Arm64EC: Invert suspend doorbell and move out of hot path

This was causing a surprisingly high amount of branch mispredicts in
Death Stranding. Suspend doorbell is fairly rare so just invert the
check and move the target down out of the hot path. Then the doorbell
handling code will trampoline to the correct location still.
This commit is contained in:
Ryan Houdek committed 2026-04-03 20:07:37 -07:00
1 parent c6d2ce043f
commit db4867839c
2 files changed
+11 -7

No files matched your search

+2 -1
View File
@@ -69,6 +69,7 @@ extern IMAGE_DOS_HEADER __ImageBase; // Provided by the linker
extern void* ExitFunctionEC;
extern void* CheckCall;
extern void* ExitFunctionSuspendPoint;
extern void* ExitFunctionSuspendResumePoint;
void* X64ReturnInstr; // See Module.S
uintptr_t NtDllBase;
@@ -676,7 +677,7 @@ bool ResetToConsistentStateImpl(const ThreadCPUArea CPUArea, EXCEPTION_RECORD* E
// A suspend interrupt can occur in ExitFunctionEC before InSimulation is unset and set SuspendDoorbell. If this
// occurs then it is still our duty to cooperatively suspend with an appropriate context. To support this, after
// unsetting InSimulation a brk #0xCAFE instruction will be raised that we can handle here.
NativeContext->Pc += 4; // Skip over the brk instruction when we resume
NativeContext->Pc = reinterpret_cast<uintptr_t>(ExitFunctionSuspendResumePoint); // Jump to the suspend resume point.
*CPUArea.Area->SuspendDoorbell = 0;
return true;
}