Merged branch subtype-trunk into default.
[cacao.git] / src / vm / jit / i386 / emit.c
index 5c601fbcce56a3def5c54123cd8a6692fac07e31..3a264f162542561af62ca4197e098192313699a4 100644 (file)
 #include "vm/jit/i386/emit.h"
 #include "vm/jit/i386/md-abi.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 
-#include "vm/exceptions.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
 
 /* emit_load ******************************************************************
 
@@ -523,6 +521,20 @@ void emit_trap_compiler(codegendata *cd)
        M_ALD_MEM(REG_METHODPTR, TRAP_COMPILER);
 }
 
+/* emit_trap_countdown *********************************************************
+
+   Emit a countdown trap.
+
+   counter....absolute address of the counter variable
+
+*******************************************************************************/
+
+void emit_trap_countdown(codegendata *cd, s4 *counter)
+{
+       M_ISUB_IMM_MEMABS(1, (s4) counter);
+       M_BNS(6);
+       M_ALD_MEM(REG_METHODPTR, TRAP_COUNTDOWN);
+}
 
 /* emit_trap *******************************************************************
 
@@ -1078,6 +1090,11 @@ void emit_alu_imm_memabs(codegendata *cd, s4 opc, s4 imm, s4 disp)
        }
 }
 
+void emit_alu_memindex_reg(codegendata *cd, s4 opc, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
+{
+       *(cd->mcodeptr++) = (((u1) (opc)) << 3) + 3;
+       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
+}
 
 void emit_test_reg_reg(codegendata *cd, s4 reg, s4 dreg)
 {
@@ -1296,6 +1313,7 @@ void emit_jcc(codegendata *cd, s4 opc, s4 imm)
  */
 void emit_setcc_reg(codegendata *cd, s4 opc, s4 reg)
 {
+       assert(reg < 4);                     /* Can only operate on al, bl, cl, dl. */
        *(cd->mcodeptr++) = 0x0f;
        *(cd->mcodeptr++) = 0x90 + (u1) (opc);
        emit_reg(0,(reg));