mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
- fixed IJMP code generation for the JIT compiler.
With a proper count value available this can be done properly. The only relevant targets are the jumps immediately succeeding the IJMP instructions, nothing else.
This commit is contained in:
parent
fcb5684607
commit
89cec539fa
2 changed files with 6 additions and 9 deletions
|
@ -25,24 +25,21 @@ void JitCompiler::EmitJMP()
|
|||
|
||||
void JitCompiler::EmitIJMP()
|
||||
{
|
||||
// This uses the whole function as potential jump targets. Can the range be reduced?
|
||||
|
||||
int i = (int)(ptrdiff_t)(pc - sfunc->Code);
|
||||
int base = (int)(ptrdiff_t)(pc - sfunc->Code) + 1;
|
||||
auto val = newTempInt32();
|
||||
cc.mov(val, regD[A]);
|
||||
cc.add(val, i + (int)BCs + 1);
|
||||
|
||||
int size = sfunc->CodeSize;
|
||||
for (i = 0; i < size; i++)
|
||||
for (int i = 0; i < (int)BCs; i++)
|
||||
{
|
||||
if (sfunc->Code[i].op == OP_JMP)
|
||||
if (sfunc->Code[base +i].op == OP_JMP)
|
||||
{
|
||||
int target = i + JMPOFS(&sfunc->Code[i]) + 1;
|
||||
int target = base + i + JMPOFS(&sfunc->Code[base + i]) + 1;
|
||||
|
||||
cc.cmp(val, i);
|
||||
cc.je(GetLabel(target));
|
||||
}
|
||||
}
|
||||
pc += BCs;
|
||||
|
||||
// This should never happen. It means we are jumping to something that is not a JMP instruction!
|
||||
EmitThrowException(X_OTHER);
|
||||
|
|
|
@ -554,7 +554,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
NEXTOP;
|
||||
OP(IJMP):
|
||||
ASSERTD(a);
|
||||
pc += (BCs + reg.d[a]);
|
||||
pc += (reg.d[a]);
|
||||
assert(pc[1].op == OP_JMP);
|
||||
pc += 1 + JMPOFS(pc+1);
|
||||
NEXTOP;
|
||||
|
|
Loading…
Reference in a new issue