diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index cedaffb920..341ce7c96b 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -8,6 +8,7 @@ #include #include +#include class AsmJitException : public std::exception { @@ -221,6 +222,29 @@ static bool CanJit(VMScriptFunction *sfunc) return true; } +template +void emitComparisonOpcode(asmjit::X86Compiler& cc, const TArray& labels, const VMOP* pc, int i, Func compFunc) { + using namespace asmjit; + + Label elseLabel = cc.newLabel(); + + auto tmp0 = cc.newInt32(); + auto tmp1 = cc.newInt32(); + + compFunc(tmp0); + + cc.mov(tmp1, A); + cc.and_(tmp1, CMP_CHECK); + + cc.cmp(tmp0, tmp1); + cc.jne(elseLabel); + + cc.jmp(labels[i + 2 + JMPOFS(pc + 1)]); + + cc.bind(elseLabel); + cc.jmp(labels[i + 2]); +} + JitFuncPtr JitCompile(VMScriptFunction *sfunc) { #if 0 // For debugging @@ -309,6 +333,11 @@ JitFuncPtr JitCompile(VMScriptFunction *sfunc) */ int size = sfunc->CodeSize; + + TArray