JitCache: Move implementation details into the cpp file

This commit is contained in:
Lioncash 2017-01-08 23:00:16 -05:00
parent cf18aeb1eb
commit 2b8ede8dc6
2 changed files with 31 additions and 7 deletions

View File

@ -35,6 +35,9 @@ static void ClearCacheThreadSafe(u64 userdata, s64 cyclesdata)
JitInterface::ClearCache();
}
JitBaseBlockCache::JitBaseBlockCache() = default;
JitBaseBlockCache::~JitBaseBlockCache() = default;
void JitBaseBlockCache::Init()
{
s_clear_jit_cache_thread_safe = CoreTiming::RegisterEvent("clearJitCache", ClearCacheThreadSafe);
@ -98,11 +101,21 @@ JitBlock* JitBaseBlockCache::GetBlock(int no)
return &blocks[no];
}
JitBlock* JitBaseBlockCache::GetBlocks()
{
return blocks.data();
}
int JitBaseBlockCache::GetNumBlocks() const
{
return num_blocks;
}
int* JitBaseBlockCache::GetICache()
{
return iCache.data();
}
int JitBaseBlockCache::AllocateBlock(u32 em_address)
{
JitBlock& b = blocks[num_blocks];
@ -238,6 +251,11 @@ void JitBaseBlockCache::InvalidateICache(u32 address, const u32 length, bool for
}
}
u32* JitBaseBlockCache::GetBlockBitSet() const
{
return valid_block.m_valid_block.get();
}
void JitBaseBlockCache::WriteDestroyBlock(const JitBlock& block)
{
}
@ -356,3 +374,8 @@ void JitBaseBlockCache::MoveBlockIntoFastCache(u32 addr, u32 msr)
LinkBlock(block_num);
}
}
int& JitBaseBlockCache::FastLookupEntryForAddress(u32 address)
{
return iCache[(address >> 2) & iCache_Mask];
}

View File

@ -112,8 +112,9 @@ public:
static constexpr u32 iCache_Num_Elements = 0x10000;
static constexpr u32 iCache_Mask = iCache_Num_Elements - 1;
JitBaseBlockCache() : num_blocks(1) {}
virtual ~JitBaseBlockCache() {}
JitBaseBlockCache();
virtual ~JitBaseBlockCache();
void Init();
void Shutdown();
void Clear();
@ -124,9 +125,9 @@ public:
// Code Cache
JitBlock* GetBlock(int block_num);
JitBlock* GetBlocks() { return blocks.data(); }
JitBlock* GetBlocks();
int GetNumBlocks() const;
int* GetICache() { return iCache.data(); }
int* GetICache();
int AllocateBlock(u32 em_address);
void FinalizeBlock(int block_num, bool block_link, const u8* code_ptr);
@ -143,7 +144,7 @@ public:
void InvalidateICache(u32 address, const u32 length, bool forced);
u32* GetBlockBitSet() const { return valid_block.m_valid_block.get(); }
u32* GetBlockBitSet() const;
private:
virtual void WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest) = 0;
@ -157,12 +158,12 @@ private:
void MoveBlockIntoFastCache(u32 em_address, u32 msr);
// Fast but risky block lookup based on iCache.
int& FastLookupEntryForAddress(u32 address) { return iCache[(address >> 2) & iCache_Mask]; }
int& FastLookupEntryForAddress(u32 address);
// We store the metadata of all blocks in a linear way within this array.
// Note: blocks[0] must not be used as it is referenced as invalid block in iCache.
std::array<JitBlock, MAX_NUM_BLOCKS> blocks; // number -> JitBlock
int num_blocks;
int num_blocks = 1;
// links_to hold all exit points of all valid blocks in a reverse way.
// It is used to query all blocks which links to an address.