diff --git a/src/scripting/vm/jit.cpp b/src/scripting/vm/jit.cpp index b5b8869e9a..e239e76c3a 100644 --- a/src/scripting/vm/jit.cpp +++ b/src/scripting/vm/jit.cpp @@ -144,11 +144,6 @@ bool JitCompiler::CanJit(VMScriptFunction *sfunc) int size = sfunc->CodeSize; for (int i = 0; i < size; i++) { - // Functions not implemented at all yet: - - if (sfunc->Code[i].op == OP_IJMP) - return false; - // Partially implemented functions: auto pc = sfunc->Code + i; diff --git a/src/scripting/vm/jit_flow.cpp b/src/scripting/vm/jit_flow.cpp index 8641c2da89..1db547d991 100644 --- a/src/scripting/vm/jit_flow.cpp +++ b/src/scripting/vm/jit_flow.cpp @@ -25,7 +25,27 @@ void JitCompiler::EmitJMP() void JitCompiler::EmitIJMP() { - I_FatalError("EmitIJMP not implemented\n"); + // This uses the whole function as potential jump targets. Can the range be reduced? + + int i = (int)(ptrdiff_t)(pc - sfunc->Code); + auto val = cc.newInt32(); + cc.mov(val, regD[A]); + cc.add(val, i + (int)BCs + 1); + + int size = sfunc->CodeSize; + for (i = 0; i < size; i++) + { + if (sfunc->Code[i].op == OP_JMP) + { + int target = i + JMPOFS(&sfunc->Code[i]) + 1; + + cc.cmp(val, i); + cc.je(labels[target]); + } + } + + // This should never happen. It means we are jumping to something that is not a JMP instruction! + EmitThrowException(X_OTHER); } void JitCompiler::EmitVTBL()