mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Logical 'not' must be sign-extended for address operands.
This commit is contained in:
parent
8a9cfa4b45
commit
374f534715
@ -37,19 +37,27 @@
|
||||
|.endif
|
||||
|
|
||||
|.define RA, ecx
|
||||
|.if X64; .define RAa, rcx; .else; .define RAa, RA; .endif
|
||||
|.define RAL, cl
|
||||
|.define RB, ebp // Must be ebp (C callee-save).
|
||||
|.if X64; .define RBa, rbp; .else; .define RBa, RB; .endif
|
||||
|.define RC, eax // Must be eax (fcomparepp and others).
|
||||
|.define RCW, ax
|
||||
|.define RCH, ah
|
||||
|.define RCL, al
|
||||
|.define OP, RB
|
||||
|.define RD, RC
|
||||
|.if X64; .define RDa, rax; .else; .define RDa, RD; .endif
|
||||
|.define RDW, RCW
|
||||
|.define RDL, RCL
|
||||
|.if X64
|
||||
|.define RAa, rcx
|
||||
|.define RBa, rbp
|
||||
|.define RCa, rax
|
||||
|.define RDa, rax
|
||||
|.else
|
||||
|.define RAa, RA
|
||||
|.define RBa, RB
|
||||
|.define RCa, RC
|
||||
|.define RDa, RD
|
||||
|.endif
|
||||
|
|
||||
|.if not X64
|
||||
|.define FCARG1, ecx // x86 fastcall arguments.
|
||||
@ -237,7 +245,7 @@
|
||||
|.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro
|
||||
|.macro ins_AB_; movzx RB, RCH; .endmacro
|
||||
|.macro ins_A_C; movzx RC, RCL; .endmacro
|
||||
|.macro ins_AND; not RD; .endmacro
|
||||
|.macro ins_AND; not RDa; .endmacro
|
||||
|
|
||||
|// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster).
|
||||
|.macro ins_NEXT
|
||||
@ -898,7 +906,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
|->vmeta_tgets:
|
||||
| mov TMP1, RC // RC = GCstr *
|
||||
| mov TMP2, LJ_TSTR
|
||||
| lea RC, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| cmp PC_OP, BC_GGET
|
||||
| jne >1
|
||||
| lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv.
|
||||
@ -919,7 +927,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| fstp TMPQ
|
||||
|.endif
|
||||
}
|
||||
| lea RC, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| jmp >1
|
||||
|
|
||||
|->vmeta_tgetv:
|
||||
@ -933,7 +941,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| mov L:CARG1d, SAVE_L
|
||||
| mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE.
|
||||
| mov CARG2d, RB
|
||||
| mov CARG3d, RC
|
||||
| mov CARG3, RCa // May be 64 bit ptr to stack.
|
||||
| mov L:RB, L:CARG1d
|
||||
|.else
|
||||
| mov ARG2, RB
|
||||
@ -971,7 +979,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
|->vmeta_tsets:
|
||||
| mov TMP1, RC // RC = GCstr *
|
||||
| mov TMP2, LJ_TSTR
|
||||
| lea RC, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| cmp PC_OP, BC_GSET
|
||||
| jne >1
|
||||
| lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv.
|
||||
@ -992,7 +1000,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| fstp TMPQ
|
||||
|.endif
|
||||
}
|
||||
| lea RC, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2.
|
||||
| jmp >1
|
||||
|
|
||||
|->vmeta_tsetv:
|
||||
@ -1006,7 +1014,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| mov L:CARG1d, SAVE_L
|
||||
| mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE.
|
||||
| mov CARG2d, RB
|
||||
| mov CARG3d, RC
|
||||
| mov CARG3, RCa // May be 64 bit ptr to stack.
|
||||
| mov L:RB, L:CARG1d
|
||||
|.else
|
||||
| mov ARG2, RB
|
||||
@ -1887,7 +1895,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
|
|
||||
|7: // Non-standard return case.
|
||||
| mov BASE, RA
|
||||
| mov RA, -8 // Results start at BASE+RA = BASE-8.
|
||||
| mov RAa, -8 // Results start at BASE+RA = BASE-8.
|
||||
| jmp ->vm_return
|
||||
|
|
||||
if (sse) {
|
||||
@ -3906,8 +3914,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| ins_AD // RA = dst, RD = hbits|asize
|
||||
|.if X64
|
||||
| mov L:CARG1d, SAVE_L
|
||||
|1:
|
||||
| mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE.
|
||||
|1:
|
||||
| mov CARG3d, RD
|
||||
| and RD, 0x7ff
|
||||
| shr CARG3d, 11
|
||||
@ -3982,7 +3990,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| mov L:FCARG1, L:RB
|
||||
| call extern lj_gc_step_fixtop@4 // (lua_State *L)
|
||||
| movzx RD, PC_RD // Need to reload RD.
|
||||
| not RD
|
||||
| not RDa
|
||||
| jmp <2
|
||||
break;
|
||||
|
||||
@ -4052,7 +4060,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
break;
|
||||
case BC_TGETS:
|
||||
| ins_ABC // RA = dst, RB = table, RC = str const (~)
|
||||
| not RC
|
||||
| not RCa
|
||||
| mov STR:RC, [KBASE+RC*4]
|
||||
| checktab RB, ->vmeta_tgets
|
||||
| mov TAB:RB, [BASE+RB*8]
|
||||
@ -4182,7 +4190,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
break;
|
||||
case BC_TSETS:
|
||||
| ins_ABC // RA = src, RB = table, RC = str const (~)
|
||||
| not RC
|
||||
| not RCa
|
||||
| mov STR:RC, [KBASE+RC*4]
|
||||
| checktab RB, ->vmeta_tsets
|
||||
| mov TAB:RB, [BASE+RB*8]
|
||||
@ -4427,7 +4435,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| test PC, FRAME_TYPE // Lua frame below?
|
||||
| jnz <4
|
||||
| movzx RD, PC_RA // Need to prepare BASE/KBASE.
|
||||
| not RD
|
||||
| not RDa
|
||||
| lea BASE, [BASE+RD*8]
|
||||
| mov LFUNC:KBASE, [BASE-8]
|
||||
| mov PROTO:KBASE, LFUNC:KBASE->pt
|
||||
@ -4591,7 +4599,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
break;
|
||||
}
|
||||
| movzx RA, PC_RA
|
||||
| not RA // Note: ~RA = -(RA+1)
|
||||
| not RAa // Note: ~RA = -(RA+1)
|
||||
| lea BASE, [BASE+RA*8] // base = base - (RA+1)*8
|
||||
| mov LFUNC:KBASE, [BASE-8]
|
||||
| mov PROTO:KBASE, LFUNC:KBASE->pt
|
||||
|
@ -224,14 +224,14 @@ LJLIB_CF(jit_util_funcbc)
|
||||
LJLIB_CF(jit_util_funck)
|
||||
{
|
||||
GCproto *pt = check_Lproto(L, 0);
|
||||
MSize idx = (MSize)lj_lib_checkint(L, 2);
|
||||
if ((int32_t)idx >= 0) {
|
||||
if (idx < pt->sizekn) {
|
||||
ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2);
|
||||
if (idx >= 0) {
|
||||
if (idx < (ptrdiff_t)pt->sizekn) {
|
||||
setnumV(L->top-1, pt->k.n[idx]);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (~idx < pt->sizekgc) {
|
||||
if (~idx < (ptrdiff_t)pt->sizekgc) {
|
||||
GCobj *gc = gcref(pt->k.gc[idx]);
|
||||
setgcV(L, L->top-1, &gc->gch, ~gc->gch.gct);
|
||||
return 1;
|
||||
|
@ -107,10 +107,10 @@ restart:
|
||||
if (ra == slot) { slot = bc_d(ins); goto restart; }
|
||||
break;
|
||||
case BC_GGET:
|
||||
*name = strdata(gco2str(gcref(pt->k.gc[~bc_d(ins)])));
|
||||
*name = strdata(gco2str(gcref(pt->k.gc[~(ptrdiff_t)bc_d(ins)])));
|
||||
return "global";
|
||||
case BC_TGETS:
|
||||
*name = strdata(gco2str(gcref(pt->k.gc[~bc_c(ins)])));
|
||||
*name = strdata(gco2str(gcref(pt->k.gc[~(ptrdiff_t)bc_c(ins)])));
|
||||
if (ip > pt->bc) {
|
||||
BCIns insp = ip[-1];
|
||||
if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 &&
|
||||
|
@ -169,7 +169,7 @@ GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent)
|
||||
nuv = fn->l.nupvalues;
|
||||
base = L->base;
|
||||
for (i = 0; i < nuv; i++) {
|
||||
int v = pt->uv[i];
|
||||
ptrdiff_t v = pt->uv[i];
|
||||
GCupval *uv = v < 0 ? &gcref(puv[~v])->uv : func_finduv(L, base + v);
|
||||
setgcref(fn->l.uvptr[i], obj2gco(uv));
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne)
|
||||
top = curr_top(L);
|
||||
setcont(top, ne ? lj_cont_condf : lj_cont_condt);
|
||||
copyTV(L, top+1, mo);
|
||||
it = ~o1->gch.gct;
|
||||
it = ~(int32_t)o1->gch.gct;
|
||||
setgcV(L, top+2, &o1->gch, it);
|
||||
setgcV(L, top+3, &o2->gch, it);
|
||||
return top+2; /* Trigger metamethod call. */
|
||||
|
@ -1751,7 +1751,7 @@ void lj_record_ins(jit_State *J)
|
||||
case BCMpri: setitype(rcv, (int32_t)~rc); rc = TREF_PRI(IRT_NIL+rc); break;
|
||||
case BCMnum: { lua_Number n = J->pt->k.n[rc];
|
||||
setnumV(rcv, n); ix.key = rc = lj_ir_knumint(J, n); } break;
|
||||
case BCMstr: { GCstr *s = strref(J->pt->k.gc[~rc]);
|
||||
case BCMstr: { GCstr *s = strref(J->pt->k.gc[~(ptrdiff_t)rc]);
|
||||
setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break;
|
||||
default: break; /* Handled later. */
|
||||
}
|
||||
@ -1943,7 +1943,7 @@ void lj_record_ins(jit_State *J)
|
||||
break;
|
||||
case BC_TDUP:
|
||||
rc = emitir(IRT(IR_TDUP, IRT_TAB),
|
||||
lj_ir_ktab(J, tabref(J->pt->k.gc[~rc])), 0);
|
||||
lj_ir_ktab(J, tabref(J->pt->k.gc[~(ptrdiff_t)rc])), 0);
|
||||
break;
|
||||
|
||||
/* -- Calls and vararg handling ----------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user