mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 11:00:19 +02:00
ARM64EC: Implement call-ret stack management
This commit is contained in:
1 parent
132de3160a
commit
2f16d25ab8
1 file changed
+8
@@ -27,6 +27,7 @@ $end_info$
|
||||
#include <FEXCore/Utils/SignalScopeGuards.h>
|
||||
|
||||
#include "Common/ArgumentLoader.h"
|
||||
#include "Common/CallRetStack.h"
|
||||
#include "Common/Config.h"
|
||||
#include "Common/Exception.h"
|
||||
#include "Common/InvalidationTracker.h"
|
||||
@@ -705,6 +706,10 @@ bool ResetToConsistentStateImpl(EXCEPTION_RECORD* Exception, CONTEXT* GuestConte
|
||||
if (Exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
|
||||
const auto FaultAddress = static_cast<uint64_t>(Exception->ExceptionInformation[1]);
|
||||
|
||||
if (FEX::Windows::CallRetStack::HandleAccessViolation(Thread, FaultAddress, NativeContext->X17)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::scoped_lock Lock(ThreadCreationMutex);
|
||||
if (InvalidationTracker && InvalidationTracker->HandleRWXAccessViolation(FaultAddress)) {
|
||||
FEXCORE_PROFILE_INSTANT_INCREMENT(Thread, AccumulatedSMCCount, 1);
|
||||
@@ -899,6 +904,8 @@ NTSTATUS ThreadInit() {
|
||||
const auto CPUArea = GetCPUArea();
|
||||
|
||||
auto* Thread = CTX->CreateThread(0, 0);
|
||||
|
||||
FEX::Windows::CallRetStack::InitializeThread(Thread);
|
||||
Thread->CurrentFrame->Pointers.Common.ExitFunctionEC = reinterpret_cast<uintptr_t>(&ExitFunctionEC);
|
||||
CPUArea.StateFrame() = Thread->CurrentFrame;
|
||||
|
||||
@@ -957,6 +964,7 @@ NTSTATUS ThreadTerm(HANDLE Thread, LONG ExitCode) {
|
||||
}
|
||||
}
|
||||
|
||||
FEX::Windows::CallRetStack::DestroyThread(OldThreadState);
|
||||
CTX->DestroyThread(OldThreadState);
|
||||
::VirtualFree(reinterpret_cast<void*>(CPUArea.EmulatorStackLimit()), 0, MEM_RELEASE);
|
||||
if (ThreadTID == GetCurrentThreadId()) {
|
||||
|
||||
Reference in new issue
Block a user