diff options
| author | Mike Pall <mike> | 2009-12-29 01:38:26 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2009-12-29 01:38:26 +0100 |
| commit | 374f53471528e1592d9075c47e579d2f3c546beb (patch) | |
| tree | 46fabaa61de90e0bf232de21ab70370eb61af6c1 /src | |
| parent | 8a9cfa4b4592e50be1903b83d28c8ea2fbc4aa43 (diff) | |
| download | luajit-374f53471528e1592d9075c47e579d2f3c546beb.tar.gz luajit-374f53471528e1592d9075c47e579d2f3c546beb.tar.bz2 luajit-374f53471528e1592d9075c47e579d2f3c546beb.zip | |
Logical 'not' must be sign-extended for address operands.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buildvm_x86.dasc | 42 | ||||
| -rw-r--r-- | src/lib_jit.c | 8 | ||||
| -rw-r--r-- | src/lj_err.c | 4 | ||||
| -rw-r--r-- | src/lj_func.c | 2 | ||||
| -rw-r--r-- | src/lj_meta.c | 2 | ||||
| -rw-r--r-- | src/lj_record.c | 4 |
6 files changed, 35 insertions, 27 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index 0f0488be..d2bb80df 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
| @@ -37,19 +37,27 @@ | |||
| 37 | |.endif | 37 | |.endif |
| 38 | | | 38 | | |
| 39 | |.define RA, ecx | 39 | |.define RA, ecx |
| 40 | |.if X64; .define RAa, rcx; .else; .define RAa, RA; .endif | ||
| 41 | |.define RAL, cl | 40 | |.define RAL, cl |
| 42 | |.define RB, ebp // Must be ebp (C callee-save). | 41 | |.define RB, ebp // Must be ebp (C callee-save). |
| 43 | |.if X64; .define RBa, rbp; .else; .define RBa, RB; .endif | ||
| 44 | |.define RC, eax // Must be eax (fcomparepp and others). | 42 | |.define RC, eax // Must be eax (fcomparepp and others). |
| 45 | |.define RCW, ax | 43 | |.define RCW, ax |
| 46 | |.define RCH, ah | 44 | |.define RCH, ah |
| 47 | |.define RCL, al | 45 | |.define RCL, al |
| 48 | |.define OP, RB | 46 | |.define OP, RB |
| 49 | |.define RD, RC | 47 | |.define RD, RC |
| 50 | |.if X64; .define RDa, rax; .else; .define RDa, RD; .endif | ||
| 51 | |.define RDW, RCW | 48 | |.define RDW, RCW |
| 52 | |.define RDL, RCL | 49 | |.define RDL, RCL |
| 50 | |.if X64 | ||
| 51 | |.define RAa, rcx | ||
| 52 | |.define RBa, rbp | ||
| 53 | |.define RCa, rax | ||
| 54 | |.define RDa, rax | ||
| 55 | |.else | ||
| 56 | |.define RAa, RA | ||
| 57 | |.define RBa, RB | ||
| 58 | |.define RCa, RC | ||
| 59 | |.define RDa, RD | ||
| 60 | |.endif | ||
| 53 | | | 61 | | |
| 54 | |.if not X64 | 62 | |.if not X64 |
| 55 | |.define FCARG1, ecx // x86 fastcall arguments. | 63 | |.define FCARG1, ecx // x86 fastcall arguments. |
| @@ -237,7 +245,7 @@ | |||
| 237 | |.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro | 245 | |.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro |
| 238 | |.macro ins_AB_; movzx RB, RCH; .endmacro | 246 | |.macro ins_AB_; movzx RB, RCH; .endmacro |
| 239 | |.macro ins_A_C; movzx RC, RCL; .endmacro | 247 | |.macro ins_A_C; movzx RC, RCL; .endmacro |
| 240 | |.macro ins_AND; not RD; .endmacro | 248 | |.macro ins_AND; not RDa; .endmacro |
| 241 | | | 249 | | |
| 242 | |// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster). | 250 | |// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster). |
| 243 | |.macro ins_NEXT | 251 | |.macro ins_NEXT |
| @@ -898,7 +906,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
| 898 | |->vmeta_tgets: | 906 | |->vmeta_tgets: |
| 899 | | mov TMP1, RC // RC = GCstr * | 907 | | mov TMP1, RC // RC = GCstr * |
| 900 | | mov TMP2, LJ_TSTR | 908 | | mov TMP2, LJ_TSTR |
| 901 | | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. | 909 | | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. |
| 902 | | cmp PC_OP, BC_GGET | 910 | | cmp PC_OP, BC_GGET |
| 903 | | jne >1 | 911 | | jne >1 |
| 904 | | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. | 912 | | 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) | |||
| 919 | | fstp TMPQ | 927 | | fstp TMPQ |
| 920 | |.endif | 928 | |.endif |
| 921 | } | 929 | } |
| 922 | | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. | 930 | | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. |
| 923 | | jmp >1 | 931 | | jmp >1 |
| 924 | | | 932 | | |
| 925 | |->vmeta_tgetv: | 933 | |->vmeta_tgetv: |
| @@ -933,7 +941,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
| 933 | | mov L:CARG1d, SAVE_L | 941 | | mov L:CARG1d, SAVE_L |
| 934 | | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | 942 | | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. |
| 935 | | mov CARG2d, RB | 943 | | mov CARG2d, RB |
| 936 | | mov CARG3d, RC | 944 | | mov CARG3, RCa // May be 64 bit ptr to stack. |
| 937 | | mov L:RB, L:CARG1d | 945 | | mov L:RB, L:CARG1d |
| 938 | |.else | 946 | |.else |
| 939 | | mov ARG2, RB | 947 | | mov ARG2, RB |
| @@ -971,7 +979,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
| 971 | |->vmeta_tsets: | 979 | |->vmeta_tsets: |
| 972 | | mov TMP1, RC // RC = GCstr * | 980 | | mov TMP1, RC // RC = GCstr * |
| 973 | | mov TMP2, LJ_TSTR | 981 | | mov TMP2, LJ_TSTR |
| 974 | | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. | 982 | | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. |
| 975 | | cmp PC_OP, BC_GSET | 983 | | cmp PC_OP, BC_GSET |
| 976 | | jne >1 | 984 | | jne >1 |
| 977 | | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. | 985 | | 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) | |||
| 992 | | fstp TMPQ | 1000 | | fstp TMPQ |
| 993 | |.endif | 1001 | |.endif |
| 994 | } | 1002 | } |
| 995 | | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. | 1003 | | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. |
| 996 | | jmp >1 | 1004 | | jmp >1 |
| 997 | | | 1005 | | |
| 998 | |->vmeta_tsetv: | 1006 | |->vmeta_tsetv: |
| @@ -1006,7 +1014,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
| 1006 | | mov L:CARG1d, SAVE_L | 1014 | | mov L:CARG1d, SAVE_L |
| 1007 | | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | 1015 | | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. |
| 1008 | | mov CARG2d, RB | 1016 | | mov CARG2d, RB |
| 1009 | | mov CARG3d, RC | 1017 | | mov CARG3, RCa // May be 64 bit ptr to stack. |
| 1010 | | mov L:RB, L:CARG1d | 1018 | | mov L:RB, L:CARG1d |
| 1011 | |.else | 1019 | |.else |
| 1012 | | mov ARG2, RB | 1020 | | mov ARG2, RB |
| @@ -1887,7 +1895,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
| 1887 | | | 1895 | | |
| 1888 | |7: // Non-standard return case. | 1896 | |7: // Non-standard return case. |
| 1889 | | mov BASE, RA | 1897 | | mov BASE, RA |
| 1890 | | mov RA, -8 // Results start at BASE+RA = BASE-8. | 1898 | | mov RAa, -8 // Results start at BASE+RA = BASE-8. |
| 1891 | | jmp ->vm_return | 1899 | | jmp ->vm_return |
| 1892 | | | 1900 | | |
| 1893 | if (sse) { | 1901 | if (sse) { |
| @@ -3906,8 +3914,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 3906 | | ins_AD // RA = dst, RD = hbits|asize | 3914 | | ins_AD // RA = dst, RD = hbits|asize |
| 3907 | |.if X64 | 3915 | |.if X64 |
| 3908 | | mov L:CARG1d, SAVE_L | 3916 | | mov L:CARG1d, SAVE_L |
| 3909 | |1: | ||
| 3910 | | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | 3917 | | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. |
| 3918 | |1: | ||
| 3911 | | mov CARG3d, RD | 3919 | | mov CARG3d, RD |
| 3912 | | and RD, 0x7ff | 3920 | | and RD, 0x7ff |
| 3913 | | shr CARG3d, 11 | 3921 | | shr CARG3d, 11 |
| @@ -3982,7 +3990,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 3982 | | mov L:FCARG1, L:RB | 3990 | | mov L:FCARG1, L:RB |
| 3983 | | call extern lj_gc_step_fixtop@4 // (lua_State *L) | 3991 | | call extern lj_gc_step_fixtop@4 // (lua_State *L) |
| 3984 | | movzx RD, PC_RD // Need to reload RD. | 3992 | | movzx RD, PC_RD // Need to reload RD. |
| 3985 | | not RD | 3993 | | not RDa |
| 3986 | | jmp <2 | 3994 | | jmp <2 |
| 3987 | break; | 3995 | break; |
| 3988 | 3996 | ||
| @@ -4052,7 +4060,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 4052 | break; | 4060 | break; |
| 4053 | case BC_TGETS: | 4061 | case BC_TGETS: |
| 4054 | | ins_ABC // RA = dst, RB = table, RC = str const (~) | 4062 | | ins_ABC // RA = dst, RB = table, RC = str const (~) |
| 4055 | | not RC | 4063 | | not RCa |
| 4056 | | mov STR:RC, [KBASE+RC*4] | 4064 | | mov STR:RC, [KBASE+RC*4] |
| 4057 | | checktab RB, ->vmeta_tgets | 4065 | | checktab RB, ->vmeta_tgets |
| 4058 | | mov TAB:RB, [BASE+RB*8] | 4066 | | mov TAB:RB, [BASE+RB*8] |
| @@ -4182,7 +4190,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 4182 | break; | 4190 | break; |
| 4183 | case BC_TSETS: | 4191 | case BC_TSETS: |
| 4184 | | ins_ABC // RA = src, RB = table, RC = str const (~) | 4192 | | ins_ABC // RA = src, RB = table, RC = str const (~) |
| 4185 | | not RC | 4193 | | not RCa |
| 4186 | | mov STR:RC, [KBASE+RC*4] | 4194 | | mov STR:RC, [KBASE+RC*4] |
| 4187 | | checktab RB, ->vmeta_tsets | 4195 | | checktab RB, ->vmeta_tsets |
| 4188 | | mov TAB:RB, [BASE+RB*8] | 4196 | | mov TAB:RB, [BASE+RB*8] |
| @@ -4427,7 +4435,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 4427 | | test PC, FRAME_TYPE // Lua frame below? | 4435 | | test PC, FRAME_TYPE // Lua frame below? |
| 4428 | | jnz <4 | 4436 | | jnz <4 |
| 4429 | | movzx RD, PC_RA // Need to prepare BASE/KBASE. | 4437 | | movzx RD, PC_RA // Need to prepare BASE/KBASE. |
| 4430 | | not RD | 4438 | | not RDa |
| 4431 | | lea BASE, [BASE+RD*8] | 4439 | | lea BASE, [BASE+RD*8] |
| 4432 | | mov LFUNC:KBASE, [BASE-8] | 4440 | | mov LFUNC:KBASE, [BASE-8] |
| 4433 | | mov PROTO:KBASE, LFUNC:KBASE->pt | 4441 | | mov PROTO:KBASE, LFUNC:KBASE->pt |
| @@ -4591,7 +4599,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 4591 | break; | 4599 | break; |
| 4592 | } | 4600 | } |
| 4593 | | movzx RA, PC_RA | 4601 | | movzx RA, PC_RA |
| 4594 | | not RA // Note: ~RA = -(RA+1) | 4602 | | not RAa // Note: ~RA = -(RA+1) |
| 4595 | | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 | 4603 | | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 |
| 4596 | | mov LFUNC:KBASE, [BASE-8] | 4604 | | mov LFUNC:KBASE, [BASE-8] |
| 4597 | | mov PROTO:KBASE, LFUNC:KBASE->pt | 4605 | | mov PROTO:KBASE, LFUNC:KBASE->pt |
diff --git a/src/lib_jit.c b/src/lib_jit.c index 0352fbe5..dceb9e5c 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
| @@ -224,14 +224,14 @@ LJLIB_CF(jit_util_funcbc) | |||
| 224 | LJLIB_CF(jit_util_funck) | 224 | LJLIB_CF(jit_util_funck) |
| 225 | { | 225 | { |
| 226 | GCproto *pt = check_Lproto(L, 0); | 226 | GCproto *pt = check_Lproto(L, 0); |
| 227 | MSize idx = (MSize)lj_lib_checkint(L, 2); | 227 | ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); |
| 228 | if ((int32_t)idx >= 0) { | 228 | if (idx >= 0) { |
| 229 | if (idx < pt->sizekn) { | 229 | if (idx < (ptrdiff_t)pt->sizekn) { |
| 230 | setnumV(L->top-1, pt->k.n[idx]); | 230 | setnumV(L->top-1, pt->k.n[idx]); |
| 231 | return 1; | 231 | return 1; |
| 232 | } | 232 | } |
| 233 | } else { | 233 | } else { |
| 234 | if (~idx < pt->sizekgc) { | 234 | if (~idx < (ptrdiff_t)pt->sizekgc) { |
| 235 | GCobj *gc = gcref(pt->k.gc[idx]); | 235 | GCobj *gc = gcref(pt->k.gc[idx]); |
| 236 | setgcV(L, L->top-1, &gc->gch, ~gc->gch.gct); | 236 | setgcV(L, L->top-1, &gc->gch, ~gc->gch.gct); |
| 237 | return 1; | 237 | return 1; |
diff --git a/src/lj_err.c b/src/lj_err.c index 20be9e9a..02a7c4cc 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
| @@ -107,10 +107,10 @@ restart: | |||
| 107 | if (ra == slot) { slot = bc_d(ins); goto restart; } | 107 | if (ra == slot) { slot = bc_d(ins); goto restart; } |
| 108 | break; | 108 | break; |
| 109 | case BC_GGET: | 109 | case BC_GGET: |
| 110 | *name = strdata(gco2str(gcref(pt->k.gc[~bc_d(ins)]))); | 110 | *name = strdata(gco2str(gcref(pt->k.gc[~(ptrdiff_t)bc_d(ins)]))); |
| 111 | return "global"; | 111 | return "global"; |
| 112 | case BC_TGETS: | 112 | case BC_TGETS: |
| 113 | *name = strdata(gco2str(gcref(pt->k.gc[~bc_c(ins)]))); | 113 | *name = strdata(gco2str(gcref(pt->k.gc[~(ptrdiff_t)bc_c(ins)]))); |
| 114 | if (ip > pt->bc) { | 114 | if (ip > pt->bc) { |
| 115 | BCIns insp = ip[-1]; | 115 | BCIns insp = ip[-1]; |
| 116 | if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 && | 116 | if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 && |
diff --git a/src/lj_func.c b/src/lj_func.c index af4f424e..61a810f2 100644 --- a/src/lj_func.c +++ b/src/lj_func.c | |||
| @@ -169,7 +169,7 @@ GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent) | |||
| 169 | nuv = fn->l.nupvalues; | 169 | nuv = fn->l.nupvalues; |
| 170 | base = L->base; | 170 | base = L->base; |
| 171 | for (i = 0; i < nuv; i++) { | 171 | for (i = 0; i < nuv; i++) { |
| 172 | int v = pt->uv[i]; | 172 | ptrdiff_t v = pt->uv[i]; |
| 173 | GCupval *uv = v < 0 ? &gcref(puv[~v])->uv : func_finduv(L, base + v); | 173 | GCupval *uv = v < 0 ? &gcref(puv[~v])->uv : func_finduv(L, base + v); |
| 174 | setgcref(fn->l.uvptr[i], obj2gco(uv)); | 174 | setgcref(fn->l.uvptr[i], obj2gco(uv)); |
| 175 | } | 175 | } |
diff --git a/src/lj_meta.c b/src/lj_meta.c index da661d54..dd965cde 100644 --- a/src/lj_meta.c +++ b/src/lj_meta.c | |||
| @@ -295,7 +295,7 @@ TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne) | |||
| 295 | top = curr_top(L); | 295 | top = curr_top(L); |
| 296 | setcont(top, ne ? lj_cont_condf : lj_cont_condt); | 296 | setcont(top, ne ? lj_cont_condf : lj_cont_condt); |
| 297 | copyTV(L, top+1, mo); | 297 | copyTV(L, top+1, mo); |
| 298 | it = ~o1->gch.gct; | 298 | it = ~(int32_t)o1->gch.gct; |
| 299 | setgcV(L, top+2, &o1->gch, it); | 299 | setgcV(L, top+2, &o1->gch, it); |
| 300 | setgcV(L, top+3, &o2->gch, it); | 300 | setgcV(L, top+3, &o2->gch, it); |
| 301 | return top+2; /* Trigger metamethod call. */ | 301 | return top+2; /* Trigger metamethod call. */ |
diff --git a/src/lj_record.c b/src/lj_record.c index 9466b529..6206bfcd 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
| @@ -1751,7 +1751,7 @@ void lj_record_ins(jit_State *J) | |||
| 1751 | case BCMpri: setitype(rcv, (int32_t)~rc); rc = TREF_PRI(IRT_NIL+rc); break; | 1751 | case BCMpri: setitype(rcv, (int32_t)~rc); rc = TREF_PRI(IRT_NIL+rc); break; |
| 1752 | case BCMnum: { lua_Number n = J->pt->k.n[rc]; | 1752 | case BCMnum: { lua_Number n = J->pt->k.n[rc]; |
| 1753 | setnumV(rcv, n); ix.key = rc = lj_ir_knumint(J, n); } break; | 1753 | setnumV(rcv, n); ix.key = rc = lj_ir_knumint(J, n); } break; |
| 1754 | case BCMstr: { GCstr *s = strref(J->pt->k.gc[~rc]); | 1754 | case BCMstr: { GCstr *s = strref(J->pt->k.gc[~(ptrdiff_t)rc]); |
| 1755 | setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; | 1755 | setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; |
| 1756 | default: break; /* Handled later. */ | 1756 | default: break; /* Handled later. */ |
| 1757 | } | 1757 | } |
| @@ -1943,7 +1943,7 @@ void lj_record_ins(jit_State *J) | |||
| 1943 | break; | 1943 | break; |
| 1944 | case BC_TDUP: | 1944 | case BC_TDUP: |
| 1945 | rc = emitir(IRT(IR_TDUP, IRT_TAB), | 1945 | rc = emitir(IRT(IR_TDUP, IRT_TAB), |
| 1946 | lj_ir_ktab(J, tabref(J->pt->k.gc[~rc])), 0); | 1946 | lj_ir_ktab(J, tabref(J->pt->k.gc[~(ptrdiff_t)rc])), 0); |
| 1947 | break; | 1947 | break; |
| 1948 | 1948 | ||
| 1949 | /* -- Calls and vararg handling ----------------------------------------- */ | 1949 | /* -- Calls and vararg handling ----------------------------------------- */ |
