diff --git a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp index 44bf711e90..7fe68c3c21 100644 --- a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp +++ b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp @@ -212,7 +212,7 @@ void CachedInterpreter::Jit(u32 address) b->codeSize = (u32)(GetCodePtr() - b->checkedEntry); b->originalSize = code_block.m_num_instructions; - m_block_cache.FinalizeBlock(block_num, jo.enableBlocklink, b->checkedEntry); + m_block_cache.FinalizeBlock(*b, jo.enableBlocklink, b->checkedEntry); } void CachedInterpreter::ClearCache() diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index a96078302e..cb000b93ff 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -591,7 +591,7 @@ void Jit64::Jit(u32 em_address) int block_num = blocks.AllocateBlock(em_address); JitBlock* b = blocks.GetBlock(block_num); - blocks.FinalizeBlock(block_num, jo.enableBlocklink, DoJit(em_address, &code_buffer, b, nextPC)); + blocks.FinalizeBlock(*b, jo.enableBlocklink, DoJit(em_address, &code_buffer, b, nextPC)); } const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock* b, u32 nextPC) diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index 988d8321fd..99bd811c2f 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -509,7 +509,7 @@ void JitIL::Jit(u32 em_address) int block_num = blocks.AllocateBlock(em_address); JitBlock* b = blocks.GetBlock(block_num); - blocks.FinalizeBlock(block_num, jo.enableBlocklink, DoJit(em_address, &code_buffer, b, nextPC)); + blocks.FinalizeBlock(*b, jo.enableBlocklink, DoJit(em_address, &code_buffer, b, nextPC)); } const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock* b, u32 nextPC) diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index 5ee45e5613..a1139f0c24 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -401,7 +401,7 @@ void JitArm64::Jit(u32) int block_num = blocks.AllocateBlock(em_address); JitBlock* b = blocks.GetBlock(block_num); const u8* BlockPtr = DoJit(em_address, &code_buffer, b, nextPC); - blocks.FinalizeBlock(block_num, jo.enableBlocklink, BlockPtr); + blocks.FinalizeBlock(*b, jo.enableBlocklink, BlockPtr); } const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock* b, u32 nextPC) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index 1a1fe03556..869ebb4374 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -131,9 +131,8 @@ int JitBaseBlockCache::AllocateBlock(u32 em_address) return num_blocks - 1; } -void JitBaseBlockCache::FinalizeBlock(int block_num, bool block_link, const u8* code_ptr) +void JitBaseBlockCache::FinalizeBlock(JitBlock& b, bool block_link, const u8* code_ptr) { - JitBlock& b = blocks[block_num]; if (start_block_map.count(b.physicalAddress)) { // We already have a block at this address; invalidate the old block. @@ -146,6 +145,7 @@ void JitBaseBlockCache::FinalizeBlock(int block_num, bool block_link, const u8* std::make_pair(old_b.physicalAddress + 4 * old_b.originalSize - 1, old_b.physicalAddress)); DestroyBlock(old_b, true); } + const int block_num = static_cast(&b - &blocks[0]); start_block_map[b.physicalAddress] = block_num; FastLookupEntryForAddress(b.effectiveAddress) = block_num; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.h b/Source/Core/Core/PowerPC/JitCommon/JitCache.h index a79ce53c9f..446aaa70e6 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.h @@ -132,7 +132,7 @@ public: int* GetICache(); int AllocateBlock(u32 em_address); - void FinalizeBlock(int block_num, bool block_link, const u8* code_ptr); + void FinalizeBlock(JitBlock& b, bool block_link, const u8* code_ptr); // Look for the block in the slow but accurate way. // This function shall be used if FastLookupEntryForAddress() failed.