From 534606f4ce59b7f18c1331e8f40bd9df3b545e53 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 1 Nov 2018 21:39:30 +0100 Subject: [PATCH] - add vm_jit cvar to control JIT compilation --- src/scripting/vm/vmframe.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/scripting/vm/vmframe.cpp b/src/scripting/vm/vmframe.cpp index 4ca4f3f97..5ee4150a9 100644 --- a/src/scripting/vm/vmframe.cpp +++ b/src/scripting/vm/vmframe.cpp @@ -41,6 +41,14 @@ #include "vmintern.h" #include "types.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]; int VMCalls[10]; @@ -51,7 +59,6 @@ IMPLEMENT_CLASS(VMException, false, false) TArray VMFunction::AllFunctions; - VMScriptFunction::VMScriptFunction(FName 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) { - VMScriptFunction *sfunc = static_cast(func); - sfunc->ScriptCall = JitCompile(sfunc); - if (!sfunc->ScriptCall) - sfunc->ScriptCall = VMExec; + if (vm_jit) + { + func->ScriptCall = JitCompile(static_cast(func)); + if (!func->ScriptCall) + func->ScriptCall = VMExec; + } + else + { + func->ScriptCall = VMExec; + } return func->ScriptCall(func, params, numparams, ret, numret); }