mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
JIT-Compile all functions during startup
This commit is contained in:
parent
aed85a25a2
commit
43c70cdf9d
3 changed files with 39 additions and 14 deletions
|
@ -41,6 +41,9 @@
|
|||
|
||||
CVAR(Bool, strictdecorate, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
|
||||
|
||||
EXTERN_CVAR(Bool, vm_jit)
|
||||
EXTERN_CVAR(Bool, vm_jit_aot)
|
||||
|
||||
struct VMRemap
|
||||
{
|
||||
uint8_t altOp, kReg, kType;
|
||||
|
@ -928,6 +931,13 @@ void FFunctionBuildList::Build()
|
|||
disasmdump.Write(sfunc, item.PrintableName);
|
||||
|
||||
sfunc->Unsafe = ctx.Unsafe;
|
||||
|
||||
#if HAVE_VM_JIT
|
||||
if(vm_jit && vm_jit_aot)
|
||||
{
|
||||
sfunc->JitCompile();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
|
@ -1094,8 +1104,6 @@ void FunctionCallEmitter::AddParameterStringConst(const FString &konst)
|
|||
});
|
||||
}
|
||||
|
||||
EXTERN_CVAR(Bool, vm_jit)
|
||||
|
||||
ExpEmit FunctionCallEmitter::EmitCall(VMFunctionBuilder *build, TArray<ExpEmit> *ReturnRegs)
|
||||
{
|
||||
unsigned paramcount = 0;
|
||||
|
|
|
@ -54,8 +54,14 @@ CUSTOM_CVAR(Bool, vm_jit, true, CVAR_NOINITCALL)
|
|||
Printf("You must restart " GAMENAME " for this change to take effect.\n");
|
||||
Printf("This cvar is currently not saved. You must specify it on the command line.");
|
||||
}
|
||||
CUSTOM_CVAR(Bool, vm_jit_aot, true, CVAR_NOINITCALL)
|
||||
{
|
||||
Printf("You must restart " GAMENAME " for this change to take effect.\n");
|
||||
Printf("This cvar is currently not saved. You must specify it on the command line.");
|
||||
}
|
||||
#else
|
||||
CVAR(Bool, vm_jit, false, CVAR_NOINITCALL|CVAR_NOSET)
|
||||
CVAR(Bool, vm_jit_aot, false, CVAR_NOINITCALL|CVAR_NOSET)
|
||||
FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames, int maxFrames) { return FString(); }
|
||||
void JitRelease() {}
|
||||
#endif
|
||||
|
@ -282,6 +288,25 @@ static bool CanJit(VMScriptFunction *func)
|
|||
return false;
|
||||
}
|
||||
|
||||
void VMScriptFunction::JitCompile()
|
||||
{
|
||||
if(!(VarFlags & VARF_Abstract))
|
||||
{
|
||||
#ifdef HAVE_VM_JIT
|
||||
if (vm_jit && CanJit(this))
|
||||
{
|
||||
ScriptCall = ::JitCompile(this);
|
||||
if (!ScriptCall)
|
||||
ScriptCall = VMExec;
|
||||
}
|
||||
else
|
||||
#endif // HAVE_VM_JIT
|
||||
{
|
||||
ScriptCall = VMExec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret)
|
||||
{
|
||||
// [Player701] Check that we aren't trying to call an abstract function.
|
||||
|
@ -291,18 +316,8 @@ int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int num
|
|||
{
|
||||
ThrowAbortException(X_OTHER, "attempt to call abstract function %s.", func->PrintableName);
|
||||
}
|
||||
#ifdef HAVE_VM_JIT
|
||||
if (vm_jit && CanJit(static_cast<VMScriptFunction*>(func)))
|
||||
{
|
||||
func->ScriptCall = JitCompile(static_cast<VMScriptFunction*>(func));
|
||||
if (!func->ScriptCall)
|
||||
func->ScriptCall = VMExec;
|
||||
}
|
||||
else
|
||||
#endif // HAVE_VM_JIT
|
||||
{
|
||||
func->ScriptCall = VMExec;
|
||||
}
|
||||
|
||||
static_cast<VMScriptFunction*>(func)->JitCompile();
|
||||
|
||||
return func->ScriptCall(func, params, numparams, ret, numret);
|
||||
}
|
||||
|
|
|
@ -481,4 +481,6 @@ public:
|
|||
|
||||
private:
|
||||
static int FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret);
|
||||
void JitCompile();
|
||||
friend class FFunctionBuildList;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue