From b83f4f48d6ae5ed3c976d873994ec2482cbc9878 Mon Sep 17 00:00:00 2001 From: Jonathan Russell Date: Sat, 15 Sep 2018 00:25:13 +0100 Subject: [PATCH 1/2] - implemented SS_R, LCS_R, and LKS_R --- src/scripting/vm/jit.cpp | 3 --- src/scripting/vm/jit_load.cpp | 31 +++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index 032ff68d38..8836cf8fc2 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -150,10 +150,7 @@ bool JitCompiler::CanJit(VMScriptFunction *sfunc) { default: break; - case OP_LKS_R: case OP_LFP: - case OP_LCS_R: - case OP_SS_R: case OP_IJMP: case OP_TAIL: case OP_TAIL_K: diff --git a/src/scripting/vm/jit_load.cpp b/src/scripting/vm/jit_load.cpp index df91cf492f..15a274f745 100644 --- a/src/scripting/vm/jit_load.cpp +++ b/src/scripting/vm/jit_load.cpp @@ -48,7 +48,22 @@ void JitCompiler::EmitLKF_R() void JitCompiler::EmitLKS_R() { - I_FatalError("EmitLKS_R not implemented\n"); + auto ptr = cc.newIntPtr(); + cc.mov(ptr, ToMemAddress(konsts)); + auto offset = cc.newIntPtr(); + cc.mov(offset, regD[B]); +#ifdef ASMJIT_ARCH_X64 + static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 8"); + cc.shl(offset, 3); +#else + static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 4"); + cc.shl(offset, 2); +#endif + cc.add(ptr, offset); + auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(CallAssignString))), + asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); + call->setArg(0, regS[A]); + call->setArg(1, ptr); } void JitCompiler::EmitLKP_R() @@ -315,7 +330,19 @@ void JitCompiler::EmitLCS() void JitCompiler::EmitLCS_R() { - I_FatalError("EmitLCS_R not implemented\n"); + EmitNullPointerThrow(B, X_READ_NIL); + auto ptr = cc.newIntPtr(); + cc.mov(ptr, regA[B]); + auto tmp = cc.newIntPtr(); + cc.mov(tmp, regD[C]); + cc.add(ptr, tmp); + auto loadLambda = [](FString* to, char** from) -> void { + *to = *from; + }; + auto call = cc.call(ToMemAddress(reinterpret_cast(static_cast(loadLambda))), + asmjit::FuncSignature2(asmjit::CallConv::kIdHostCDecl)); + call->setArg(0, regS[A]); + call->setArg(1, ptr); } void JitCompiler::EmitLBIT() From 407418a92ec180ed9bd41a274aea5161c7dbe5da Mon Sep 17 00:00:00 2001 From: Jonathan Russell Date: Sat, 15 Sep 2018 00:26:14 +0100 Subject: [PATCH 2/2] - fixed typo in last commit --- src/scripting/vm/jit_load.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/vm/jit_load.cpp b/src/scripting/vm/jit_load.cpp index 15a274f745..59885019ad 100644 --- a/src/scripting/vm/jit_load.cpp +++ b/src/scripting/vm/jit_load.cpp @@ -56,7 +56,7 @@ void JitCompiler::EmitLKS_R() static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 8"); cc.shl(offset, 3); #else - static_assert(sizeof(FString) == 8, "sizeof(FString) needs to be 4"); + static_assert(sizeof(FString) == 4, "sizeof(FString) needs to be 4"); cc.shl(offset, 2); #endif cc.add(ptr, offset);