aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r--src/lj_asm.c21
1 files changed, 18 insertions, 3 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);