From 2d5288dc1025ec0e582090b5c1efc326635eb708 Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 10 Jan 2017 23:28:44 +0100 Subject: [PATCH] JitCache: Return a pointer in AllocateBlock. --- .../Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp | 3 +-- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 3 +-- Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp | 3 +-- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 3 +-- Source/Core/Core/PowerPC/JitCommon/JitCache.cpp | 4 ++-- Source/Core/Core/PowerPC/JitCommon/JitCache.h | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp index 7fe68c3c21..39006acf01 100644 --- a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp +++ b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp @@ -140,8 +140,7 @@ void CachedInterpreter::Jit(u32 address) return; } - int block_num = m_block_cache.AllocateBlock(PC); - JitBlock* b = m_block_cache.GetBlock(block_num); + JitBlock* b = m_block_cache.AllocateBlock(PC); js.blockStart = PC; js.firstFPInstructionFound = false; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index cb000b93ff..580bab2577 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -589,8 +589,7 @@ void Jit64::Jit(u32 em_address) return; } - int block_num = blocks.AllocateBlock(em_address); - JitBlock* b = blocks.GetBlock(block_num); + JitBlock* b = blocks.AllocateBlock(em_address); blocks.FinalizeBlock(*b, jo.enableBlocklink, DoJit(em_address, &code_buffer, b, nextPC)); } diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index 99bd811c2f..85c8b12cc0 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -507,8 +507,7 @@ void JitIL::Jit(u32 em_address) return; } - int block_num = blocks.AllocateBlock(em_address); - JitBlock* b = blocks.GetBlock(block_num); + JitBlock* b = blocks.AllocateBlock(em_address); blocks.FinalizeBlock(*b, jo.enableBlocklink, DoJit(em_address, &code_buffer, b, nextPC)); } diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index a1139f0c24..a424166574 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -398,8 +398,7 @@ void JitArm64::Jit(u32) return; } - int block_num = blocks.AllocateBlock(em_address); - JitBlock* b = blocks.GetBlock(block_num); + JitBlock* b = blocks.AllocateBlock(em_address); const u8* BlockPtr = DoJit(em_address, &code_buffer, b, nextPC); blocks.FinalizeBlock(*b, jo.enableBlocklink, BlockPtr); } diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index 869ebb4374..944051d2ac 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -119,7 +119,7 @@ int* JitBaseBlockCache::GetICache() return iCache.data(); } -int JitBaseBlockCache::AllocateBlock(u32 em_address) +JitBlock* JitBaseBlockCache::AllocateBlock(u32 em_address) { JitBlock& b = blocks[num_blocks]; b.invalid = false; @@ -128,7 +128,7 @@ int JitBaseBlockCache::AllocateBlock(u32 em_address) b.msrBits = MSR & JitBlock::JIT_CACHE_MSR_MASK; b.linkData.clear(); num_blocks++; // commit the current block - return num_blocks - 1; + return &b; } void JitBaseBlockCache::FinalizeBlock(JitBlock& b, bool block_link, const u8* code_ptr) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.h b/Source/Core/Core/PowerPC/JitCommon/JitCache.h index 446aaa70e6..b44572e2b4 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.h @@ -131,7 +131,7 @@ public: int GetNumBlocks() const; int* GetICache(); - int AllocateBlock(u32 em_address); + JitBlock* AllocateBlock(u32 em_address); void FinalizeBlock(JitBlock& b, bool block_link, const u8* code_ptr); // Look for the block in the slow but accurate way.