Avoid copying code when hashing block.

This commit is contained in:
Jean-Philip Desjardins 2024-04-29 14:51:51 -04:00
parent bf706f88e6
commit 727ab7927b
3 changed files with 10 additions and 15 deletions

View file

@ -49,6 +49,11 @@ const CMemoryMap::MEMORYMAPELEMENT* CMemoryMap::GetWriteMap(uint32 address) cons
return GetMap(m_writeMap, address);
}
const CMemoryMap::MEMORYMAPELEMENT* CMemoryMap::GetInstructionMap(uint32 address) const
{
return GetMap(m_instructionMap, address);
}
void CMemoryMap::InsertMap(MemoryMapListType& memoryMap, uint32 start, uint32 end, void* pointer, unsigned char key)
{
MEMORYMAPELEMENT element;

View file

@ -47,6 +47,7 @@ public:
const MemoryMapListType& GetInstructionMaps();
const MEMORYMAPELEMENT* GetReadMap(uint32) const;
const MEMORYMAPELEMENT* GetWriteMap(uint32) const;
const MEMORYMAPELEMENT* GetInstructionMap(uint32) const;
protected:
static const MEMORYMAPELEMENT* GetMap(const MemoryMapListType&, uint32);

View file

@ -18,22 +18,11 @@ BasicBlockPtr CVuExecutor::BlockFactory(CMIPS& context, uint32 begin, uint32 end
{
uint32 blockSize = ((end - begin) + 4) / 4;
uint32 blockSizeByte = blockSize * 4;
uint32* blockMemory = reinterpret_cast<uint32*>(alloca(blockSizeByte));
for(uint32 address = begin; address <= end; address += 8)
{
uint32 index = (address - begin) / 4;
uint32 addressLo = address + 0;
uint32 addressHi = address + 4;
uint32 opcodeLo = m_context.m_pMemoryMap->GetInstruction(addressLo);
uint32 opcodeHi = m_context.m_pMemoryMap->GetInstruction(addressHi);
assert((index + 0) < blockSize);
blockMemory[index + 0] = opcodeLo;
assert((index + 1) < blockSize);
blockMemory[index + 1] = opcodeHi;
}
auto map = m_context.m_pMemoryMap->GetInstructionMap(begin);
assert(m_context.m_pMemoryMap->GetInstructionMap(end) == map);
uint32 localBegin = begin - map->nStart;
auto blockMemory = reinterpret_cast<const uint32*>(reinterpret_cast<uint8*>(map->pPointer) + localBegin);
auto xxHash = XXH3_128bits(blockMemory, blockSizeByte);
uint128 hash;