1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:18:11 +00:00

UserspaceEmulator: Cache the region we're executing code from

Instead of caching a raw pointer to the next instruction, cache the
region we're fetching instructions from, and a pointer to its base.
This way we don't need to keep invalidating and reloading the cache
whenever the CPU jumps.
This commit is contained in:
Andreas Kling 2020-11-16 13:54:00 +01:00
parent b4ff85f138
commit d14695f823
2 changed files with 15 additions and 18 deletions

View file

@ -140,8 +140,9 @@ void SoftCPU::update_code_cache()
TODO();
}
m_cached_code_ptr = region->cacheable_ptr(eip() - region->base());
m_cached_code_end = region->cacheable_ptr(region->size());
// FIXME: This cache needs to be invalidated if the code region is ever unmapped.
m_cached_code_region = region;
m_cached_code_base_ptr = region->data();
}
ValueWithShadow<u8> SoftCPU::read_memory8(X86::LogicalAddress address)