CachedInterpreter: Separate the block cache from CachedInterpreter

An interpreter is not a block cache. It may utilize a block cache, it may
contain a block cache but it *is not* A block cache.
This commit is contained in:
Lioncash 2017-01-09 01:18:58 -05:00
parent eddccb3891
commit f75aab1a85
7 changed files with 48 additions and 11 deletions

View File

@ -168,6 +168,7 @@ set(SRCS ActionReplay.cpp
PowerPC/SignatureDB/SignatureDB.cpp
PowerPC/JitInterface.cpp
PowerPC/CachedInterpreter/CachedInterpreter.cpp
PowerPC/CachedInterpreter/InterpreterBlockCache.cpp
PowerPC/Interpreter/Interpreter_Branch.cpp
PowerPC/Interpreter/Interpreter.cpp
PowerPC/Interpreter/Interpreter_FloatingPoint.cpp

View File

@ -205,6 +205,7 @@
<ClCompile Include="NetPlayServer.cpp" />
<ClCompile Include="PatchEngine.cpp" />
<ClCompile Include="PowerPC\CachedInterpreter\CachedInterpreter.cpp" />
<ClCompile Include="PowerPC\CachedInterpreter\InterpreterBlockCache.cpp" />
<ClCompile Include="PowerPC\Interpreter\Interpreter.cpp" />
<ClCompile Include="PowerPC\Interpreter\Interpreter_Branch.cpp" />
<ClCompile Include="PowerPC\Interpreter\Interpreter_FloatingPoint.cpp" />
@ -425,6 +426,7 @@
<ClInclude Include="PowerPC\CPUCoreBase.h" />
<ClInclude Include="PowerPC\Gekko.h" />
<ClInclude Include="PowerPC\CachedInterpreter\CachedInterpreter.h" />
<ClInclude Include="PowerPC\CachedInterpreter\InterpreterBlockCache.h" />
<ClInclude Include="PowerPC\Interpreter\Interpreter.h" />
<ClInclude Include="PowerPC\Interpreter\Interpreter_FPUtils.h" />
<ClInclude Include="PowerPC\Interpreter\Interpreter_Tables.h" />

View File

@ -279,6 +279,9 @@
<ClCompile Include="PowerPC\CachedInterpreter\CachedInterpreter.cpp">
<Filter>PowerPC\Cached Interpreter</Filter>
</ClCompile>
<ClCompile Include="PowerPC\CachedInterpreter\InterpreterBlockCache.cpp">
<Filter>PowerPC\Cached Interpreter</Filter>
</ClCompile>
<ClCompile Include="PowerPC\Interpreter\Interpreter.cpp">
<Filter>PowerPC\Interpreter</Filter>
</ClCompile>
@ -875,6 +878,9 @@
<ClInclude Include="PowerPC\CachedInterpreter\CachedInterpreter.h">
<Filter>PowerPC\Cached Interpreter</Filter>
</ClInclude>
<ClInclude Include="PowerPC\CachedInterpreter\InterpreterBlockCache.h">
<Filter>PowerPC\Cached Interpreter</Filter>
</ClInclude>
<ClInclude Include="PowerPC\Interpreter\Interpreter.h">
<Filter>PowerPC\Interpreter</Filter>
</ClInclude>

View File

@ -20,7 +20,7 @@ void CachedInterpreter::Init()
jo.enableBlocklink = false;
JitBaseBlockCache::Init();
m_block_cache.Init();
UpdateMemoryOptions();
code_block.m_stats = &js.st;
@ -30,12 +30,12 @@ void CachedInterpreter::Init()
void CachedInterpreter::Shutdown()
{
JitBaseBlockCache::Shutdown();
m_block_cache.Shutdown();
}
void CachedInterpreter::ExecuteOneBlock()
{
const u8* normal_entry = JitBaseBlockCache::Dispatch();
const u8* normal_entry = m_block_cache.Dispatch();
const Instruction* code = reinterpret_cast<const Instruction*>(normal_entry);
for (; code->type != Instruction::INSTRUCTION_ABORT; ++code)
@ -123,7 +123,7 @@ static bool CheckDSI(u32 data)
void CachedInterpreter::Jit(u32 address)
{
if (m_code.size() >= CODE_SIZE / sizeof(Instruction) - 0x1000 || IsFull() ||
if (m_code.size() >= CODE_SIZE / sizeof(Instruction) - 0x1000 || m_block_cache.IsFull() ||
SConfig::GetInstance().bJITNoBlockCache)
{
ClearCache();
@ -140,8 +140,8 @@ void CachedInterpreter::Jit(u32 address)
return;
}
int block_num = AllocateBlock(PC);
JitBlock* b = GetBlock(block_num);
int block_num = m_block_cache.AllocateBlock(PC);
JitBlock* b = m_block_cache.GetBlock(block_num);
js.blockStart = PC;
js.firstFPInstructionFound = false;
@ -212,12 +212,12 @@ void CachedInterpreter::Jit(u32 address)
b->codeSize = (u32)(GetCodePtr() - b->checkedEntry);
b->originalSize = code_block.m_num_instructions;
FinalizeBlock(block_num, jo.enableBlocklink, b->checkedEntry);
m_block_cache.FinalizeBlock(block_num, jo.enableBlocklink, b->checkedEntry);
}
void CachedInterpreter::ClearCache()
{
m_code.clear();
JitBaseBlockCache::Clear();
m_block_cache.Clear();
UpdateMemoryOptions();
}

View File

@ -7,10 +7,11 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "Core/PowerPC/CachedInterpreter/InterpreterBlockCache.h"
#include "Core/PowerPC/JitCommon/JitBase.h"
#include "Core/PowerPC/PPCAnalyst.h"
class CachedInterpreter : public JitBase, JitBaseBlockCache
class CachedInterpreter : public JitBase
{
public:
CachedInterpreter() : code_buffer(32000) {}
@ -26,9 +27,8 @@ public:
void Jit(u32 address) override;
JitBaseBlockCache* GetBlockCache() override { return this; }
JitBaseBlockCache* GetBlockCache() override { return &m_block_cache; }
const char* GetName() override { return "Cached Interpreter"; }
void WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest) override {}
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }
private:
struct Instruction
@ -59,6 +59,7 @@ private:
const u8* GetCodePtr() { return (u8*)(m_code.data() + m_code.size()); }
void ExecuteOneBlock();
BlockCache m_block_cache;
std::vector<Instruction> m_code;
PPCAnalyst::CodeBuffer code_buffer;
};

View File

@ -0,0 +1,11 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/PowerPC/CachedInterpreter/InterpreterBlockCache.h"
BlockCache::BlockCache() = default;
void BlockCache::WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest)
{
}

View File

@ -0,0 +1,16 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "Core/PowerPC/JitCommon/JitCache.h"
class BlockCache final : public JitBaseBlockCache
{
public:
BlockCache();
private:
void WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest) override;
};