mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-08 00:00:16 +02:00
Lots going on here. This moves OS thread object lifetime management and internal thread state lifetime management to the frontend. This causes a bunch of thread handling to move from the FEXCore Context to the frontend. Looking at `FEXCore/include/FEXCore/Core/Context.h` really shows how much of the API has moved to the frontend that FEXCore no longer needs to manage. Primarily this makes FEXCore itself no longer need to care about most of the management of the emulation state. A large amount of the behaviour moved wholesale from Core.cpp to LinuxEmulation's ThreadManager.cpp. Which this manages the lifetimes of both the OS threads and the FEXCore thread state objects. One feature lost was the instruction capability, but this was already buggy and is going to be rewritten/fixed when gdbserver work continues. Now that all of this management is moved to the frontend, the gdbserver can start improving since it can start managing all thread state directly.
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#include "Interface/Context/Context.h"
|
|
#include "Interface/Core/OpcodeDispatcher.h"
|
|
#include "Interface/Core/X86Tables/X86Tables.h"
|
|
|
|
#include <FEXCore/Core/CoreState.h>
|
|
#include <FEXCore/Core/Context.h>
|
|
#include <FEXCore/Core/CPUID.h>
|
|
#include <FEXCore/Core/SignalDelegator.h>
|
|
#include "FEXCore/Debug/InternalThreadState.h"
|
|
|
|
#include <string.h>
|
|
#include <utility>
|
|
|
|
namespace FEXCore::HLE {
|
|
class SyscallVisitor;
|
|
}
|
|
|
|
namespace FEXCore::Context {
|
|
void InitializeStaticTables(OperatingMode Mode) {
|
|
X86Tables::InitializeInfoTables(Mode);
|
|
IR::InstallOpcodeHandlers(Mode);
|
|
}
|
|
|
|
fextl::unique_ptr<FEXCore::Context::Context> FEXCore::Context::Context::CreateNewContext() {
|
|
return fextl::make_unique<FEXCore::Context::ContextImpl>();
|
|
}
|
|
|
|
void FEXCore::Context::ContextImpl::SetExitHandler(ExitHandler handler) {
|
|
CustomExitHandler = std::move(handler);
|
|
}
|
|
|
|
ExitHandler FEXCore::Context::ContextImpl::GetExitHandler() const {
|
|
return CustomExitHandler;
|
|
}
|
|
|
|
void FEXCore::Context::ContextImpl::CompileRIP(FEXCore::Core::InternalThreadState *Thread, uint64_t GuestRIP) {
|
|
CompileBlock(Thread->CurrentFrame, GuestRIP);
|
|
}
|
|
|
|
void FEXCore::Context::ContextImpl::CompileRIPCount(FEXCore::Core::InternalThreadState *Thread, uint64_t GuestRIP, uint64_t MaxInst) {
|
|
CompileBlock(Thread->CurrentFrame, GuestRIP, MaxInst);
|
|
}
|
|
|
|
void FEXCore::Context::ContextImpl::SetCustomCPUBackendFactory(CustomCPUFactoryType Factory) {
|
|
CustomCPUFactory = std::move(Factory);
|
|
}
|
|
|
|
HostFeatures FEXCore::Context::ContextImpl::GetHostFeatures() const {
|
|
return HostFeatures;
|
|
}
|
|
|
|
void FEXCore::Context::ContextImpl::SetSignalDelegator(FEXCore::SignalDelegator *_SignalDelegation) {
|
|
SignalDelegation = _SignalDelegation;
|
|
}
|
|
|
|
void FEXCore::Context::ContextImpl::SetSyscallHandler(FEXCore::HLE::SyscallHandler *Handler) {
|
|
SyscallHandler = Handler;
|
|
SourcecodeResolver = Handler->GetSourcecodeResolver();
|
|
}
|
|
|
|
FEXCore::CPUID::FunctionResults FEXCore::Context::ContextImpl::RunCPUIDFunction(uint32_t Function, uint32_t Leaf) {
|
|
return CPUID.RunFunction(Function, Leaf);
|
|
}
|
|
|
|
FEXCore::CPUID::XCRResults FEXCore::Context::ContextImpl::RunXCRFunction(uint32_t Function) {
|
|
return CPUID.RunXCRFunction(Function);
|
|
}
|
|
|
|
FEXCore::CPUID::FunctionResults FEXCore::Context::ContextImpl::RunCPUIDFunctionName(uint32_t Function, uint32_t Leaf, uint32_t CPU) {
|
|
return CPUID.RunFunctionName(Function, Leaf, CPU);
|
|
}
|
|
}
|