Check for upvalue state transition in IR_UREFO.
Thanks to Peter Cawley. #1085
This commit is contained in:
@@ -1772,12 +1772,12 @@ noconstify:
|
||||
/* Note: this effectively limits LJ_MAX_UPVAL to 127. */
|
||||
uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
|
||||
if (!uvp->closed) {
|
||||
uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_PGC), fn, uv));
|
||||
/* In current stack? */
|
||||
if (uvval(uvp) >= tvref(J->L->stack) &&
|
||||
uvval(uvp) < tvref(J->L->maxstack)) {
|
||||
int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
|
||||
if (slot >= 0) { /* Aliases an SSA slot? */
|
||||
uref = tref_ref(emitir(IRT(IR_UREFO, IRT_PGC), fn, uv));
|
||||
emitir(IRTG(IR_EQ, IRT_PGC),
|
||||
REF_BASE,
|
||||
emitir(IRT(IR_ADD, IRT_PGC), uref,
|
||||
@@ -1792,12 +1792,21 @@ noconstify:
|
||||
}
|
||||
}
|
||||
}
|
||||
/* IR_UREFO+IRT_IGC is not checked for open-ness at runtime.
|
||||
** Always marked as a guard, since it might get promoted to IRT_PGC later.
|
||||
*/
|
||||
uref = emitir(IRTG(IR_UREFO, tref_isgcv(val) ? IRT_PGC : IRT_IGC), fn, uv);
|
||||
uref = tref_ref(uref);
|
||||
emitir(IRTG(IR_UGT, IRT_PGC),
|
||||
emitir(IRT(IR_SUB, IRT_PGC), uref, REF_BASE),
|
||||
lj_ir_kintpgc(J, (J->baseslot + J->maxslot) * 8));
|
||||
} else {
|
||||
/* If fn is constant, then so is the GCupval*, and the upvalue cannot
|
||||
** transition back to open, so no guard is required in this case.
|
||||
*/
|
||||
IRType t = (tref_isk(fn) ? 0 : IRT_GUARD) | IRT_PGC;
|
||||
uref = tref_ref(emitir(IRT(IR_UREFC, t), fn, uv));
|
||||
needbarrier = 1;
|
||||
uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_PGC), fn, uv));
|
||||
}
|
||||
if (val == 0) { /* Upvalue load */
|
||||
IRType t = itype2irt(uvval(uvp));
|
||||
|
||||
Reference in New Issue
Block a user