From 7e3e4f81acec86a4491a069e7f10b91cdcb3e189 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 26 Aug 2026 19:47:19 +0900 Subject: [PATCH] LookupCache: Clear L1 entries on dynamic cache growth Growing widens L1PointerMask without touching the table, so an entry whose address has the new mask bit set sits where InvalidateCache no longer looks, and a later shrink hands it back to the JIT. Wipe [0, old) on grow, the way the shrink wipes [new, MAX); the still-valid entries go with it. --- FEXCore/Source/Interface/Core/LookupCache.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FEXCore/Source/Interface/Core/LookupCache.h b/FEXCore/Source/Interface/Core/LookupCache.h index bf958d80b..d8d8c01f3 100644 --- a/FEXCore/Source/Interface/Core/LookupCache.h +++ b/FEXCore/Source/Interface/Core/LookupCache.h @@ -242,6 +242,9 @@ public: if (AveragePerSecond >= DynamicL1CacheIncreaseCountHeuristic()) { if (CurrentL1Entries < MAX_L1_ENTRIES) { + // Entries whose address has the new mask bit set would be unreachable by InvalidateCache + FEXCore::Allocator::VirtualDontNeed(reinterpret_cast(L1Pointer), CurrentL1Entries * sizeof(LookupCacheEntry), false); + CurrentL1Entries <<= 1; L1PointerMask = CurrentL1Entries - 1;