diff options
author | Mike Pall <mike> | 2010-02-23 03:08:49 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-23 03:08:49 +0100 |
commit | c1362dcac98bb73ff308e3453279d52e988a555b (patch) | |
tree | 98891212ccb4d8b7f6dc9559fa6c2fb43964758b /src | |
parent | f751cd1d6ff2ff1caab338cd2294f69cab34ae04 (diff) | |
download | luajit-c1362dcac98bb73ff308e3453279d52e988a555b.tar.gz luajit-c1362dcac98bb73ff308e3453279d52e988a555b.tar.bz2 luajit-c1362dcac98bb73ff308e3453279d52e988a555b.zip |
Don't eliminate SLOAD restores across RETF.
Move restore-elimination logic into snapshot_slots().
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_asm.c | 4 | ||||
-rw-r--r-- | src/lj_jit.h | 1 | ||||
-rw-r--r-- | src/lj_snap.c | 14 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c index 1e934d7c..3813a5d7 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c | |||
@@ -2581,9 +2581,7 @@ static void asm_stack_restore(ASMState *as, SnapShot *snap) | |||
2581 | int32_t ofs = 8*((int32_t)s-1); | 2581 | int32_t ofs = 8*((int32_t)s-1); |
2582 | IRRef ref = snap_ref(sn); | 2582 | IRRef ref = snap_ref(sn); |
2583 | IRIns *ir = IR(ref); | 2583 | IRIns *ir = IR(ref); |
2584 | /* No need to restore readonly slots and unmodified non-parent slots. */ | 2584 | if ((sn & SNAP_NORESTORE)) |
2585 | if (ir->o == IR_SLOAD && ir->op1 == s && | ||
2586 | (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) | ||
2587 | continue; | 2585 | continue; |
2588 | if (irt_isnum(ir->t)) { | 2586 | if (irt_isnum(ir->t)) { |
2589 | Reg src = ra_alloc1(as, ref, RSET_FPR); | 2587 | Reg src = ra_alloc1(as, ref, RSET_FPR); |
diff --git a/src/lj_jit.h b/src/lj_jit.h index 68cebbc2..18069ac9 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -125,6 +125,7 @@ typedef uint32_t SnapEntry; | |||
125 | 125 | ||
126 | #define SNAP_FRAME 0x010000 /* Frame slot. */ | 126 | #define SNAP_FRAME 0x010000 /* Frame slot. */ |
127 | #define SNAP_CONT 0x020000 /* Continuation slot. */ | 127 | #define SNAP_CONT 0x020000 /* Continuation slot. */ |
128 | #define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ | ||
128 | LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); | 129 | LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); |
129 | LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); | 130 | LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); |
130 | 131 | ||
diff --git a/src/lj_snap.c b/src/lj_snap.c index 1353e90f..2b82e672 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
@@ -53,16 +53,24 @@ void lj_snap_grow_map_(jit_State *J, MSize need) | |||
53 | /* Add all modified slots to the snapshot. */ | 53 | /* Add all modified slots to the snapshot. */ |
54 | static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) | 54 | static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) |
55 | { | 55 | { |
56 | IRRef retf = J->chain[IR_RETF]; /* Limits SLOAD restore elimination. */ | ||
56 | BCReg s; | 57 | BCReg s; |
57 | MSize n = 0; | 58 | MSize n = 0; |
58 | for (s = 0; s < nslots; s++) { | 59 | for (s = 0; s < nslots; s++) { |
59 | TRef tr = J->slot[s]; | 60 | TRef tr = J->slot[s]; |
60 | IRRef ref = tref_ref(tr); | 61 | IRRef ref = tref_ref(tr); |
61 | if (ref) { | 62 | if (ref) { |
63 | SnapEntry sn = SNAP_TR(s, tr); | ||
62 | IRIns *ir = IR(ref); | 64 | IRIns *ir = IR(ref); |
63 | if (!(ir->o == IR_SLOAD && ir->op1 == s && | 65 | if (ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { |
64 | !(ir->op2 & IRSLOAD_INHERIT))) | 66 | /* No need to snapshot unmodified non-inherited slots. */ |
65 | map[n++] = SNAP_TR(s, tr); | 67 | if (!(ir->op2 & IRSLOAD_INHERIT)) |
68 | continue; | ||
69 | /* No need to restore readonly slots and unmodified non-parent slots. */ | ||
70 | if ((ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) | ||
71 | sn |= SNAP_NORESTORE; | ||
72 | } | ||
73 | map[n++] = sn; | ||
66 | } | 74 | } |
67 | } | 75 | } |
68 | return n; | 76 | return n; |