mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
LJ_FR2: Fix slot 1 handling.
Contributed by Peter Cawley.
This commit is contained in:
parent
3f43f09413
commit
6a25014c1c
@ -338,6 +338,8 @@ local function formatk(tr, idx, sn)
|
|||||||
elseif t == 21 then -- int64_t
|
elseif t == 21 then -- int64_t
|
||||||
s = sub(tostring(k), 1, -3)
|
s = sub(tostring(k), 1, -3)
|
||||||
if sub(s, 1, 1) ~= "-" then s = "+"..s end
|
if sub(s, 1, 1) ~= "-" then s = "+"..s end
|
||||||
|
elseif sn == 0x1057fff then -- SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)
|
||||||
|
return "----" -- Special case for LJ_FR2 slot 1.
|
||||||
else
|
else
|
||||||
s = tostring(k) -- For primitives.
|
s = tostring(k) -- For primitives.
|
||||||
end
|
end
|
||||||
|
@ -105,7 +105,7 @@ static void rec_check_slots(jit_State *J)
|
|||||||
lua_assert(tref_isfunc(tr));
|
lua_assert(tref_isfunc(tr));
|
||||||
#if LJ_FR2
|
#if LJ_FR2
|
||||||
} else if (s == 1) {
|
} else if (s == 1) {
|
||||||
lua_assert(0);
|
lua_assert((tr & ~TREF_FRAME) == 0);
|
||||||
#endif
|
#endif
|
||||||
} else if ((tr & TREF_FRAME)) {
|
} else if ((tr & TREF_FRAME)) {
|
||||||
GCfunc *fn = gco2func(frame_gc(tv));
|
GCfunc *fn = gco2func(frame_gc(tv));
|
||||||
@ -747,7 +747,7 @@ void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs)
|
|||||||
}
|
}
|
||||||
/* Move func + args down. */
|
/* Move func + args down. */
|
||||||
if (LJ_FR2 && J->baseslot == 2)
|
if (LJ_FR2 && J->baseslot == 2)
|
||||||
J->base[func+1] = 0;
|
J->base[func+1] = TREF_FRAME;
|
||||||
memmove(&J->base[-1-LJ_FR2], &J->base[func], sizeof(TRef)*(J->maxslot+1+LJ_FR2));
|
memmove(&J->base[-1-LJ_FR2], &J->base[func], sizeof(TRef)*(J->maxslot+1+LJ_FR2));
|
||||||
/* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */
|
/* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */
|
||||||
/* Tailcalls can form a loop, so count towards the loop unroll limit. */
|
/* Tailcalls can form a loop, so count towards the loop unroll limit. */
|
||||||
|
@ -69,9 +69,13 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
|
|||||||
TRef tr = J->slot[s];
|
TRef tr = J->slot[s];
|
||||||
IRRef ref = tref_ref(tr);
|
IRRef ref = tref_ref(tr);
|
||||||
#if LJ_FR2
|
#if LJ_FR2
|
||||||
if (s == 1) continue;
|
if (s == 1) { /* Ignore slot 1 in LJ_FR2 mode, except if tailcalled. */
|
||||||
|
if ((tr & TREF_FRAME))
|
||||||
|
map[n++] = SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ((tr & (TREF_FRAME | TREF_CONT)) && !ref) {
|
if ((tr & (TREF_FRAME | TREF_CONT)) && !ref) {
|
||||||
TValue *base = J->L->base - J->baseslot;
|
cTValue *base = J->L->base - J->baseslot;
|
||||||
tr = J->slot[s] = (tr & 0xff0000) | lj_ir_k64(J, IR_KNUM, base[s].u64);
|
tr = J->slot[s] = (tr & 0xff0000) | lj_ir_k64(J, IR_KNUM, base[s].u64);
|
||||||
ref = tref_ref(tr);
|
ref = tref_ref(tr);
|
||||||
}
|
}
|
||||||
@ -470,6 +474,10 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
|
|||||||
goto setslot;
|
goto setslot;
|
||||||
bloomset(seen, ref);
|
bloomset(seen, ref);
|
||||||
if (irref_isk(ref)) {
|
if (irref_isk(ref)) {
|
||||||
|
/* See special treatment of LJ_FR2 slot 1 in snapshot_slots() above. */
|
||||||
|
if (LJ_FR2 && (sn == SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)))
|
||||||
|
tr = 0;
|
||||||
|
else
|
||||||
tr = snap_replay_const(J, ir);
|
tr = snap_replay_const(J, ir);
|
||||||
} else if (!regsp_used(ir->prev)) {
|
} else if (!regsp_used(ir->prev)) {
|
||||||
pass23 = 1;
|
pass23 = 1;
|
||||||
@ -484,7 +492,7 @@ void lj_snap_replay(jit_State *J, GCtrace *T)
|
|||||||
}
|
}
|
||||||
setslot:
|
setslot:
|
||||||
J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */
|
J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */
|
||||||
J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s);
|
J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && (s != LJ_FR2));
|
||||||
if ((sn & SNAP_FRAME))
|
if ((sn & SNAP_FRAME))
|
||||||
J->baseslot = s+1;
|
J->baseslot = s+1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user