Skip to content

Commit

Permalink
Make block invalidation a bit faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed Jan 5, 2024
1 parent dec00b5 commit 70c1bdc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Source/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef std::multimap<uint32, BLOCK_OUT_LINK> BlockOutLinkMap;
//to their outgoing link definitions inside the map
typedef BlockOutLinkMap::iterator BlockOutLinkPointer;

class CBasicBlock
class CBasicBlock : public std::enable_shared_from_this<CBasicBlock>
{
public:
CBasicBlock(CMIPS&, uint32 = MIPS_INVALID_PC, uint32 = MIPS_INVALID_PC, BLOCK_CATEGORY = BLOCK_CATEGORY_UNKNOWN);
Expand Down
12 changes: 6 additions & 6 deletions Source/GenericMipsExecutor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <list>
#include <unordered_set>
#include "MIPS.h"
#include "BasicBlock.h"

Expand Down Expand Up @@ -125,7 +125,7 @@ class CGenericMipsExecutor : public CMipsExecutor
#endif

protected:
typedef std::list<BasicBlockPtr> BlockList;
typedef std::unordered_set<BasicBlockPtr> BlockStore;

bool HasBlockAt(uint32 address) const
{
Expand All @@ -139,7 +139,7 @@ class CGenericMipsExecutor : public CMipsExecutor
auto block = BlockFactory(m_context, start, end);
ResetBlockOutLinks(block.get());
m_blockLookup.AddBlock(block.get());
m_blocks.push_back(std::move(block));
m_blocks.insert(std::move(block));
}

void ResetBlockOutLinks(CBasicBlock* block)
Expand Down Expand Up @@ -311,13 +311,13 @@ class CGenericMipsExecutor : public CMipsExecutor
}
}

if(!clearedBlocks.empty())
for(auto* clearedBlock : clearedBlocks)
{
m_blocks.remove_if([&](const BasicBlockPtr& block) { return clearedBlocks.find(block.get()) != std::end(clearedBlocks); });
m_blocks.erase(clearedBlock->shared_from_this());
}
}

BlockList m_blocks;
BlockStore m_blocks;
BasicBlockPtr m_emptyBlock;
BlockOutLinkMap m_blockOutLinks;
CMIPS& m_context;
Expand Down

0 comments on commit 70c1bdc

Please sign in to comment.