mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
- added null check for self pointer before calling a native function
With JIT enabled, an implicit test for null self pointer is added to generated code This has no effect without JIT as VM verifies a pointer before calling a native method https://forum.zdoom.org/viewtopic.php?t=64961
This commit is contained in:
parent
c222b24c0a
commit
d3e6ed3c9b
1 changed files with 22 additions and 0 deletions
|
@ -323,6 +323,28 @@ void JitCompiler::EmitNativeCall(VMNativeFunction *target)
|
||||||
I_Error("Native direct member function calls not implemented\n");
|
I_Error("Native direct member function calls not implemented\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target->ImplicitArgs > 0)
|
||||||
|
{
|
||||||
|
auto label = EmitThrowExceptionLabel(X_READ_NIL);
|
||||||
|
|
||||||
|
assert(ParamOpcodes.Size() > 0);
|
||||||
|
const VMOP *param = ParamOpcodes[0];
|
||||||
|
const int bc = param->i16u;
|
||||||
|
asmjit::X86Gp *reg = nullptr;
|
||||||
|
|
||||||
|
switch (param->a & REGT_TYPE)
|
||||||
|
{
|
||||||
|
case REGT_STRING: reg = ®S[bc]; break;
|
||||||
|
case REGT_POINTER: reg = ®A[bc]; break;
|
||||||
|
default:
|
||||||
|
I_Error("Unexpected register type for self pointer\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc.test(*reg, *reg);
|
||||||
|
cc.jz(label);
|
||||||
|
}
|
||||||
|
|
||||||
asmjit::CBNode *cursorBefore = cc.getCursor();
|
asmjit::CBNode *cursorBefore = cc.getCursor();
|
||||||
auto call = cc.call(imm_ptr(target->DirectNativeCall), CreateFuncSignature());
|
auto call = cc.call(imm_ptr(target->DirectNativeCall), CreateFuncSignature());
|
||||||
call->setInlineComment(target->PrintableName.GetChars());
|
call->setInlineComment(target->PrintableName.GetChars());
|
||||||
|
|
Loading…
Reference in a new issue