diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index e10256f491..539bb1b84b 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -183,7 +183,7 @@ void Jit64::Init() gpr.SetEmitter(this); fpr.SetEmitter(this); - trampolines.Init(); + trampolines.Init(js.memcheck ? TRAMPOLINE_CODE_SIZE_MMU : TRAMPOLINE_CODE_SIZE); AllocCodeSpace(CODE_SIZE); // BLR optimization has the same consequences as block linking, as well as @@ -494,9 +494,10 @@ void Jit64::Jit(u32 em_address) { if (GetSpaceLeft() < 0x10000 || farcode.GetSpaceLeft() < 0x10000 || - blocks.IsFull() || - SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockCache || - m_clear_cache_asap) + trampolines.GetSpaceLeft() < 0x10000 || + blocks.IsFull() || + SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockCache || + m_clear_cache_asap) { ClearCache(); } diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index 45f910eca0..b30515c101 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -249,7 +249,7 @@ void JitIL::Init() jo.accurateSinglePrecision = false; js.memcheck = SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU; - trampolines.Init(); + trampolines.Init(js.memcheck ? TRAMPOLINE_CODE_SIZE_MMU : TRAMPOLINE_CODE_SIZE); AllocCodeSpace(CODE_SIZE); blocks.Init(); asm_routines.Init(nullptr); diff --git a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h index 6681808aa7..9c11937b47 100644 --- a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h +++ b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h @@ -42,6 +42,10 @@ static const int CODE_SIZE = 1024 * 1024 * 32; static const int FARCODE_SIZE = 1024 * 1024 * 8; static const int FARCODE_SIZE_MMU = 1024 * 1024 * 48; +// same for the trampoline code cache, because fastmem results in far more backpatches in MMU mode +static const int TRAMPOLINE_CODE_SIZE = 1024 * 1024 * 8; +static const int TRAMPOLINE_CODE_SIZE_MMU = 1024 * 1024 * 32; + // Like XCodeBlock but has some utilities for memory access. class EmuCodeBlock : public Gen::X64CodeBlock { diff --git a/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.cpp b/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.cpp index f5bbea78dc..63a436511d 100644 --- a/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.cpp @@ -19,9 +19,9 @@ using namespace Gen; -void TrampolineCache::Init() +void TrampolineCache::Init(int size) { - AllocCodeSpace(8 * 1024 * 1024); + AllocCodeSpace(size); } void TrampolineCache::ClearCodeSpace() diff --git a/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.h b/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.h index 9b35950b66..305ab2389a 100644 --- a/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.h +++ b/Source/Core/Core/PowerPC/JitCommon/TrampolineCache.h @@ -17,7 +17,7 @@ const int BACKPATCH_SIZE = 5; class TrampolineCache : public Gen::X64CodeBlock { public: - void Init(); + void Init(int size); void Shutdown(); const u8* GenerateReadTrampoline(const InstructionInfo &info, BitSet32 registersInUse, u8* exceptionHandler, u8* returnPtr);