- make functions using too many registers (more than 200) fall back to the VM

This commit is contained in:
Magnus Norddahl 2018-11-17 00:04:15 +01:00
parent 95ab1da6a0
commit ea26bf6b2f
1 changed files with 8 additions and 1 deletions

View File

@ -221,10 +221,17 @@ int VMScriptFunction::PCToLine(const VMOP *pc)
return -1;
}
static bool CanJit(VMScriptFunction *func)
{
// Asmjit has a 256 register limit. Stay safely away from it as the jit compiler uses a few for temporaries as well.
// Any function exceeding the limit will use the VM - a fair punishment to someone for writing a function so bloated ;)
return func->NumRegA + func->NumRegD + func->NumRegF + func->NumRegS < 200;
}
int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret)
{
#ifdef ARCH_X64
if (vm_jit)
if (vm_jit && CanJit(static_cast<VMScriptFunction*>(func)))
{
func->ScriptCall = JitCompile(static_cast<VMScriptFunction*>(func));
if (!func->ScriptCall)