From 9ef7212f541b0353e4014f6d92d790ac6256eaad Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 23 Nov 2018 05:20:12 +0100 Subject: [PATCH] - add return type to CreateFuncSignature --- src/scripting/vm/jit_call.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/scripting/vm/jit_call.cpp b/src/scripting/vm/jit_call.cpp index 5e07a8d316..48ba37dc69 100644 --- a/src/scripting/vm/jit_call.cpp +++ b/src/scripting/vm/jit_call.cpp @@ -510,12 +510,38 @@ asmjit::FuncSignature JitCompiler::CreateFuncSignature(VMFunction *func) } } + uint32_t rettype = TypeIdOf::kTypeId; + if (func->Proto->ReturnTypes.Size() > 0) + { + const PType *type = func->Proto->ReturnTypes[0]; + if (type == TypeFloat64) + { + rettype = TypeIdOf::kTypeId; + key += "rf"; + } + else if (type == TypeString) + { + rettype = TypeIdOf::kTypeId; + key += "rs"; + } + else if (type->isIntCompatible()) + { + rettype = TypeIdOf::kTypeId; + key += "ri"; + } + else + { + rettype = TypeIdOf::kTypeId; + key += "rv"; + } + } + // FuncSignature only keeps a pointer to its args array. Store a copy of each args array variant. static std::map>> argsCache; std::unique_ptr> &cachedArgs = argsCache[key]; if (!cachedArgs) cachedArgs.reset(new TArray(args)); FuncSignature signature; - signature.init(CallConv::kIdHost, TypeIdOf::kTypeId, cachedArgs->Data(), cachedArgs->Size()); + signature.init(CallConv::kIdHost, rettype, cachedArgs->Data(), cachedArgs->Size()); return signature; }