]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Don't eliminate SLOAD restores across RETF.
authorMike Pall <mike>
Tue, 23 Feb 2010 02:08:49 +0000 (03:08 +0100)
committerMike Pall <mike>
Tue, 23 Feb 2010 02:08:49 +0000 (03:08 +0100)
Move restore-elimination logic into snapshot_slots().

src/lj_asm.c
src/lj_jit.h
src/lj_snap.c

index 1e934d7ceacd9cc4643b3b6b53e5ce030218a9a8..3813a5d7d54ec894f834a2c5c715b545488678b4 100644 (file)
@@ -2581,9 +2581,7 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap)
     int32_t ofs = 8*((int32_t)s-1);
     IRRef ref = snap_ref(sn);
     IRIns *ir = IR(ref);
-    /* No need to restore readonly slots and unmodified non-parent slots. */
-    if (ir->o == IR_SLOAD && ir->op1 == s &&
-       (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT)
+    if ((sn & SNAP_NORESTORE))
       continue;
     if (irt_isnum(ir->t)) {
       Reg src = ra_alloc1(as, ref, RSET_FPR);
index 68cebbc26aeb0ba6c4e0685bff5414bb379b5e76..18069ac9f7330b6f209a64a566d0ef14095433a4 100644 (file)
@@ -125,6 +125,7 @@ typedef uint32_t SnapEntry;
 
 #define SNAP_FRAME             0x010000        /* Frame slot. */
 #define SNAP_CONT              0x020000        /* Continuation slot. */
+#define SNAP_NORESTORE         0x040000        /* No need to restore slot. */
 LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME);
 LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT);
 
index 1353e90f62249ec6591d9d57e12b56a404a554f2..2b82e67288754fde31865186a2b2e993c987c207 100644 (file)
@@ -53,16 +53,24 @@ void lj_snap_grow_map_(jit_State *J, MSize need)
 /* Add all modified slots to the snapshot. */
 static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
 {
+  IRRef retf = J->chain[IR_RETF];  /* Limits SLOAD restore elimination. */
   BCReg s;
   MSize n = 0;
   for (s = 0; s < nslots; s++) {
     TRef tr = J->slot[s];
     IRRef ref = tref_ref(tr);
     if (ref) {
+      SnapEntry sn = SNAP_TR(s, tr);
       IRIns *ir = IR(ref);
-      if (!(ir->o == IR_SLOAD && ir->op1 == s &&
-           !(ir->op2 & IRSLOAD_INHERIT)))
-       map[n++] = SNAP_TR(s, tr);
+      if (ir->o == IR_SLOAD && ir->op1 == s && ref > retf) {
+       /* No need to snapshot unmodified non-inherited slots. */
+       if (!(ir->op2 & IRSLOAD_INHERIT))
+         continue;
+       /* No need to restore readonly slots and unmodified non-parent slots. */
+       if ((ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT)
+         sn |= SNAP_NORESTORE;
+      }
+      map[n++] = sn;
     }
   }
   return n;