- add vm_jit cvar to control JIT compilation

This commit is contained in:
Magnus Norddahl 2018-11-01 21:39:30 +01:00
parent 369dcfd57f
commit 534606f4ce

View file

@ -41,6 +41,14 @@
#include "vmintern.h" #include "vmintern.h"
#include "types.h" #include "types.h"
#include "jit.h" #include "jit.h"
#include "c_cvars.h"
#include "version.h"
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.");
}
cycle_t VMCycles[10]; cycle_t VMCycles[10];
int VMCalls[10]; int VMCalls[10];
@ -51,7 +59,6 @@ IMPLEMENT_CLASS(VMException, false, false)
TArray<VMFunction *> VMFunction::AllFunctions; TArray<VMFunction *> VMFunction::AllFunctions;
VMScriptFunction::VMScriptFunction(FName name) VMScriptFunction::VMScriptFunction(FName name)
{ {
Name = name; Name = name;
@ -210,10 +217,16 @@ int VMScriptFunction::PCToLine(const VMOP *pc)
int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret) int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret)
{ {
VMScriptFunction *sfunc = static_cast<VMScriptFunction*>(func); if (vm_jit)
sfunc->ScriptCall = JitCompile(sfunc); {
if (!sfunc->ScriptCall) func->ScriptCall = JitCompile(static_cast<VMScriptFunction*>(func));
sfunc->ScriptCall = VMExec; if (!func->ScriptCall)
func->ScriptCall = VMExec;
}
else
{
func->ScriptCall = VMExec;
}
return func->ScriptCall(func, params, numparams, ret, numret); return func->ScriptCall(func, params, numparams, ret, numret);
} }