Skip to content

Commit

Permalink
CPU/CodeCache: Reduce far code size when using NewRec
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jun 30, 2024
1 parent 9b42ad3 commit f3671d2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/cpu_code_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ PerfScope MIPSPerfScope("MIPS");

#if defined(CPU_ARCH_ARM32)
// Use a smaller code buffer size on AArch32 to have a better chance of being in range.
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 20 * 1024 * 1024;
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 16 * 1024 * 1024;
static constexpr u32 RECOMPILER_FAR_CODE_CACHE_SIZE = 4 * 1024 * 1024;
#else
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 48 * 1024 * 1024;
Expand Down Expand Up @@ -1435,8 +1435,13 @@ void CPU::CodeCache::ResetCodeBuffer()
s_code_size = RECOMPILER_CODE_CACHE_SIZE - RECOMPILER_FAR_CODE_CACHE_SIZE;
s_code_used = 0;

s_far_code_size = RECOMPILER_FAR_CODE_CACHE_SIZE;
s_far_code_ptr = (s_far_code_size > 0) ? (static_cast<u8*>(s_code_ptr) + s_code_size) : nullptr;
// Use half the far code size when using newrec and memory exceptions aren't enabled. It's only used for backpatching.
const u32 far_code_size =
(g_settings.cpu_execution_mode == CPUExecutionMode::NewRec && !g_settings.cpu_recompiler_memory_exceptions) ?
(RECOMPILER_FAR_CODE_CACHE_SIZE / 2) :
RECOMPILER_FAR_CODE_CACHE_SIZE;
s_far_code_size = far_code_size;
s_far_code_ptr = (far_code_size > 0) ? (static_cast<u8*>(s_code_ptr) + s_code_size) : nullptr;
s_free_far_code_ptr = s_far_code_ptr;
s_far_code_used = 0;

Expand Down

0 comments on commit f3671d2

Please sign in to comment.