aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2012-07-02 22:42:40 +0200
committerMike Pall <mike>2012-07-02 22:42:40 +0200
commit5d0115ef8df093ce9737d00ad35d2fcc693df83f (patch)
treeac4268983040eba4ef45a4e4fea775062db34154 /src
parent264177b0d041fdea5e07091a0c585607e9b55828 (diff)
downloadluajit-5d0115ef8df093ce9737d00ad35d2fcc693df83f.tar.gz
luajit-5d0115ef8df093ce9737d00ad35d2fcc693df83f.tar.bz2
luajit-5d0115ef8df093ce9737d00ad35d2fcc693df83f.zip
Add explicit IR_GCSTEP instruction.
Diffstat (limited to 'src')
-rw-r--r--src/lj_asm.c21
-rw-r--r--src/lj_asm_arm.h3
-rw-r--r--src/lj_asm_mips.h3
-rw-r--r--src/lj_asm_ppc.h3
-rw-r--r--src/lj_asm_x86.h3
-rw-r--r--src/lj_ir.h1
6 files changed, 27 insertions, 7 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index e8e823c3..dccc4eab 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -71,7 +71,7 @@ typedef struct ASMState {
71 IRRef loopref; /* Reference of LOOP instruction (or 0). */ 71 IRRef loopref; /* Reference of LOOP instruction (or 0). */
72 72
73 BCReg topslot; /* Number of slots for stack check (unless 0). */ 73 BCReg topslot; /* Number of slots for stack check (unless 0). */
74 MSize gcsteps; /* Accumulated number of GC steps (per section). */ 74 int32_t gcsteps; /* Accumulated number of GC steps (per section). */
75 75
76 GCtrace *T; /* Trace to assemble. */ 76 GCtrace *T; /* Trace to assemble. */
77 GCtrace *parent; /* Parent trace (or NULL). */ 77 GCtrace *parent; /* Parent trace (or NULL). */
@@ -972,6 +972,22 @@ static void asm_tdup(ASMState *as, IRIns *ir)
972 asm_gencall(as, ci, args); 972 asm_gencall(as, ci, args);
973} 973}
974 974
975static void asm_gc_check(ASMState *as);
976
977/* Explicit GC step. */
978static void asm_gcstep(ASMState *as, IRIns *ir)
979{
980 IRIns *ira;
981 for (ira = IR(as->stopins+1); ira < ir; ira++)
982 if ((ira->o == IR_TNEW || ira->o == IR_TDUP ||
983 (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI))) &&
984 ra_used(ira))
985 as->gcsteps++;
986 if (as->gcsteps)
987 asm_gc_check(as);
988 as->gcsteps = 0x80000000; /* Prevent implicit GC check further up. */
989}
990
975/* -- PHI and loop handling ----------------------------------------------- */ 991/* -- PHI and loop handling ----------------------------------------------- */
976 992
977/* Break a PHI cycle by renaming to a free register (evict if needed). */ 993/* Break a PHI cycle by renaming to a free register (evict if needed). */
@@ -1191,7 +1207,6 @@ static void asm_phi(ASMState *as, IRIns *ir)
1191 } 1207 }
1192} 1208}
1193 1209
1194static void asm_gc_check(ASMState *as);
1195static void asm_loop_fixup(ASMState *as); 1210static void asm_loop_fixup(ASMState *as);
1196 1211
1197/* Middle part of a loop. */ 1212/* Middle part of a loop. */
@@ -1757,7 +1772,7 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
1757 /* Emit head of trace. */ 1772 /* Emit head of trace. */
1758 RA_DBG_REF(); 1773 RA_DBG_REF();
1759 checkmclim(as); 1774 checkmclim(as);
1760 if (as->gcsteps) { 1775 if (as->gcsteps > 0) {
1761 as->curins = as->T->snap[0].ref; 1776 as->curins = as->T->snap[0].ref;
1762 asm_snap_prep(as); /* The GC check is a guard. */ 1777 asm_snap_prep(as); /* The GC check is a guard. */
1763 asm_gc_check(as); 1778 asm_gc_check(as);
diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h
index c08b6196..e6ab3573 100644
--- a/src/lj_asm_arm.h
+++ b/src/lj_asm_arm.h
@@ -1532,7 +1532,7 @@ static void asm_gc_check(ASMState *as)
1532 asm_gencall(as, ci, args); 1532 asm_gencall(as, ci, args);
1533 tmp1 = ra_releasetmp(as, ASMREF_TMP1); 1533 tmp1 = ra_releasetmp(as, ASMREF_TMP1);
1534 tmp2 = ra_releasetmp(as, ASMREF_TMP2); 1534 tmp2 = ra_releasetmp(as, ASMREF_TMP2);
1535 emit_loadi(as, tmp2, (int32_t)as->gcsteps); 1535 emit_loadi(as, tmp2, as->gcsteps);
1536 /* Jump around GC step if GC total < GC threshold. */ 1536 /* Jump around GC step if GC total < GC threshold. */
1537 emit_branch(as, ARMF_CC(ARMI_B, CC_LS), l_end); 1537 emit_branch(as, ARMF_CC(ARMI_B, CC_LS), l_end);
1538 emit_nm(as, ARMI_CMP, RID_TMP, tmp2); 1538 emit_nm(as, ARMI_CMP, RID_TMP, tmp2);
@@ -1646,6 +1646,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
1646 case IR_USE: ra_alloc1(as, ir->op1, RSET_GPR); break; 1646 case IR_USE: ra_alloc1(as, ir->op1, RSET_GPR); break;
1647 case IR_PHI: asm_phi(as, ir); break; 1647 case IR_PHI: asm_phi(as, ir); break;
1648 case IR_HIOP: asm_hiop(as, ir); break; 1648 case IR_HIOP: asm_hiop(as, ir); break;
1649 case IR_GCSTEP: asm_gcstep(as, ir); break;
1649 1650
1650 /* Guarded assertions. */ 1651 /* Guarded assertions. */
1651 case IR_EQ: case IR_NE: 1652 case IR_EQ: case IR_NE:
diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h
index a3a4da6c..b42f9f9a 100644
--- a/src/lj_asm_mips.h
+++ b/src/lj_asm_mips.h
@@ -1673,7 +1673,7 @@ static void asm_gc_check(ASMState *as)
1673 asm_gencall(as, ci, args); 1673 asm_gencall(as, ci, args);
1674 emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); 1674 emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768);
1675 tmp = ra_releasetmp(as, ASMREF_TMP2); 1675 tmp = ra_releasetmp(as, ASMREF_TMP2);
1676 emit_loadi(as, tmp, (int32_t)as->gcsteps); 1676 emit_loadi(as, tmp, as->gcsteps);
1677 /* Jump around GC step if GC total < GC threshold. */ 1677 /* Jump around GC step if GC total < GC threshold. */
1678 emit_branch(as, MIPSI_BNE, RID_TMP, RID_ZERO, l_end); 1678 emit_branch(as, MIPSI_BNE, RID_TMP, RID_ZERO, l_end);
1679 emit_dst(as, MIPSI_SLTU, RID_TMP, RID_TMP, tmp); 1679 emit_dst(as, MIPSI_SLTU, RID_TMP, RID_TMP, tmp);
@@ -1770,6 +1770,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
1770 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; 1770 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break;
1771 case IR_PHI: asm_phi(as, ir); break; 1771 case IR_PHI: asm_phi(as, ir); break;
1772 case IR_HIOP: asm_hiop(as, ir); break; 1772 case IR_HIOP: asm_hiop(as, ir); break;
1773 case IR_GCSTEP: asm_gcstep(as, ir); break;
1773 1774
1774 /* Guarded assertions. */ 1775 /* Guarded assertions. */
1775 case IR_EQ: case IR_NE: asm_compeq(as, ir); break; 1776 case IR_EQ: case IR_NE: asm_compeq(as, ir); break;
diff --git a/src/lj_asm_ppc.h b/src/lj_asm_ppc.h
index ec22e260..5d538fc8 100644
--- a/src/lj_asm_ppc.h
+++ b/src/lj_asm_ppc.h
@@ -1856,7 +1856,7 @@ static void asm_gc_check(ASMState *as)
1856 asm_gencall(as, ci, args); 1856 asm_gencall(as, ci, args);
1857 emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); 1857 emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768);
1858 tmp = ra_releasetmp(as, ASMREF_TMP2); 1858 tmp = ra_releasetmp(as, ASMREF_TMP2);
1859 emit_loadi(as, tmp, (int32_t)as->gcsteps); 1859 emit_loadi(as, tmp, as->gcsteps);
1860 /* Jump around GC step if GC total < GC threshold. */ 1860 /* Jump around GC step if GC total < GC threshold. */
1861 emit_condbranch(as, PPCI_BC|PPCF_Y, CC_LT, l_end); 1861 emit_condbranch(as, PPCI_BC|PPCF_Y, CC_LT, l_end);
1862 emit_ab(as, PPCI_CMPLW, RID_TMP, tmp); 1862 emit_ab(as, PPCI_CMPLW, RID_TMP, tmp);
@@ -1966,6 +1966,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
1966 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; 1966 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break;
1967 case IR_PHI: asm_phi(as, ir); break; 1967 case IR_PHI: asm_phi(as, ir); break;
1968 case IR_HIOP: asm_hiop(as, ir); break; 1968 case IR_HIOP: asm_hiop(as, ir); break;
1969 case IR_GCSTEP: asm_gcstep(as, ir); break;
1969 1970
1970 /* Guarded assertions. */ 1971 /* Guarded assertions. */
1971 case IR_EQ: case IR_NE: 1972 case IR_EQ: case IR_NE:
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h
index 7647b03f..4537e1d5 100644
--- a/src/lj_asm_x86.h
+++ b/src/lj_asm_x86.h
@@ -2379,7 +2379,7 @@ static void asm_gc_check(ASMState *as)
2379 asm_gencall(as, ci, args); 2379 asm_gencall(as, ci, args);
2380 tmp = ra_releasetmp(as, ASMREF_TMP1); 2380 tmp = ra_releasetmp(as, ASMREF_TMP1);
2381 emit_loada(as, tmp, J2G(as->J)); 2381 emit_loada(as, tmp, J2G(as->J));
2382 emit_loadi(as, ra_releasetmp(as, ASMREF_TMP2), (int32_t)as->gcsteps); 2382 emit_loadi(as, ra_releasetmp(as, ASMREF_TMP2), as->gcsteps);
2383 /* Jump around GC step if GC total < GC threshold. */ 2383 /* Jump around GC step if GC total < GC threshold. */
2384 emit_sjcc(as, CC_B, l_end); 2384 emit_sjcc(as, CC_B, l_end);
2385 emit_opgl(as, XO_ARITH(XOg_CMP), tmp, gc.threshold); 2385 emit_opgl(as, XO_ARITH(XOg_CMP), tmp, gc.threshold);
@@ -2556,6 +2556,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
2556 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; 2556 ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break;
2557 case IR_PHI: asm_phi(as, ir); break; 2557 case IR_PHI: asm_phi(as, ir); break;
2558 case IR_HIOP: asm_hiop(as, ir); break; 2558 case IR_HIOP: asm_hiop(as, ir); break;
2559 case IR_GCSTEP: asm_gcstep(as, ir); break;
2559 2560
2560 /* Guarded assertions. */ 2561 /* Guarded assertions. */
2561 case IR_LT: case IR_GE: case IR_LE: case IR_GT: 2562 case IR_LT: case IR_GE: case IR_LE: case IR_GT:
diff --git a/src/lj_ir.h b/src/lj_ir.h
index a8f48ffb..b10c65df 100644
--- a/src/lj_ir.h
+++ b/src/lj_ir.h
@@ -33,6 +33,7 @@
33 /* Miscellaneous ops. */ \ 33 /* Miscellaneous ops. */ \
34 _(NOP, N , ___, ___) \ 34 _(NOP, N , ___, ___) \
35 _(BASE, N , lit, lit) \ 35 _(BASE, N , lit, lit) \
36 _(GCSTEP, S , ___, ___) \
36 _(HIOP, S , ref, ref) \ 37 _(HIOP, S , ref, ref) \
37 _(LOOP, S , ___, ___) \ 38 _(LOOP, S , ___, ___) \
38 _(USE, S , ref, ___) \ 39 _(USE, S , ref, ___) \