diff --git a/src/scripting/backend/vmbuilder.cpp b/src/scripting/backend/vmbuilder.cpp index a141c3f8e..fd4ce1c93 100644 --- a/src/scripting/backend/vmbuilder.cpp +++ b/src/scripting/backend/vmbuilder.cpp @@ -35,6 +35,7 @@ #include "vmbuilder.h" #include "codegen.h" #include "m_argv.h" +#include "c_cvars.h" #include "scripting/vm/jit.h" struct VMRemap @@ -1046,6 +1047,8 @@ void FunctionCallEmitter::AddParameterStringConst(const FString &konst) }); } +EXTERN_CVAR(Bool, vm_jit) + ExpEmit FunctionCallEmitter::EmitCall(VMFunctionBuilder *build, TArray *ReturnRegs) { unsigned paramcount = 0; @@ -1085,6 +1088,15 @@ ExpEmit FunctionCallEmitter::EmitCall(VMFunctionBuilder *build, TArray if (ReturnRegs) ReturnRegs->Push(reg); else return reg; } + if (vm_jit) // The JIT compiler needs this, but the VM interpreter does not. + { + for (unsigned i = returns.Size(); i < target->Proto->ReturnTypes.Size(); i++) + { + ExpEmit reg(build, target->Proto->ReturnTypes[i]->RegType, target->Proto->ReturnTypes[i]->RegCount); + build->Emit(OP_RESULT, 0, EncodeRegType(reg), reg.RegNum); + reg.Free(build); + } + } return ExpEmit(); } diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 6e328c4c8..cf429ce37 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -36,8 +36,8 @@ #ifndef VM_H #define VM_H -#include "zstring.h" #include "autosegs.h" +#include "zstring.h" #include "vectors.h" #include "cmdlib.h" #include "doomerrors.h" diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index bf3fffef8..93717fb99 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1,4 +1,4 @@ -s//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- // // Copyright 2016-2018 Christoph Oelckers //