From c6fba938bb3505ae99dfc36e7b39e39140693202 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 2 May 2026 02:49:59 +0000 Subject: [PATCH] CPU: Increased base JIT cache size @MaxLastBreath found that The Legend of Zelda: Tears of the Kingdom experiences inconsistent crashing with a limited JIT cache size. Increasing the cache size seems to help with this, and increasing it shouldn't degrade performance for other titles. @LotP plans to look this over later, but for now, this should suffice as a fix for affected users. --- src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs index 05143ac45..c8fb1c840 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs @@ -17,7 +17,8 @@ namespace Ryujinx.Cpu.LightningJit.Cache private static readonly int _pageMask = _pageSize - 1; private const int CodeAlignment = 4; // Bytes. - private const int CacheSize = 256 * 1024 * 1024; + // TODO: JIT Cache size should be application dependent, not global. + private const int CacheSize = 1024 * (1024 * 1024); // Megabytes * Size of Megabytes (since its in bytes). private static JitCacheInvalidation _jitCacheInvalidator; @@ -34,6 +35,14 @@ namespace Ryujinx.Cpu.LightningJit.Cache [LibraryImport("kernel32.dll", SetLastError = true)] public static partial nint FlushInstructionCache(nint hProcess, nint lpAddress, nuint dwSize); + [SupportedOSPlatform("macos")] + [LibraryImport("libSystem.dylib", EntryPoint = "sys_icache_invalidate")] + internal static partial void SysICacheInvalidate(nint start, nuint len); + + [SupportedOSPlatform("linux")] + [LibraryImport("libgcc_s.so.1", EntryPoint = "__clear_cache")] + internal static partial void ClearCache(nint begin, nint end); + public static void Initialize(IJitMemoryAllocator allocator) { if (_initialized)