From 2b8ede8dc6d69509131cf12fe7166b5ef1902bb2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Jan 2017 23:00:16 -0500 Subject: [PATCH] JitCache: Move implementation details into the cpp file --- .../Core/Core/PowerPC/JitCommon/JitCache.cpp | 23 +++++++++++++++++++ Source/Core/Core/PowerPC/JitCommon/JitCache.h | 15 ++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index e358f473e4..64c7b88da4 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -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]; +} diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.h b/Source/Core/Core/PowerPC/JitCommon/JitCache.h index 7837603a64..e964eba9c7 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.h @@ -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 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.