From aa7fd6979eb66747da103e313bd52492bffba1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 22 Jul 2024 09:14:13 +0200 Subject: [PATCH] Disable preloading of function stubs if bPreloadFunctions is off Fixes #19349. Strange that the game worked at all. The issue is that the arena could get resized due to precompile during sceKernelModuleLoad . Now respect the flag that turns precompile off properly (we should probably make it work differently instead, if we're gonna have it). --- Core/HLE/sceKernelModule.cpp | 12 +++++++++--- Core/MIPS/IR/IRJit.cpp | 10 +++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index be60003f75..e840ad4577 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -772,7 +772,9 @@ void ImportFuncSymbol(const FuncSymbolImport &func, bool reimporting, const char } WriteSyscall(func.moduleName, func.nid, func.stubAddr); currentMIPS->InvalidateICache(func.stubAddr, 8); - MIPSAnalyst::PrecompileFunction(func.stubAddr, 8); + if (g_Config.bPreloadFunctions) { + MIPSAnalyst::PrecompileFunction(func.stubAddr, 8); + } return; } @@ -791,7 +793,9 @@ void ImportFuncSymbol(const FuncSymbolImport &func, bool reimporting, const char } WriteFuncStub(func.stubAddr, it->symAddr); currentMIPS->InvalidateICache(func.stubAddr, 8); - MIPSAnalyst::PrecompileFunction(func.stubAddr, 8); + if (g_Config.bPreloadFunctions) { + MIPSAnalyst::PrecompileFunction(func.stubAddr, 8); + } return; } } @@ -831,7 +835,9 @@ void ExportFuncSymbol(const FuncSymbolExport &func) { INFO_LOG(Log::Loader, "Resolving function %s/%08x", func.moduleName, func.nid); WriteFuncStub(it->stubAddr, func.symAddr); currentMIPS->InvalidateICache(it->stubAddr, 8); - MIPSAnalyst::PrecompileFunction(it->stubAddr, 8); + if (g_Config.bPreloadFunctions) { + MIPSAnalyst::PrecompileFunction(it->stubAddr, 8); + } } } } diff --git a/Core/MIPS/IR/IRJit.cpp b/Core/MIPS/IR/IRJit.cpp index 68634e8447..10d213581b 100644 --- a/Core/MIPS/IR/IRJit.cpp +++ b/Core/MIPS/IR/IRJit.cpp @@ -327,11 +327,7 @@ void IRBlockCache::Clear() { arena_.shrink_to_fit(); } -IRBlockCache::IRBlockCache(bool compileToNative) : compileToNative_(compileToNative) { - // For whatever reason, this makes things go slower?? Probably just a CPU cache alignment fluke. - //arena_.reserve(1024 * 1024 * 12); - //arena_.reserve(1024); -} +IRBlockCache::IRBlockCache(bool compileToNative) : compileToNative_(compileToNative) {} int IRBlockCache::AllocateBlock(int emAddr, u32 origSize, const std::vector &insts) { // We have 24 bits to represent offsets with. @@ -346,7 +342,7 @@ int IRBlockCache::AllocateBlock(int emAddr, u32 origSize, const std::vector