mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fix bytecode JMP slot range after const + and/or optimization.
This commit is contained in:
parent
44876ec99f
commit
39112fd6fb
@ -269,20 +269,23 @@ static int jmp_novalue(FuncState *fs, BCPos list)
|
|||||||
/* Patch register of test instructions. */
|
/* Patch register of test instructions. */
|
||||||
static int jmp_patchtestreg(FuncState *fs, BCPos pc, BCReg reg)
|
static int jmp_patchtestreg(FuncState *fs, BCPos pc, BCReg reg)
|
||||||
{
|
{
|
||||||
BCIns *ip = &fs->bcbase[pc >= 1 ? pc-1 : pc].ins;
|
BCInsLine *ilp = &fs->bcbase[pc >= 1 ? pc-1 : pc];
|
||||||
BCOp op = bc_op(*ip);
|
BCOp op = bc_op(ilp->ins);
|
||||||
if (op == BC_ISTC || op == BC_ISFC) {
|
if (op == BC_ISTC || op == BC_ISFC) {
|
||||||
if (reg != NO_REG && reg != bc_d(*ip)) {
|
if (reg != NO_REG && reg != bc_d(ilp->ins)) {
|
||||||
setbc_a(ip, reg);
|
setbc_a(&ilp->ins, reg);
|
||||||
} else { /* Nothing to store or already in the right register. */
|
} else { /* Nothing to store or already in the right register. */
|
||||||
setbc_op(ip, op+(BC_IST-BC_ISTC));
|
setbc_op(&ilp->ins, op+(BC_IST-BC_ISTC));
|
||||||
setbc_a(ip, 0);
|
setbc_a(&ilp->ins, 0);
|
||||||
|
}
|
||||||
|
} else if (bc_a(ilp->ins) == NO_REG) {
|
||||||
|
if (reg == NO_REG) {
|
||||||
|
ilp->ins = BCINS_AJ(BC_JMP, bc_a(fs->bcbase[pc].ins), 0);
|
||||||
|
} else {
|
||||||
|
setbc_a(&ilp->ins, reg);
|
||||||
|
if (reg >= bc_a(ilp[1].ins))
|
||||||
|
setbc_a(&ilp[1].ins, reg+1);
|
||||||
}
|
}
|
||||||
} else if (bc_a(*ip) == NO_REG) {
|
|
||||||
if (reg == NO_REG)
|
|
||||||
*ip = BCINS_AJ(BC_JMP, bc_a(fs->bcbase[pc].ins), 0);
|
|
||||||
else
|
|
||||||
setbc_a(ip, reg);
|
|
||||||
} else {
|
} else {
|
||||||
return 0; /* Cannot patch other instructions. */
|
return 0; /* Cannot patch other instructions. */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user