From 4364feea9a11c234dc1b2e7ec8f542120ae04548 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 15 Sep 2018 15:38:16 +0200 Subject: [PATCH] - fix truncated load addresses due to a bug in asmjit - change ToMemAddress to use uint64_t --- src/scripting/vm/jit_load.cpp | 20 ++++++++++++-------- src/scripting/vm/jitintern.h | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/scripting/vm/jit_load.cpp b/src/scripting/vm/jit_load.cpp index 5fdbdbaf1..1f7589271 100644 --- a/src/scripting/vm/jit_load.cpp +++ b/src/scripting/vm/jit_load.cpp @@ -16,9 +16,9 @@ void JitCompiler::EmitLK() void JitCompiler::EmitLKF() { - auto tmp = cc.newIntPtr(); - cc.mov(tmp, ToMemAddress(konstf + BC)); - cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp)); + auto base = cc.newIntPtr(); + cc.mov(base, ToMemAddress(konstf + BC)); + cc.movsd(regF[A], asmjit::x86::qword_ptr(base)); } void JitCompiler::EmitLKS() @@ -36,14 +36,16 @@ void JitCompiler::EmitLKP() void JitCompiler::EmitLK_R() { - cc.mov(regD[A], asmjit::x86::ptr(ToMemAddress(konstd + C), regD[B], 2)); + auto base = cc.newIntPtr(); + cc.mov(base, ToMemAddress(konstd + C)); + cc.mov(regD[A], asmjit::x86::ptr(base, regD[B], 2)); } void JitCompiler::EmitLKF_R() { - auto tmp = cc.newIntPtr(); - cc.mov(tmp, ToMemAddress(konstf + C)); - cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp, regD[B], 3)); + auto base = cc.newIntPtr(); + cc.mov(base, ToMemAddress(konstf + C)); + cc.movsd(regF[A], asmjit::x86::qword_ptr(base, regD[B], 3)); } void JitCompiler::EmitLKS_R() @@ -68,7 +70,9 @@ void JitCompiler::EmitLKS_R() void JitCompiler::EmitLKP_R() { - cc.mov(regA[A], asmjit::x86::ptr(ToMemAddress(konsta + C), regD[B], 2)); + auto base = cc.newIntPtr(); + cc.mov(base, ToMemAddress(konsta + C)); + cc.mov(regA[A], asmjit::x86::ptr(base, regD[B], 2)); } void JitCompiler::EmitLFP() diff --git a/src/scripting/vm/jitintern.h b/src/scripting/vm/jitintern.h index be8abec7f..e19b5c6c2 100644 --- a/src/scripting/vm/jitintern.h +++ b/src/scripting/vm/jitintern.h @@ -65,9 +65,9 @@ private: pc++; // This instruction uses two instruction slots - skip the next one } - static int64_t ToMemAddress(const void *d) + static uint64_t ToMemAddress(const void *d) { - return (int64_t)(ptrdiff_t)d; + return (uint64_t)(ptrdiff_t)d; } void CallSqrt(const asmjit::X86Xmm &a, const asmjit::X86Xmm &b);