lua-hooks/ext/luajit/src/vm_x64.dasc in immunio-1.2.1 vs lua-hooks/ext/luajit/src/vm_x64.dasc in immunio-2.0.2

- old
+ new

@@ -1,8 +1,8 @@ |// Low-level VM code for x64 CPUs in LJ_GC64 mode. |// Bytecode interpreter, fast functions and helper functions. -|// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h +|// Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h | |.arch x64 |.section code_op, code_sub | |.actionlist build_actionlist @@ -248,15 +248,15 @@ |//----------------------------------------------------------------------- | |// Macros to clear or set tags. |.macro cleartp, reg; shl reg, 17; shr reg, 17; .endmacro |.macro settp, reg, tp -| mov64 ITYPE, ((int64_t)tp<<47) +| mov64 ITYPE, ((uint64_t)tp<<47) | or reg, ITYPE |.endmacro |.macro settp, dst, reg, tp -| mov64 dst, ((int64_t)tp<<47) +| mov64 dst, ((uint64_t)tp<<47) | or dst, reg |.endmacro |.macro setint, reg | settp reg, LJ_TISNUM |.endmacro @@ -1103,15 +1103,15 @@ | mov RA, RB | mov L:RB, SAVE_L | mov BASE, L:RB->base | mov NARGS:RDd, TMP1d | mov LFUNC:RB, [RA-16] - | cleartp LFUNC:RB | add NARGS:RDd, 1 | // This is fragile. L->base must not move, KBASE must always be defined. | cmp KBASE, BASE // Continue with CALLT if flag set. | je ->BC_CALLT_Z + | cleartp LFUNC:RB | mov BASE, RA | ins_call // Otherwise call resolved metamethod. | |//-- Argument coercion for 'for' statement ------------------------------ | @@ -1467,11 +1467,11 @@ | settp CFUNC:RD, LJ_TFUNC | mov PC, [BASE-8] | mov [BASE-16], CFUNC:RD | mov [BASE-8], TMPR |.if DUALNUM - | mov64 RD, ((int64_t)LJ_TISNUM<<47) + | mov64 RD, ((uint64_t)LJ_TISNUM<<47) | mov [BASE], RD |.else | mov qword [BASE], 0 |.endif | mov RDd, 1+3 @@ -1802,16 +1802,16 @@ | mov PC, [BASE-8] | fstp qword [BASE-16] | jmp ->fff_res1 | |.ffunc_n math_frexp + | mov RB, BASE |.if X64WIN - | lea CARG2, TMP1 + | lea CARG2, TMP1 // Caveat: CARG2 == BASE |.else | lea CARG1, TMP1 |.endif - | mov RB, BASE | call extern frexp | mov BASE, RB | mov RBd, TMP1d | mov PC, [BASE-8] | movsd qword [BASE-16], xmm0 @@ -1824,17 +1824,16 @@ |.endif | mov RDd, 1+2 | jmp ->fff_res | |.ffunc_n math_modf + | mov RB, BASE |.if X64WIN - | lea CARG2, [BASE-16] + | lea CARG2, [BASE-16] // Caveat: CARG2 == BASE |.else | lea CARG1, [BASE-16] |.endif - | mov PC, [BASE-8] - | mov RB, BASE | call extern modf | mov BASE, RB | mov PC, [BASE-8] | movsd qword [BASE-8], xmm0 | mov RDd, 1+2 @@ -2323,11 +2322,12 @@ | jmp RB | |->cont_stitch: // Trace stitching. |.if JIT | // BASE = base, RC = result, RB = mbase - | mov ITYPEd, [RB-24] // Save previous trace number. + | mov TRACE:ITYPE, [RB-40] // Save previous trace. + | cleartp TRACE:ITYPE | mov TMPRd, MULTRES | movzx RAd, PC_RA | lea RA, [BASE+RA*8] // Call base. | sub TMPRd, 1 | jz >2 @@ -2345,15 +2345,14 @@ | lea RC, [BASE+RC*8-8] |3: | cmp RC, RA | ja >9 // More results wanted? | - | mov RA, [DISPATCH+DISPATCH_J(trace)] - | mov TRACE:RD, [RA+ITYPE*8] - | test TRACE:RD, TRACE:RD + | test TRACE:ITYPE, TRACE:ITYPE | jz ->cont_nop - | movzx RDd, word TRACE:RD->link + | movzx RBd, word TRACE:ITYPE->traceno + | movzx RDd, word TRACE:ITYPE->link | cmp RDd, RBd | je ->cont_nop // Blacklisted. | test RDd, RDd | jne =>BC_JLOOP // Jump to stitched trace. | @@ -2400,16 +2399,15 @@ | push rdi; push rsi; push rbp; lea rbp, [rsp+88]; push rbp | push rbx; push rdx; push rcx; push rax | movzx RCd, byte [rbp-8] // Reconstruct exit number. | mov RCH, byte [rbp-16] | mov [rbp-8], r15; mov [rbp-16], r14 - | // Caveat: DISPATCH is rbx. - | mov DISPATCH, [ebp] - | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. + | // DISPATCH is preserved on-trace in LJ_GC64 mode. + | mov RAd, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. | set_vmstate EXIT - | mov [DISPATCH+DISPATCH_J(exitno)], RC - | mov [DISPATCH+DISPATCH_J(parent)], RA + | mov [DISPATCH+DISPATCH_J(exitno)], RCd + | mov [DISPATCH+DISPATCH_J(parent)], RAd |.if X64WIN | sub rsp, 16*8+4*8 // Room for SSE regs + save area. |.else | sub rsp, 16*8 // Room for SSE regs. |.endif @@ -2431,11 +2429,11 @@ | lea CARG2, [rsp+4*8] |.else | mov CARG2, rsp |.endif | lea CARG1, [DISPATCH+GG_DISP2J] - | mov dword [DISPATCH+DISPATCH_GL(jit_base)], 0 + | mov qword [DISPATCH+DISPATCH_GL(jit_base)], 0 | call extern lj_trace_exit // (jit_State *J, ExitState *ex) | // MULTRES or negated error code returned in eax (RD). | mov RA, L:RB->cframe | and RA, CFRAME_RAWMASK | mov [RA+CFRAME_OFS_L], L:RB // Set SAVE_L (on-trace resume/yield). @@ -2478,11 +2476,11 @@ | mov LFUNC:KBASE, [BASE-16] | cleartp LFUNC:KBASE | mov KBASE, LFUNC:KBASE->pc | mov KBASE, [KBASE+PC2PROTO(k)] | mov L:RB->base, BASE - | mov dword [DISPATCH+DISPATCH_GL(jit_base)], 0 + | mov qword [DISPATCH+DISPATCH_GL(jit_base)], 0 | set_vmstate INTERP | // Modified copy of ins_next which handles function header dispatch, too. | mov RCd, [PC] | movzx RAd, RCH | movzx OP, RCL @@ -2502,11 +2500,11 @@ | test RCd, FRAME_TYPE | jnz <2 // Trace stitching continuation? | // Otherwise set KBASE for Lua function below fast function. | movzx RCd, byte [RC-3] | neg RC - | mov LFUNC:KBASE, [BASE+RC*8-24] + | mov LFUNC:KBASE, [BASE+RC*8-32] | cleartp LFUNC:KBASE | mov KBASE, LFUNC:KBASE->pc | mov KBASE, [KBASE+PC2PROTO(k)] | jmp <2 | @@ -2637,10 +2635,11 @@ |// int lj_vm_cpuid(uint32_t f, uint32_t res[4]) |->vm_cpuid: | mov eax, CARG1d | .if X64WIN; push rsi; mov rsi, CARG2; .endif | push rbx + | xor ecx, ecx | cpuid | mov [rsi], eax | mov [rsi+4], ebx | mov [rsi+8], ecx | mov [rsi+12], edx @@ -3514,11 +3513,11 @@ break; case BC_UCLO: | ins_AD // RA = level, RD = target | branchPC RD // Do this first to free RD. | mov L:RB, SAVE_L - | cmp dword L:RB->openupval, 0 + | cmp aword L:RB->openupval, 0 | je >1 | mov L:RB->base, BASE | lea CARG2, [BASE+RA*8] // Caveat: CARG2 == BASE | mov L:CARG1, L:RB // Caveat: CARG1 == RA | call extern lj_func_closeuv // (lua_State *L, TValue *level) @@ -4048,10 +4047,10 @@ | lea RA, [BASE+RA*8+16] // fb = base+2 | mov RB, [RA-32] // Copy state. fb[0] = fb[-4]. | mov RC, [RA-24] // Copy control var. fb[1] = fb[-3]. | mov [RA], RB | mov [RA+8], RC - | mov LFUNC:RB, [RA-40] // Copy callable. fb[-1] = fb[-5] + | mov LFUNC:RB, [RA-40] // Copy callable. fb[-2] = fb[-5] | mov [RA-16], LFUNC:RB | mov NARGS:RDd, 2+1 // Handle like a regular 2-arg call. | checkfunc LFUNC:RB, ->vmeta_call | mov BASE, RA | ins_call