From 8ec85cb0eea62ed4939d7a2f4562af307062d7c8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 17 Nov 2018 00:36:40 +0100 Subject: [PATCH] - add warning text when falling back to the VM --- src/scripting/vm/vmframe.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scripting/vm/vmframe.cpp b/src/scripting/vm/vmframe.cpp index 5f4e1f6a4..72046d0a2 100644 --- a/src/scripting/vm/vmframe.cpp +++ b/src/scripting/vm/vmframe.cpp @@ -225,7 +225,14 @@ 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 maxregs = 200; + if (func->NumRegA + func->NumRegD + func->NumRegF + func->NumRegS < maxregs) + return true; + + Printf(TEXTCOLOR_ORANGE "%s is using too many registers (%d of max %d)! Function will not use native code.\n", func->PrintableName.GetChars(), func->NumRegA + func->NumRegD + func->NumRegF + func->NumRegS, maxregs); + + return false; } int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret)