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

UserspaceEmulator: Add a fast path for forward REP STOSD

Same as REP STOSB, except for 32-bit fills instead.
This commit is contained in:
Andreas Kling 2020-11-15 18:07:22 +01:00
parent 102e1d330c
commit 6dab0af9af
3 changed files with 43 additions and 1 deletions

View file

@ -259,7 +259,7 @@ bool SoftMMU::fast_fill_memory8(X86::LogicalAddress address, size_t size, ValueW
if (region->is_mmap() && static_cast<const MmapRegion&>(*region).is_malloc_block()) {
if (auto* tracer = Emulator::the().malloc_tracer()) {
// FIXME: Add a way to audit an entire range of memory instead of looping here!
for (size_t i = 0; i < size; i += sizeof(u8)) {
for (size_t i = 0; i < size; ++i) {
tracer->audit_write(address.offset() + (i * sizeof(u8)), sizeof(u8));
}
}
@ -271,4 +271,29 @@ bool SoftMMU::fast_fill_memory8(X86::LogicalAddress address, size_t size, ValueW
return true;
}
bool SoftMMU::fast_fill_memory32(X86::LogicalAddress address, size_t count, ValueWithShadow<u32> value)
{
if (!count)
return true;
auto* region = find_region(address);
if (!region)
return false;
if (!region->contains(address.offset() + (count * sizeof(u32)) - 1))
return false;
if (region->is_mmap() && static_cast<const MmapRegion&>(*region).is_malloc_block()) {
if (auto* tracer = Emulator::the().malloc_tracer()) {
// FIXME: Add a way to audit an entire range of memory instead of looping here!
for (size_t i = 0; i < count; ++i) {
tracer->audit_write(address.offset() + (i * sizeof(u32)), sizeof(u32));
}
}
}
size_t offset_in_region = address.offset() - region->base();
fast_u32_fill((u32*)(region->data() + offset_in_region), value.value(), count);
fast_u32_fill((u32*)(region->shadow_data() + offset_in_region), value.shadow(), count);
return true;
}
}