mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +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()
|
void JitCompiler::EmitIJMP()
|
||||||
{
|
{
|
||||||
// This uses the whole function as potential jump targets. Can the range be reduced?
|
int base = (int)(ptrdiff_t)(pc - sfunc->Code) + 1;
|
||||||
|
|
||||||
int i = (int)(ptrdiff_t)(pc - sfunc->Code);
|
|
||||||
auto val = newTempInt32();
|
auto val = newTempInt32();
|
||||||
cc.mov(val, regD[A]);
|
cc.mov(val, regD[A]);
|
||||||
cc.add(val, i + (int)BCs + 1);
|
|
||||||
|
|
||||||
int size = sfunc->CodeSize;
|
for (int i = 0; i < (int)BCs; i++)
|
||||||
for (i = 0; i < size; 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.cmp(val, i);
|
||||||
cc.je(GetLabel(target));
|
cc.je(GetLabel(target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pc += BCs;
|
||||||
|
|
||||||
// This should never happen. It means we are jumping to something that is not a JMP instruction!
|
// This should never happen. It means we are jumping to something that is not a JMP instruction!
|
||||||
EmitThrowException(X_OTHER);
|
EmitThrowException(X_OTHER);
|
||||||
|
|
|
@ -554,7 +554,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
||||||
NEXTOP;
|
NEXTOP;
|
||||||
OP(IJMP):
|
OP(IJMP):
|
||||||
ASSERTD(a);
|
ASSERTD(a);
|
||||||
pc += (BCs + reg.d[a]);
|
pc += (reg.d[a]);
|
||||||
assert(pc[1].op == OP_JMP);
|
assert(pc[1].op == OP_JMP);
|
||||||
pc += 1 + JMPOFS(pc+1);
|
pc += 1 + JMPOFS(pc+1);
|
||||||
NEXTOP;
|
NEXTOP;
|
||||||
|
|
Loading…
Reference in a new issue