Permalink
Browse files

Cleanup GetBlockNumberFromStartAddress

  • Loading branch information...
hrydgard committed Jan 5, 2018
1 parent 468b830 commit d1d01bfdcbb73d2cdc3fa3018c011cdbb48c6c22
Showing with 12 additions and 13 deletions.
  1. +12 −13 Core/MIPS/IR/IRJit.cpp
View
@@ -240,19 +240,18 @@ void IRBlockCache::ComputeStats(BlockCacheStats &bcStats) const {
}
int IRBlockCache::GetBlockNumberFromStartAddress(u32 em_address, bool realBlocksOnly) const {
u32 startPage = AddressToPage(em_address);
u32 endPage = AddressToPage(em_address + 4);
for (u32 page = startPage; page <= endPage; ++page) {
const auto iter = byPage_.find(page);
if (iter == byPage_.end())
continue;
const std::vector<int> &blocksInPage = iter->second;
for (int i : blocksInPage) {
if (blocks_[i].OverlapsRange(em_address, 4)) {
return i;
}
u32 page = AddressToPage(em_address);
const auto iter = byPage_.find(page);
if (iter == byPage_.end())
return -1;
const std::vector<int> &blocksInPage = iter->second;
for (int i : blocksInPage) {
uint32_t start, size;
blocks_[i].GetRange(start, size);
if (start == em_address) {
return i;
}
}
return -1;

0 comments on commit d1d01bf

Please sign in to comment.