JitCache: Use a pointer in links_to.

This commit is contained in:
degasus 2017-01-11 20:08:45 +01:00
parent 928ccbef53
commit ca026b58ab
2 changed files with 5 additions and 5 deletions

View File

@ -159,7 +159,7 @@ void JitBaseBlockCache::FinalizeBlock(JitBlock& b, bool block_link, const u8* co
{ {
for (const auto& e : b.linkData) for (const auto& e : b.linkData)
{ {
links_to.emplace(e.exitAddress, block_num); links_to.emplace(e.exitAddress, &b);
} }
LinkBlock(b); LinkBlock(b);
@ -295,7 +295,7 @@ void JitBaseBlockCache::LinkBlock(JitBlock& b)
for (auto iter = ppp.first; iter != ppp.second; ++iter) for (auto iter = ppp.first; iter != ppp.second; ++iter)
{ {
JitBlock& b2 = blocks[iter->second]; JitBlock& b2 = *iter->second;
if (b.msrBits == b2.msrBits) if (b.msrBits == b2.msrBits)
LinkBlockExits(b2); LinkBlockExits(b2);
} }
@ -307,7 +307,7 @@ void JitBaseBlockCache::UnlinkBlock(const JitBlock& b)
for (auto iter = ppp.first; iter != ppp.second; ++iter) for (auto iter = ppp.first; iter != ppp.second; ++iter)
{ {
JitBlock& sourceBlock = blocks[iter->second]; JitBlock& sourceBlock = *iter->second;
if (sourceBlock.msrBits != b.msrBits) if (sourceBlock.msrBits != b.msrBits)
continue; continue;
@ -340,7 +340,7 @@ void JitBaseBlockCache::DestroyBlock(JitBlock& b, bool invalidate)
auto it = links_to.equal_range(b.effectiveAddress); auto it = links_to.equal_range(b.effectiveAddress);
while (it.first != it.second) while (it.first != it.second)
{ {
if (it.first->second == &b - &blocks[0]) if (it.first->second == &b)
it.first = links_to.erase(it.first); it.first = links_to.erase(it.first);
else else
it.first++; it.first++;

View File

@ -173,7 +173,7 @@ private:
// links_to hold all exit points of all valid blocks in a reverse way. // 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. // It is used to query all blocks which links to an address.
std::multimap<u32, int> links_to; // destination_PC -> number std::multimap<u32, JitBlock*> links_to; // destination_PC -> number
// Map indexed by the physical memory location. // Map indexed by the physical memory location.
// It is used to invalidate blocks based on memory location. // It is used to invalidate blocks based on memory location.