From 097de74510a3509316f6b6514f73235d4e34c29f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Sep 2018 03:39:54 +0200 Subject: [PATCH] - implement OP_LFP --- src/scripting/vm/jit.cpp | 19 ++++++++++--------- src/scripting/vm/jit_load.cpp | 2 +- src/scripting/vm/jitintern.h | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index 1b67a326e..a419e5bb7 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -150,7 +150,6 @@ bool JitCompiler::CanJit(VMScriptFunction *sfunc) { default: break; - case OP_LFP: case OP_IJMP: case OP_TAIL: case OP_TAIL_K: @@ -237,15 +236,17 @@ void JitCompiler::Setup() int offsetS = offsetF + (int)(sfunc->NumRegF * sizeof(double)); int offsetA = offsetS + (int)(sfunc->NumRegS * sizeof(FString)); int offsetD = offsetA + (int)(sfunc->NumRegA * sizeof(void*)); + offsetExtra = (offsetD + (int)(sfunc->NumRegD * sizeof(int32_t)) + 15) & ~15; - auto vmregs = cc.newIntPtr(); - cc.mov(vmregs, x86::ptr(stack)); // stack->Blocks - cc.mov(vmregs, x86::ptr(vmregs, VMFrameStack::OffsetLastFrame())); // Blocks->LastFrame - cc.lea(params, x86::ptr(vmregs, offsetParams)); - cc.lea(frameF, x86::ptr(vmregs, offsetF)); - cc.lea(frameS, x86::ptr(vmregs, offsetS)); - cc.lea(frameA, x86::ptr(vmregs, offsetA)); - cc.lea(frameD, x86::ptr(vmregs, offsetD)); + vmframe = cc.newIntPtr(); + cc.mov(vmframe, x86::ptr(stack)); // stack->Blocks + cc.mov(vmframe, x86::ptr(vmframe, VMFrameStack::OffsetLastFrame())); // Blocks->LastFrame + + cc.lea(params, x86::ptr(vmframe, offsetParams)); + cc.lea(frameF, x86::ptr(vmframe, offsetF)); + cc.lea(frameS, x86::ptr(vmframe, offsetS)); + cc.lea(frameA, x86::ptr(vmframe, offsetA)); + cc.lea(frameD, x86::ptr(vmframe, offsetD)); for (int i = 0; i < sfunc->NumRegD; i++) { diff --git a/src/scripting/vm/jit_load.cpp b/src/scripting/vm/jit_load.cpp index 44fff4d1c..3bf07393f 100644 --- a/src/scripting/vm/jit_load.cpp +++ b/src/scripting/vm/jit_load.cpp @@ -81,7 +81,7 @@ void JitCompiler::EmitLKP_R() void JitCompiler::EmitLFP() { - I_FatalError("EmitLFP not implemented\n"); + cc.lea(regA[A], asmjit::x86::ptr(vmframe, offsetExtra)); } void JitCompiler::EmitMETA() diff --git a/src/scripting/vm/jitintern.h b/src/scripting/vm/jitintern.h index a59240cdc..2d24e33ce 100644 --- a/src/scripting/vm/jitintern.h +++ b/src/scripting/vm/jitintern.h @@ -95,6 +95,8 @@ private: asmjit::X86Gp numret; asmjit::X86Gp exceptInfo; + int offsetExtra; + asmjit::X86Gp vmframe; asmjit::X86Gp frameD; asmjit::X86Gp frameF; asmjit::X86Gp frameS;