From a9f6605f4b9e1e8e57c149e08cb610b25b98e762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Fri, 22 Mar 2024 10:35:46 -0300 Subject: [PATCH] Can't narrow down the JIT bug yet, so block JIT for functions that call Function Pointers temporarily --- src/common/scripting/backend/codegen.cpp | 2 ++ src/common/scripting/vm/vmframe.cpp | 2 ++ src/common/scripting/vm/vmintern.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 0504fc16006..28f27f8505f 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -9542,6 +9542,8 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) auto &argflags = Function->Variants[0].ArgFlags; auto *defaults = FnPtrCall ? nullptr : &Function->Variants[0].Implementation->DefaultArgs; + if(FnPtrCall) static_cast(ctx.Function->Variants[0].Implementation)->blockJit = true; + int implicit = Function->GetImplicitArgs(); if (!CheckAccessibility(ctx.Version)) diff --git a/src/common/scripting/vm/vmframe.cpp b/src/common/scripting/vm/vmframe.cpp index 635bace6339..f69b8ea6160 100644 --- a/src/common/scripting/vm/vmframe.cpp +++ b/src/common/scripting/vm/vmframe.cpp @@ -279,6 +279,8 @@ 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 ;) + if(func->blockJit) return false; + int maxregs = 200; if (func->NumRegA + func->NumRegD + func->NumRegF + func->NumRegS < maxregs) return true; diff --git a/src/common/scripting/vm/vmintern.h b/src/common/scripting/vm/vmintern.h index 44fb5346302..b35eefc1e34 100644 --- a/src/common/scripting/vm/vmintern.h +++ b/src/common/scripting/vm/vmintern.h @@ -474,6 +474,8 @@ class VMScriptFunction : public VMFunction VM_UBYTE NumArgs; // Number of arguments this function takes TArray SpecialInits; // list of all contents on the extra stack which require construction and destruction + bool blockJit = false; // function triggers Jit bugs, block compilation until bugs are fixed + void InitExtra(void *addr); void DestroyExtra(void *addr); int AllocExtraStack(PType *type);