mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
UserspaceEmulator: Add a fast path for forward REP STOSB
This is used by memset() so we get a lot of mileage out of optimizing this instruction. Note that we currently audit every individual byte accessed separately. This could be greatly improved by adding a range auditing mechanism to MallocTracer.
This commit is contained in:
parent
92e152f11d
commit
102e1d330c
3 changed files with 45 additions and 0 deletions
|
@ -3048,6 +3048,22 @@ void SoftCPU::STI(const X86::Instruction&) { TODO_INSN(); }
|
|||
|
||||
void SoftCPU::STOSB(const X86::Instruction& insn)
|
||||
{
|
||||
if (insn.has_rep_prefix() && !df()) {
|
||||
// Fast path for 8-bit forward memory fill.
|
||||
if (m_emulator.mmu().fast_fill_memory8({ es(), destination_index(insn.a32()).value() }, ecx().value(), al())) {
|
||||
if (insn.a32()) {
|
||||
// FIXME: Should an uninitialized ECX taint EDI here?
|
||||
set_edi({ (u32)(edi().value() + ecx().value()), edi().shadow() });
|
||||
set_ecx(shadow_wrap_as_initialized<u32>(0));
|
||||
} else {
|
||||
// FIXME: Should an uninitialized CX taint DI here?
|
||||
set_di({ (u16)(di().value() + cx().value()), di().shadow() });
|
||||
set_cx(shadow_wrap_as_initialized<u16>(0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
do_once_or_repeat<false>(insn, [&] {
|
||||
write_memory8({ es(), destination_index(insn.a32()).value() }, al());
|
||||
step_destination_index(insn.a32(), 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue