mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- fix missing line number for the function throwing the exception and remove the duplicate call stack line
This commit is contained in:
parent
8c52f20373
commit
b0d8a813f9
3 changed files with 39 additions and 24 deletions
|
@ -156,6 +156,8 @@ asmjit::CCFunc *JitCompiler::Codegen()
|
|||
LineInfo[j] = info;
|
||||
}
|
||||
|
||||
std::stable_sort(LineInfo.begin(), LineInfo.end(), [](const JitLineInfo &a, const JitLineInfo &b) { return a.InstructionIndex < b.InstructionIndex; });
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
|
@ -444,17 +446,15 @@ void JitCompiler::EmitNullPointerThrow(int index, EVMAbortException reason)
|
|||
cc.je(label);
|
||||
}
|
||||
|
||||
void JitCompiler::ThrowException(VMScriptFunction *func, VMOP *line, int reason)
|
||||
void JitCompiler::ThrowException(int reason)
|
||||
{
|
||||
ThrowAbortException(func, line, (EVMAbortException)reason, nullptr);
|
||||
ThrowAbortException((EVMAbortException)reason, nullptr);
|
||||
}
|
||||
|
||||
void JitCompiler::EmitThrowException(EVMAbortException reason)
|
||||
{
|
||||
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int>(&JitCompiler::ThrowException);
|
||||
call->setArg(0, asmjit::imm_ptr(sfunc));
|
||||
call->setArg(1, asmjit::imm_ptr(pc));
|
||||
call->setArg(2, asmjit::imm(reason));
|
||||
auto call = CreateCall<void, int>(&JitCompiler::ThrowException);
|
||||
call->setArg(0, asmjit::imm(reason));
|
||||
}
|
||||
|
||||
asmjit::Label JitCompiler::EmitThrowExceptionLabel(EVMAbortException reason)
|
||||
|
@ -464,6 +464,12 @@ asmjit::Label JitCompiler::EmitThrowExceptionLabel(EVMAbortException reason)
|
|||
cc.bind(label);
|
||||
EmitThrowException(reason);
|
||||
cc.setCursor(cursor);
|
||||
|
||||
JitLineInfo info;
|
||||
info.Label = label;
|
||||
info.LineNumber = sfunc->PCToLine(pc);
|
||||
LineInfo.Push(info);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
|
|
@ -330,15 +330,18 @@ void JitCompiler::EmitBOUND()
|
|||
auto cursor = cc.getCursor();
|
||||
auto label = cc.newLabel();
|
||||
cc.bind(label);
|
||||
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
||||
call->setArg(0, asmjit::imm_ptr(sfunc));
|
||||
call->setArg(1, asmjit::imm_ptr(pc));
|
||||
call->setArg(2, regD[A]);
|
||||
call->setArg(3, asmjit::imm(BC));
|
||||
auto call = CreateCall<void, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
||||
call->setArg(0, regD[A]);
|
||||
call->setArg(1, asmjit::imm(BC));
|
||||
cc.setCursor(cursor);
|
||||
|
||||
cc.cmp(regD[A], (int)BC);
|
||||
cc.jae(label);
|
||||
|
||||
JitLineInfo info;
|
||||
info.Label = label;
|
||||
info.LineNumber = sfunc->PCToLine(pc);
|
||||
LineInfo.Push(info);
|
||||
}
|
||||
|
||||
void JitCompiler::EmitBOUND_K()
|
||||
|
@ -346,15 +349,18 @@ void JitCompiler::EmitBOUND_K()
|
|||
auto cursor = cc.getCursor();
|
||||
auto label = cc.newLabel();
|
||||
cc.bind(label);
|
||||
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
||||
call->setArg(0, asmjit::imm_ptr(sfunc));
|
||||
call->setArg(1, asmjit::imm_ptr(pc));
|
||||
call->setArg(2, regD[A]);
|
||||
call->setArg(3, asmjit::imm(konstd[BC]));
|
||||
auto call = CreateCall<void, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
||||
call->setArg(0, regD[A]);
|
||||
call->setArg(1, asmjit::imm(konstd[BC]));
|
||||
cc.setCursor(cursor);
|
||||
|
||||
cc.cmp(regD[A], (int)konstd[BC]);
|
||||
cc.jae(label);
|
||||
|
||||
JitLineInfo info;
|
||||
info.Label = label;
|
||||
info.LineNumber = sfunc->PCToLine(pc);
|
||||
LineInfo.Push(info);
|
||||
}
|
||||
|
||||
void JitCompiler::EmitBOUND_R()
|
||||
|
@ -362,18 +368,21 @@ void JitCompiler::EmitBOUND_R()
|
|||
auto cursor = cc.getCursor();
|
||||
auto label = cc.newLabel();
|
||||
cc.bind(label);
|
||||
auto call = CreateCall<void, VMScriptFunction *, VMOP *, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
||||
call->setArg(0, asmjit::imm_ptr(sfunc));
|
||||
call->setArg(1, asmjit::imm_ptr(pc));
|
||||
call->setArg(2, regD[A]);
|
||||
call->setArg(3, regD[B]);
|
||||
auto call = CreateCall<void, int, int>(&JitCompiler::ThrowArrayOutOfBounds);
|
||||
call->setArg(0, regD[A]);
|
||||
call->setArg(1, regD[B]);
|
||||
cc.setCursor(cursor);
|
||||
|
||||
cc.cmp(regD[A], regD[B]);
|
||||
cc.jae(label);
|
||||
|
||||
JitLineInfo info;
|
||||
info.Label = label;
|
||||
info.LineNumber = sfunc->PCToLine(pc);
|
||||
LineInfo.Push(info);
|
||||
}
|
||||
|
||||
void JitCompiler::ThrowArrayOutOfBounds(VMScriptFunction *func, VMOP *line, int index, int size)
|
||||
void JitCompiler::ThrowArrayOutOfBounds(int index, int size)
|
||||
{
|
||||
if (index >= size)
|
||||
{
|
||||
|
|
|
@ -219,8 +219,8 @@ private:
|
|||
void EmitThrowException(EVMAbortException reason);
|
||||
asmjit::Label EmitThrowExceptionLabel(EVMAbortException reason);
|
||||
|
||||
static void ThrowArrayOutOfBounds(VMScriptFunction *func, VMOP *line, int index, int size);
|
||||
static void ThrowException(VMScriptFunction *func, VMOP *line, int reason);
|
||||
static void ThrowArrayOutOfBounds(int index, int size);
|
||||
static void ThrowException(int reason);
|
||||
|
||||
asmjit::X86Gp CheckRegD(int r0, int r1);
|
||||
asmjit::X86Xmm CheckRegF(int r0, int r1);
|
||||
|
|
Loading…
Reference in a new issue