mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 19:45:33 +00:00
CPU/CodeCache: Only reset used portion of buffer
Saves writing 48MB every reset.
This commit is contained in:
parent
050bda8cd2
commit
1d138da3ff
@ -1432,6 +1432,25 @@ void CPU::CodeCache::UnlinkBlockExits(Block* block)
|
|||||||
|
|
||||||
void CPU::CodeCache::ResetCodeBuffer()
|
void CPU::CodeCache::ResetCodeBuffer()
|
||||||
{
|
{
|
||||||
|
if (s_code_used > 0 || s_far_code_used > 0)
|
||||||
|
{
|
||||||
|
MemMap::BeginCodeWrite();
|
||||||
|
|
||||||
|
if (s_code_used > 0)
|
||||||
|
{
|
||||||
|
std::memset(s_code_ptr, 0, s_code_used);
|
||||||
|
MemMap::FlushInstructionCache(s_code_ptr, s_code_used);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_far_code_used > 0)
|
||||||
|
{
|
||||||
|
std::memset(s_far_code_ptr, 0, s_far_code_used);
|
||||||
|
MemMap::FlushInstructionCache(s_far_code_ptr, s_far_code_used);
|
||||||
|
}
|
||||||
|
|
||||||
|
MemMap::EndCodeWrite();
|
||||||
|
}
|
||||||
|
|
||||||
s_code_ptr = static_cast<u8*>(s_code_buffer_ptr);
|
s_code_ptr = static_cast<u8*>(s_code_buffer_ptr);
|
||||||
s_free_code_ptr = s_code_ptr;
|
s_free_code_ptr = s_code_ptr;
|
||||||
s_code_size = RECOMPILER_CODE_CACHE_SIZE - RECOMPILER_FAR_CODE_CACHE_SIZE;
|
s_code_size = RECOMPILER_CODE_CACHE_SIZE - RECOMPILER_FAR_CODE_CACHE_SIZE;
|
||||||
@ -1444,13 +1463,6 @@ void CPU::CodeCache::ResetCodeBuffer()
|
|||||||
s_far_code_ptr = (far_code_size > 0) ? (static_cast<u8*>(s_code_ptr) + s_code_size) : nullptr;
|
s_far_code_ptr = (far_code_size > 0) ? (static_cast<u8*>(s_code_ptr) + s_code_size) : nullptr;
|
||||||
s_free_far_code_ptr = s_far_code_ptr;
|
s_free_far_code_ptr = s_far_code_ptr;
|
||||||
s_far_code_used = 0;
|
s_far_code_used = 0;
|
||||||
|
|
||||||
MemMap::BeginCodeWrite();
|
|
||||||
|
|
||||||
std::memset(s_code_ptr, 0, RECOMPILER_CODE_CACHE_SIZE);
|
|
||||||
MemMap::FlushInstructionCache(s_code_ptr, RECOMPILER_CODE_CACHE_SIZE);
|
|
||||||
|
|
||||||
MemMap::EndCodeWrite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* CPU::CodeCache::GetFreeCodePointer()
|
u8* CPU::CodeCache::GetFreeCodePointer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user