Merge pull request #3535 from RisingFog/cya_savestate_memleak

Properly clear JIT cache on save states
This commit is contained in:
Pierre Bourdon 2016-01-20 18:02:25 +01:00
commit e455ca4d58
6 changed files with 20 additions and 2 deletions

View File

@ -607,7 +607,11 @@ void Wiimote::DoState(PointerWrap& p)
{
//clear
while (!m_read_requests.empty())
{
delete[] m_read_requests.front().data;
m_read_requests.pop();
}
p.Do(size);
while (size--)

View File

@ -210,6 +210,7 @@ void Jit64::Init()
// important: do this *after* generating the global asm routines, because we can't use farcode in them.
// it'll crash because the farcode functions get cleared on JIT clears.
farcode.Init(jo.memcheck ? FARCODE_SIZE_MMU : FARCODE_SIZE);
Clear();
code_block.m_stats = &js.st;
code_block.m_gpa = &js.gpa;
@ -223,6 +224,7 @@ void Jit64::ClearCache()
trampolines.ClearCodeSpace();
farcode.ClearCodeSpace();
ClearCodeSpace();
Clear();
UpdateMemoryOptions();
m_clear_cache_asap = false;
}

View File

@ -258,6 +258,7 @@ void JitIL::Init()
asm_routines.Init(nullptr);
farcode.Init(jo.memcheck ? FARCODE_SIZE_MMU : FARCODE_SIZE);
Clear();
code_block.m_stats = &js.st;
code_block.m_gpa = &js.gpa;
@ -273,7 +274,9 @@ void JitIL::ClearCache()
{
blocks.Clear();
trampolines.ClearCodeSpace();
farcode.ClearCodeSpace();
ClearCodeSpace();
Clear();
}
void JitIL::Shutdown()
@ -459,7 +462,7 @@ void JitIL::Trace()
void JitIL::Jit(u32 em_address)
{
if (IsAlmostFull() || farcode.IsAlmostFull() || blocks.IsFull() ||
if (IsAlmostFull() || farcode.IsAlmostFull() || trampolines.IsAlmostFull() || blocks.IsFull() ||
SConfig::GetInstance().bJITNoBlockCache)
{
ClearCache();

View File

@ -1018,3 +1018,11 @@ void EmuCodeBlock::JitClearCA()
{
MOV(8, PPCSTATE(xer_ca), Imm8(0));
}
void EmuCodeBlock::Clear()
{
registersInUseAtLoc.clear();
pcAtLoc.clear();
exceptionHandlerAtLoc.clear();
}

View File

@ -129,6 +129,7 @@ public:
void ConvertSingleToDouble(Gen::X64Reg dst, Gen::X64Reg src, bool src_is_gpr = false);
void ConvertDoubleToSingle(Gen::X64Reg dst, Gen::X64Reg src);
void SetFPRF(Gen::X64Reg xmm);
void Clear();
protected:
std::unordered_map<u8 *, BitSet32> registersInUseAtLoc;
std::unordered_map<u8 *, u32> pcAtLoc;

View File

@ -40,7 +40,7 @@ namespace JitInterface
void DoState(PointerWrap &p)
{
if (jit && p.GetMode() == PointerWrap::MODE_READ)
jit->GetBlockCache()->Clear();
jit->ClearCache();
}
CPUCoreBase *InitJitCore(int core)
{