aboutsummaryrefslogtreecommitdiff
path: root/src/lj_snap.c
diff options
context:
space:
mode:
authorMike Pall <mike>2016-10-16 21:04:38 +0200
committerMike Pall <mike>2016-10-16 21:04:38 +0200
commit6a25014c1c33448cabdc013ccb9e5c4fc98a0238 (patch)
treec3c3bfc7ceadd3f38c02e31fa8754bfaea90c323 /src/lj_snap.c
parent3f43f09413c49a1f4cffc0e060d755e84c5df85e (diff)
downloadluajit-6a25014c1c33448cabdc013ccb9e5c4fc98a0238.tar.gz
luajit-6a25014c1c33448cabdc013ccb9e5c4fc98a0238.tar.bz2
luajit-6a25014c1c33448cabdc013ccb9e5c4fc98a0238.zip
LJ_FR2: Fix slot 1 handling.
Contributed by Peter Cawley.
Diffstat (limited to 'src/lj_snap.c')
-rw-r--r--src/lj_snap.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lj_snap.c b/src/lj_snap.c
index 48259972..8ca6deb7 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -69,9 +69,13 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
69 TRef tr = J->slot[s]; 69 TRef tr = J->slot[s];
70 IRRef ref = tref_ref(tr); 70 IRRef ref = tref_ref(tr);
71#if LJ_FR2 71#if LJ_FR2
72 if (s == 1) continue; 72 if (s == 1) { /* Ignore slot 1 in LJ_FR2 mode, except if tailcalled. */
73 if ((tr & TREF_FRAME))
74 map[n++] = SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL);
75 continue;
76 }
73 if ((tr & (TREF_FRAME | TREF_CONT)) && !ref) { 77 if ((tr & (TREF_FRAME | TREF_CONT)) && !ref) {
74 TValue *base = J->L->base - J->baseslot; 78 cTValue *base = J->L->base - J->baseslot;
75 tr = J->slot[s] = (tr & 0xff0000) | lj_ir_k64(J, IR_KNUM, base[s].u64); 79 tr = J->slot[s] = (tr & 0xff0000) | lj_ir_k64(J, IR_KNUM, base[s].u64);
76 ref = tref_ref(tr); 80 ref = tref_ref(tr);
77 } 81 }
@@ -470,7 +474,11 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
470 goto setslot; 474 goto setslot;
471 bloomset(seen, ref); 475 bloomset(seen, ref);
472 if (irref_isk(ref)) { 476 if (irref_isk(ref)) {
473 tr = snap_replay_const(J, ir); 477 /* See special treatment of LJ_FR2 slot 1 in snapshot_slots() above. */
478 if (LJ_FR2 && (sn == SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)))
479 tr = 0;
480 else
481 tr = snap_replay_const(J, ir);
474 } else if (!regsp_used(ir->prev)) { 482 } else if (!regsp_used(ir->prev)) {
475 pass23 = 1; 483 pass23 = 1;
476 lua_assert(s != 0); 484 lua_assert(s != 0);
@@ -484,7 +492,7 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
484 } 492 }
485 setslot: 493 setslot:
486 J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */ 494 J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */
487 J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s); 495 J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && (s != LJ_FR2));
488 if ((sn & SNAP_FRAME)) 496 if ((sn & SNAP_FRAME))
489 J->baseslot = s+1; 497 J->baseslot = s+1;
490 } 498 }