summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-01-20 18:02:25 +0100
committerPierre Bourdon <delroth@gmail.com>2016-01-20 18:02:25 +0100
commite455ca4d58a7fd398091524e8a270ba81880dfa5 (patch)
tree2527285f36b237c25462225bde59aee4f85b34f7 /Source
parentf4c1801c643d70d68be99a2e34da02cbaa77fc00 (diff)
parenta7a744d33ce042b3ed72775de393149bee63663f (diff)
Merge pull request #3535 from RisingFog/cya_savestate_memleak
Properly clear JIT cache on save states
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp4
-rw-r--r--Source/Core/Core/PowerPC/Jit64/Jit.cpp2
-rw-r--r--Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp5
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp8
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/Jit_Util.h1
-rw-r--r--Source/Core/Core/PowerPC/JitInterface.cpp2
6 files changed, 20 insertions, 2 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
index 377cda3769..78d68e5f2a 100644
--- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
@@ -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--)
diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp
index a9801ee1fa..1314b8b49b 100644
--- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp
+++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp
@@ -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;
}
diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
index 72cb76270e..68fb1aa686 100644
--- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
+++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
@@ -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();
diff --git a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp
index 3797fa979d..11a02efb31 100644
--- a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp
+++ b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp
@@ -1018,3 +1018,11 @@ void EmuCodeBlock::JitClearCA()
{
MOV(8, PPCSTATE(xer_ca), Imm8(0));
}
+
+void EmuCodeBlock::Clear()
+{
+ registersInUseAtLoc.clear();
+ pcAtLoc.clear();
+ exceptionHandlerAtLoc.clear();
+}
+
diff --git a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h
index 4915206786..cc5db24240 100644
--- a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h
+++ b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.h
@@ -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;
diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp
index 5bc3323a1f..7295ea2a8a 100644
--- a/Source/Core/Core/PowerPC/JitInterface.cpp
+++ b/Source/Core/Core/PowerPC/JitInterface.cpp
@@ -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)
{