Convert a ton of things over to fextl

This commit is contained in:
Ryan Houdek committed 2023-03-30 16:28:33 -07:00
1 parent 465ecd9b19
commit 1eb36b8b31
56 files changed
+273 -175

No files matched your search

+6 -4
View File
@@ -1,5 +1,7 @@
#include "Common/Paths.h"
#include <FEXCore/Utils/Allocator.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <cstdlib>
@@ -10,8 +12,8 @@
#include <unistd.h>
namespace FEXCore::Paths {
std::unique_ptr<fextl::string> CachePath;
std::unique_ptr<fextl::string> EntryCache;
fextl::unique_ptr<fextl::string> CachePath;
fextl::unique_ptr<fextl::string> EntryCache;
char const* FindUserHomeThroughUID() {
auto passwd = getpwuid(geteuid());
@@ -43,8 +45,8 @@ namespace FEXCore::Paths {
}
void InitializePaths() {
CachePath = std::make_unique<fextl::string>();
EntryCache = std::make_unique<fextl::string>();
CachePath = fextl::make_unique<fextl::string>();
EntryCache = fextl::make_unique<fextl::string>();
char const *HomeDir = getenv("HOME");
+17 -16
View File
@@ -9,6 +9,7 @@
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/fextl/list.h>
#include <FEXCore/fextl/map.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/unordered_map.h>
#include <FEXCore/fextl/vector.h>
@@ -19,7 +20,6 @@
#include <filesystem>
#include <fstream>
#include <functional>
#include <memory>
#include <optional>
#include <stddef.h>
#include <stdint.h>
@@ -46,13 +46,13 @@ namespace DefaultValues {
namespace JSON {
struct JsonAllocator {
jsonPool_t PoolObject;
std::unique_ptr<fextl::list<json_t>> json_objects;
fextl::unique_ptr<fextl::list<json_t>> json_objects;
};
static_assert(offsetof(JsonAllocator, PoolObject) == 0, "This needs to be at offset zero");
json_t* PoolInit(jsonPool_t* Pool) {
JsonAllocator* alloc = reinterpret_cast<JsonAllocator*>(Pool);
alloc->json_objects = std::make_unique<fextl::list<json_t>>();
alloc->json_objects = fextl::make_unique<fextl::list<json_t>>();
return &*alloc->json_objects->emplace(alloc->json_objects->end());
}
@@ -213,7 +213,7 @@ namespace JSON {
return 0;
}
static fextl::map<FEXCore::Config::LayerType, std::unique_ptr<FEXCore::Config::Layer>> ConfigLayers;
static fextl::map<FEXCore::Config::LayerType, fextl::unique_ptr<FEXCore::Config::Layer>> ConfigLayers;
static FEXCore::Config::Layer *Meta{};
constexpr std::array<FEXCore::Config::LayerType, 9> LoadOrder = {
@@ -316,7 +316,7 @@ namespace JSON {
}
void Initialize() {
AddLayer(std::make_unique<MetaLayer>(FEXCore::Config::LayerType::LAYER_TOP));
AddLayer(fextl::make_unique<MetaLayer>(FEXCore::Config::LayerType::LAYER_TOP));
Meta = ConfigLayers.begin()->second.get();
}
@@ -339,6 +339,7 @@ namespace JSON {
return {};
}
std::filesystem::path Path{PathName};
// Expand home if it exists
@@ -479,7 +480,7 @@ namespace JSON {
if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_ROOTFS)) {
FEX_CONFIG_OPT(PathName, ROOTFS);
auto ExpandedString = ExpandPath(ContainerPrefix, PathName());
auto ExpandedString = ExpandPath(ContainerPrefix,PathName());
if (!ExpandedString.empty()) {
// Adjust the path if it ended up being relative
FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_ROOTFS, ExpandedString);
@@ -530,7 +531,7 @@ namespace JSON {
}
}
void AddLayer(std::unique_ptr<FEXCore::Config::Layer> _Layer) {
void AddLayer(fextl::unique_ptr<FEXCore::Config::Layer> _Layer) {
ConfigLayers.emplace(_Layer->GetLayerType(), std::move(_Layer));
}
@@ -758,25 +759,25 @@ namespace JSON {
}
}
std::unique_ptr<FEXCore::Config::Layer> CreateGlobalMainLayer() {
return std::make_unique<FEXCore::Config::MainLoader>(FEXCore::Config::LayerType::LAYER_GLOBAL_MAIN);
fextl::unique_ptr<FEXCore::Config::Layer> CreateGlobalMainLayer() {
return fextl::make_unique<FEXCore::Config::MainLoader>(FEXCore::Config::LayerType::LAYER_GLOBAL_MAIN);
}
std::unique_ptr<FEXCore::Config::Layer> CreateMainLayer(fextl::string const *File) {
fextl::unique_ptr<FEXCore::Config::Layer> CreateMainLayer(fextl::string const *File) {
if (File) {
return std::make_unique<FEXCore::Config::MainLoader>(*File);
return fextl::make_unique<FEXCore::Config::MainLoader>(*File);
}
else {
return std::make_unique<FEXCore::Config::MainLoader>(FEXCore::Config::LayerType::LAYER_MAIN);
return fextl::make_unique<FEXCore::Config::MainLoader>(FEXCore::Config::LayerType::LAYER_MAIN);
}
}
std::unique_ptr<FEXCore::Config::Layer> CreateAppLayer(const fextl::string& Filename, FEXCore::Config::LayerType Type) {
return std::make_unique<FEXCore::Config::AppLoader>(Filename, Type);
fextl::unique_ptr<FEXCore::Config::Layer> CreateAppLayer(const fextl::string& Filename, FEXCore::Config::LayerType Type) {
return fextl::make_unique<FEXCore::Config::AppLoader>(Filename, Type);
}
std::unique_ptr<FEXCore::Config::Layer> CreateEnvironmentLayer(char *const _envp[]) {
return std::make_unique<FEXCore::Config::EnvLoader>(_envp);
fextl::unique_ptr<FEXCore::Config::Layer> CreateEnvironmentLayer(char *const _envp[]) {
return fextl::make_unique<FEXCore::Config::EnvLoader>(_envp);
}
}
+14 -5
View File
@@ -15,6 +15,7 @@
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/Utils/CompilerDefs.h>
#include <FEXCore/Utils/Event.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/set.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/unordered_map.h>
@@ -71,6 +72,14 @@ namespace FEXCore::Context {
class ContextImpl final : public FEXCore::Context::Context {
public:
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
// Context base class implementation.
bool InitializeContext() override;
@@ -261,14 +270,14 @@ namespace FEXCore::Context {
FEXCore::CPUIDEmu CPUID;
FEXCore::HLE::SyscallHandler *SyscallHandler{};
FEXCore::HLE::SourcecodeResolver *SourcecodeResolver{};
std::unique_ptr<FEXCore::ThunkHandler> ThunkHandler;
std::unique_ptr<FEXCore::CPU::Dispatcher> Dispatcher;
fextl::unique_ptr<FEXCore::ThunkHandler> ThunkHandler;
fextl::unique_ptr<FEXCore::CPU::Dispatcher> Dispatcher;
CustomCPUFactoryType CustomCPUFactory;
FEXCore::Context::ExitHandler CustomExitHandler;
#ifdef BLOCKSTATS
std::unique_ptr<FEXCore::BlockSamplingData> BlockData;
fextl::unique_ptr<FEXCore::BlockSamplingData> BlockData;
#endif
SignalDelegator *SignalDelegation{};
@@ -405,10 +414,10 @@ namespace FEXCore::Context {
// Entry Cache
std::mutex ExitMutex;
std::unique_ptr<GdbServer> DebugServer;
fextl::unique_ptr<GdbServer> DebugServer;
IR::AOTIRCaptureCache IRCaptureCache;
std::unique_ptr<FEXCore::CodeSerialize::CodeObjectSerializeService> CodeObjectCacheService;
fextl::unique_ptr<FEXCore::CodeSerialize::CodeObjectSerializeService> CodeObjectCacheService;
bool StartPaused = false;
bool IsMemoryShared = false;
+8 -8
View File
@@ -45,6 +45,7 @@ $end_info$
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/Utils/Threads.h>
#include <FEXCore/Utils/Profiler.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/set.h>
#include <FEXCore/fextl/sstream.h>
#include <FEXCore/fextl/vector.h>
@@ -59,7 +60,6 @@ $end_info$
#include <filesystem>
#include <functional>
#include <fstream>
#include <memory>
#include <mutex>
#include <queue>
#include <shared_mutex>
@@ -151,7 +151,7 @@ namespace FEXCore::Context {
BlockData = std::make_unique<FEXCore::BlockSamplingData>();
#endif
if (Config.CacheObjectCodeCompilation() != FEXCore::Config::ConfigObjectCodeHandler::CONFIG_NONE) {
CodeObjectCacheService = std::make_unique<FEXCore::CodeSerialize::CodeObjectSerializeService>(this);
CodeObjectCacheService = fextl::make_unique<FEXCore::CodeSerialize::CodeObjectSerializeService>(this);
}
if (!Config.EnableAVX) {
HostFeatures.SupportsAVX = false;
@@ -275,7 +275,7 @@ namespace FEXCore::Context {
StopGdbServer();
}
ThunkHandler.reset(FEXCore::ThunkHandler::Create());
ThunkHandler = FEXCore::ThunkHandler::Create();
using namespace FEXCore::Core;
@@ -295,7 +295,7 @@ namespace FEXCore::Context {
void ContextImpl::StartGdbServer() {
if (!DebugServer) {
DebugServer = std::make_unique<GdbServer>(this);
DebugServer = fextl::make_unique<GdbServer>(this);
StartPaused = true;
}
}
@@ -557,11 +557,11 @@ namespace FEXCore::Context {
}
void ContextImpl::InitializeCompiler(FEXCore::Core::InternalThreadState* Thread) {
Thread->OpDispatcher = std::make_unique<FEXCore::IR::OpDispatchBuilder>(this);
Thread->OpDispatcher = fextl::make_unique<FEXCore::IR::OpDispatchBuilder>(this);
Thread->OpDispatcher->SetMultiblock(Config.Multiblock);
Thread->LookupCache = std::make_unique<FEXCore::LookupCache>(this);
Thread->FrontendDecoder = std::make_unique<FEXCore::Frontend::Decoder>(this);
Thread->PassManager = std::make_unique<FEXCore::IR::PassManager>();
Thread->LookupCache = fextl::make_unique<FEXCore::LookupCache>(this);
Thread->FrontendDecoder = fextl::make_unique<FEXCore::Frontend::Decoder>(this);
Thread->PassManager = fextl::make_unique<FEXCore::IR::PassManager>();
Thread->PassManager->RegisterExitHandler([this]() {
Stop(false /* Ignore current thread */);
});
@@ -12,6 +12,7 @@
#include <FEXCore/Core/CoreState.h>
#include <FEXCore/Core/X86Enums.h>
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/fextl/memory.h>
#include <FEXHeaderUtils/Syscalls.h>
#include <array>
@@ -672,8 +673,8 @@ void Arm64Dispatcher::InitThreadPointers(FEXCore::Core::InternalThreadState *Thr
}
}
std::unique_ptr<Dispatcher> Dispatcher::CreateArm64(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config) {
return std::make_unique<Arm64Dispatcher>(CTX, Config);
fextl::unique_ptr<Dispatcher> Dispatcher::CreateArm64(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config) {
return fextl::make_unique<Arm64Dispatcher>(CTX, Config);
}
}
@@ -1,6 +1,7 @@
#pragma once
#include <FEXCore/Core/CPUBackend.h>
#include <FEXCore/fextl/memory.h>
#include "Interface/Core/ArchHelpers/MContext.h"
#include <cstdint>
@@ -73,8 +74,8 @@ public:
virtual size_t GenerateGDBPauseCheck(uint8_t *CodeBuffer, uint64_t GuestRIP) = 0;
virtual size_t GenerateInterpreterTrampoline(uint8_t *CodeBuffer) = 0;
static std::unique_ptr<Dispatcher> CreateX86(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config);
static std::unique_ptr<Dispatcher> CreateArm64(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config);
static fextl::unique_ptr<Dispatcher> CreateX86(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config);
static fextl::unique_ptr<Dispatcher> CreateArm64(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config);
virtual void ExecuteDispatch(FEXCore::Core::CpuStateFrame *Frame) {
DispatchPtr(Frame);
@@ -11,6 +11,7 @@
#include <FEXCore/Core/CPUBackend.h>
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/Utils/Allocator.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <FEXHeaderUtils/Syscalls.h>
@@ -500,8 +501,8 @@ void X86Dispatcher::InitThreadPointers(FEXCore::Core::InternalThreadState *Threa
}
}
std::unique_ptr<Dispatcher> Dispatcher::CreateX86(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config) {
return std::make_unique<X86Dispatcher>(CTX, Config);
fextl::unique_ptr<Dispatcher> Dispatcher::CreateX86(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config) {
return fextl::make_unique<X86Dispatcher>(CTX, Config);
}
}
@@ -10,8 +10,8 @@
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/Utils/MathUtils.h>
#include <FEXCore/fextl/memory.h>
#include <memory>
#include <signal.h>
#include <stdint.h>
#include <utility>
@@ -103,8 +103,8 @@ void InterpreterCore::ClearCache() {
BufferUsed = 0;
}
std::unique_ptr<CPUBackend> CreateInterpreterCore(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::InternalThreadState *Thread) {
return std::make_unique<InterpreterCore>(ctx->Dispatcher.get(), Thread);
fextl::unique_ptr<CPUBackend> CreateInterpreterCore(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::InternalThreadState *Thread) {
return fextl::make_unique<InterpreterCore>(ctx->Dispatcher.get(), Thread);
}
void InitializeInterpreterSignalHandlers(FEXCore::Context::ContextImpl *CTX) {
@@ -1,6 +1,7 @@
#pragma once
#include <memory>
#include <FEXCore/Core/CPUBackend.h>
#include <FEXCore/fextl/memory.h>
namespace FEXCore::Context {
class ContextImpl;
@@ -14,7 +15,7 @@ namespace FEXCore::CPU {
class CPUBackend;
struct DispatcherConfig;
[[nodiscard]] std::unique_ptr<CPUBackend> CreateInterpreterCore(FEXCore::Context::ContextImpl *ctx,
[[nodiscard]] fextl::unique_ptr<CPUBackend> CreateInterpreterCore(FEXCore::Context::ContextImpl *ctx,
FEXCore::Core::InternalThreadState *Thread);
void InitializeInterpreterSignalHandlers(FEXCore::Context::ContextImpl *CTX);
CPUBackendFeatures GetInterpreterBackendFeatures();
+2 -2
View File
@@ -1087,8 +1087,8 @@ void Arm64JITCore::ResetStack() {
}
}
std::unique_ptr<CPUBackend> CreateArm64JITCore(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::InternalThreadState *Thread) {
return std::make_unique<Arm64JITCore>(ctx, Thread);
fextl::unique_ptr<CPUBackend> CreateArm64JITCore(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::InternalThreadState *Thread) {
return fextl::make_unique<Arm64JITCore>(ctx, Thread);
}
void InitializeArm64JITSignalHandlers(FEXCore::Context::ContextImpl *CTX) {
+4 -3
View File
@@ -1,6 +1,7 @@
#pragma once
#include <memory>
#include <FEXCore/Core/CPUBackend.h>
#include <FEXCore/fextl/memory.h>
namespace FEXCore::Context {
class ContextImpl;
@@ -13,12 +14,12 @@ struct InternalThreadState;
namespace FEXCore::CPU {
class CPUBackend;
[[nodiscard]] std::unique_ptr<CPUBackend> CreateX86JITCore(FEXCore::Context::ContextImpl *ctx,
[[nodiscard]] fextl::unique_ptr<CPUBackend> CreateX86JITCore(FEXCore::Context::ContextImpl *ctx,
FEXCore::Core::InternalThreadState *Thread);
void InitializeX86JITSignalHandlers(FEXCore::Context::ContextImpl *CTX);
CPUBackendFeatures GetX86JITBackendFeatures();
[[nodiscard]] std::unique_ptr<CPUBackend> CreateArm64JITCore(FEXCore::Context::ContextImpl *ctx,
[[nodiscard]] fextl::unique_ptr<CPUBackend> CreateArm64JITCore(FEXCore::Context::ContextImpl *ctx,
FEXCore::Core::InternalThreadState *Thread);
void InitializeArm64JITSignalHandlers(FEXCore::Context::ContextImpl *CTX);
CPUBackendFeatures GetArm64JITBackendFeatures();
+2 -2
View File
@@ -788,8 +788,8 @@ CPUBackend::CompiledCode X86JITCore::CompileCode(uint64_t Entry, [[maybe_unused]
return CodeData;
}
std::unique_ptr<CPUBackend> CreateX86JITCore(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::InternalThreadState *Thread) {
return std::make_unique<X86JITCore>(ctx, Thread);
fextl::unique_ptr<CPUBackend> CreateX86JITCore(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::InternalThreadState *Thread) {
return fextl::make_unique<X86JITCore>(ctx, Thread);
}
CPUBackendFeatures GetX86JITBackendFeatures() {
@@ -8,12 +8,12 @@
#include <FEXCore/Utils/Threads.h>
#include <FEXCore/fextl/map.h>
#include <FEXCore/fextl/queue.h>
#include <FEXCore/fextl/robin_map.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/vector.h>
#include <memory>
#include <shared_mutex>
#include <tsl/robin_map.h>
namespace FEXCore::CodeSerialize {
// XXX: Does this need to be signal safe?
@@ -111,7 +111,7 @@ namespace FEXCore::CodeSerialize {
// This per section map takes the most time to load and needs to be quick
// This is the map of all code segments for this entry
tsl::robin_map<uint64_t, CodeObjectFileSection*> SectionLookupMap{};
fextl::robin_map<uint64_t, CodeObjectFileSection*> SectionLookupMap{};
/** @} */
// Default initialization
+2 -2
View File
@@ -355,8 +355,8 @@ namespace FEXCore {
}
};
ThunkHandler* ThunkHandler::Create() {
return new ThunkHandler_impl();
fextl::unique_ptr<ThunkHandler> ThunkHandler::Create() {
return fextl::make_unique<ThunkHandler_impl>();
}
/**
+6 -5
View File
@@ -7,6 +7,7 @@ $end_info$
#pragma once
#include <FEXCore/IR/IR.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/vector.h>
namespace FEXCore::Context {
@@ -26,12 +27,12 @@ namespace FEXCore {
class ThunkHandler {
public:
virtual ThunkedFunction* LookupThunk(const IR::SHA256Sum &sha256) = 0;
virtual void RegisterTLSState(FEXCore::Core::InternalThreadState *Thread) = 0;
virtual ~ThunkHandler() { }
virtual ThunkedFunction* LookupThunk(const IR::SHA256Sum &sha256) = 0;
virtual void RegisterTLSState(FEXCore::Core::InternalThreadState *Thread) = 0;
virtual ~ThunkHandler() { }
static ThunkHandler* Create();
static fextl::unique_ptr<ThunkHandler> Create();
virtual void AppendThunkDefinitions(fextl::vector<FEXCore::IR::ThunkDefinition> const& Definitions) = 0;
virtual void AppendThunkDefinitions(fextl::vector<FEXCore::IR::ThunkDefinition> const& Definitions) = 0;
};
};
+5 -5
View File
@@ -8,12 +8,12 @@ $end_info$
#include <FEXCore/Config/Config.h>
#include <FEXCore/Utils/ThreadPoolAllocator.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/unordered_map.h>
#include <FEXCore/fextl/vector.h>
#include <functional>
#include <memory>
#include <utility>
namespace FEXCore::Context {
@@ -48,7 +48,7 @@ class PassManager final {
public:
void AddDefaultPasses(FEXCore::Context::ContextImpl *ctx, bool InlineConstants, bool StaticRegisterAllocation);
void AddDefaultValidationPasses();
Pass* InsertPass(std::unique_ptr<Pass> Pass, fextl::string Name = "") {
Pass* InsertPass(fextl::unique_ptr<Pass> Pass, fextl::string Name = "") {
Pass->RegisterPassManager(this);
auto PassPtr = Passes.emplace_back(std::move(Pass)).get();
@@ -88,12 +88,12 @@ protected:
FEXCore::HLE::SyscallHandler *SyscallHandler;
private:
fextl::vector<std::unique_ptr<Pass>> Passes;
fextl::vector<fextl::unique_ptr<Pass>> Passes;
fextl::unordered_map<fextl::string, Pass*> NameToPassMaping;
#if defined(ASSERTIONS_ENABLED) && ASSERTIONS_ENABLED
fextl::vector<std::unique_ptr<Pass>> ValidationPasses;
void InsertValidationPass(std::unique_ptr<Pass> Pass, fextl::string Name = "") {
fextl::vector<fextl::unique_ptr<Pass>> ValidationPasses;
void InsertValidationPass(fextl::unique_ptr<Pass> Pass, fextl::string Name = "") {
Pass->RegisterPassManager(this);
auto PassPtr = ValidationPasses.emplace_back(std::move(Pass)).get();
+14 -14
View File
@@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include <FEXCore/fextl/memory.h>
namespace FEXCore::Utils {
class IntrusivePooledAllocator;
@@ -11,23 +11,23 @@ class Pass;
class RegisterAllocationPass;
class RegisterAllocationData;
std::unique_ptr<FEXCore::IR::Pass> CreateConstProp(bool InlineConstants, bool SupportsTSOImm9);
std::unique_ptr<FEXCore::IR::Pass> CreateContextLoadStoreElimination(bool SupportsAVX);
std::unique_ptr<FEXCore::IR::Pass> CreateSyscallOptimization();
std::unique_ptr<FEXCore::IR::Pass> CreateDeadFlagCalculationEliminination();
std::unique_ptr<FEXCore::IR::Pass> CreateDeadStoreElimination(bool SupportsAVX);
std::unique_ptr<FEXCore::IR::Pass> CreatePassDeadCodeElimination();
std::unique_ptr<FEXCore::IR::Pass> CreateIRCompaction(FEXCore::Utils::IntrusivePooledAllocator &Allocator);
std::unique_ptr<FEXCore::IR::RegisterAllocationPass> CreateRegisterAllocationPass(FEXCore::IR::Pass* CompactionPass,
fextl::unique_ptr<FEXCore::IR::Pass> CreateConstProp(bool InlineConstants, bool SupportsTSOImm9);
fextl::unique_ptr<FEXCore::IR::Pass> CreateContextLoadStoreElimination(bool SupportsAVX);
fextl::unique_ptr<FEXCore::IR::Pass> CreateSyscallOptimization();
fextl::unique_ptr<FEXCore::IR::Pass> CreateDeadFlagCalculationEliminination();
fextl::unique_ptr<FEXCore::IR::Pass> CreateDeadStoreElimination(bool SupportsAVX);
fextl::unique_ptr<FEXCore::IR::Pass> CreatePassDeadCodeElimination();
fextl::unique_ptr<FEXCore::IR::Pass> CreateIRCompaction(FEXCore::Utils::IntrusivePooledAllocator &Allocator);
fextl::unique_ptr<FEXCore::IR::RegisterAllocationPass> CreateRegisterAllocationPass(FEXCore::IR::Pass* CompactionPass,
bool OptimizeSRA,
bool SupportsAVX);
std::unique_ptr<FEXCore::IR::Pass> CreateLongDivideEliminationPass();
fextl::unique_ptr<FEXCore::IR::Pass> CreateLongDivideEliminationPass();
namespace Validation {
std::unique_ptr<FEXCore::IR::Pass> CreateIRValidation();
std::unique_ptr<FEXCore::IR::Pass> CreateRAValidation();
std::unique_ptr<FEXCore::IR::Pass> CreatePhiValidation();
std::unique_ptr<FEXCore::IR::Pass> CreateValueDominanceValidation();
fextl::unique_ptr<FEXCore::IR::Pass> CreateIRValidation();
fextl::unique_ptr<FEXCore::IR::Pass> CreateRAValidation();
fextl::unique_ptr<FEXCore::IR::Pass> CreatePhiValidation();
fextl::unique_ptr<FEXCore::IR::Pass> CreateValueDominanceValidation();
}
}
+4 -4
View File
@@ -22,6 +22,7 @@ $end_info$
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/Utils/Profiler.h>
#include <FEXCore/fextl/map.h>
#include <FEXCore/fextl/robin_map.h>
#include <FEXCore/fextl/unordered_map.h>
#include <bit>
@@ -29,7 +30,6 @@ $end_info$
#include <memory>
#include <string.h>
#include <tuple>
#include <tsl/robin_map.h>
#include <utility>
namespace FEXCore::IR {
@@ -201,7 +201,7 @@ private:
fextl::map<OrderedNode*, uint64_t> AddressgenConsts;
// Pool inline constant generation. These are typically very small and pool efficiently.
tsl::robin_map<uint64_t, OrderedNode*> InlineConstantGen;
fextl::robin_map<uint64_t, OrderedNode*> InlineConstantGen;
OrderedNode *CreateInlineConstant(IREmitter *IREmit, uint64_t Constant) {
const auto it = InlineConstantGen.find(Constant);
if (it != InlineConstantGen.end()) {
@@ -1073,8 +1073,8 @@ bool ConstProp::Run(IREmitter *IREmit) {
return Changed;
}
std::unique_ptr<FEXCore::IR::Pass> CreateConstProp(bool InlineConstants, bool SupportsTSOImm9) {
return std::make_unique<ConstProp>(InlineConstants, SupportsTSOImm9);
fextl::unique_ptr<FEXCore::IR::Pass> CreateConstProp(bool InlineConstants, bool SupportsTSOImm9) {
return fextl::make_unique<ConstProp>(InlineConstants, SupportsTSOImm9);
}
}
@@ -80,8 +80,8 @@ void DeadCodeElimination::markUsed(OrderedNodeWrapper *CodeOp, IROp_Header *IROp
}
std::unique_ptr<FEXCore::IR::Pass> CreatePassDeadCodeElimination() {
return std::make_unique<DeadCodeElimination>();
fextl::unique_ptr<FEXCore::IR::Pass> CreatePassDeadCodeElimination() {
return fextl::make_unique<DeadCodeElimination>();
}
}
@@ -410,7 +410,7 @@ public:
}
bool Run(FEXCore::IR::IREmitter *IREmit) override;
private:
std::unique_ptr<FEXCore::IR::Pass> DCE;
fextl::unique_ptr<FEXCore::IR::Pass> DCE;
ContextInfo ClassifiedStruct;
fextl::unordered_map<FEXCore::IR::NodeID, BlockInfo> OffsetToBlockMap;
@@ -784,8 +784,8 @@ bool RCLSE::Run(FEXCore::IR::IREmitter *IREmit) {
namespace FEXCore::IR {
std::unique_ptr<FEXCore::IR::Pass> CreateContextLoadStoreElimination(bool SupportsAVX) {
return std::make_unique<RCLSE>(SupportsAVX);
fextl::unique_ptr<FEXCore::IR::Pass> CreateContextLoadStoreElimination(bool SupportsAVX) {
return fextl::make_unique<RCLSE>(SupportsAVX);
}
}
@@ -358,8 +358,8 @@ bool DeadStoreElimination::Run(IREmitter *IREmit) {
return Changed;
}
std::unique_ptr<FEXCore::IR::Pass> CreateDeadStoreElimination(bool SupportsAVX) {
return std::make_unique<DeadStoreElimination>(SupportsAVX);
fextl::unique_ptr<FEXCore::IR::Pass> CreateDeadStoreElimination(bool SupportsAVX) {
return fextl::make_unique<DeadStoreElimination>(SupportsAVX);
}
}
@@ -220,8 +220,8 @@ bool IRCompaction::Run(IREmitter *IREmit) {
return true;
}
std::unique_ptr<FEXCore::IR::Pass> CreateIRCompaction(FEXCore::Utils::IntrusivePooledAllocator &Allocator) {
return std::make_unique<IRCompaction>(Allocator);
fextl::unique_ptr<FEXCore::IR::Pass> CreateIRCompaction(FEXCore::Utils::IntrusivePooledAllocator &Allocator) {
return fextl::make_unique<IRCompaction>(Allocator);
}
}
@@ -271,7 +271,7 @@ bool IRValidation::Run(IREmitter *IREmit) {
return false;
}
std::unique_ptr<FEXCore::IR::Pass> CreateIRValidation() {
return std::make_unique<IRValidation>();
fextl::unique_ptr<FEXCore::IR::Pass> CreateIRValidation() {
return fextl::make_unique<IRValidation>();
}
}
@@ -114,7 +114,7 @@ bool LongDivideEliminationPass::Run(IREmitter *IREmit) {
return Changed;
}
std::unique_ptr<FEXCore::IR::Pass> CreateLongDivideEliminationPass() {
return std::make_unique<LongDivideEliminationPass>();
fextl::unique_ptr<FEXCore::IR::Pass> CreateLongDivideEliminationPass() {
return fextl::make_unique<LongDivideEliminationPass>();
}
}
@@ -70,8 +70,8 @@ bool PhiValidation::Run(IREmitter *IREmit) {
return false;
}
std::unique_ptr<FEXCore::IR::Pass> CreatePhiValidation() {
return std::make_unique<PhiValidation>();
fextl::unique_ptr<FEXCore::IR::Pass> CreatePhiValidation() {
return fextl::make_unique<PhiValidation>();
}
}
@@ -452,7 +452,7 @@ bool RAValidation::Run(IREmitter *IREmit) {
return false;
}
std::unique_ptr<FEXCore::IR::Pass> CreateRAValidation() {
return std::make_unique<RAValidation>();
fextl::unique_ptr<FEXCore::IR::Pass> CreateRAValidation() {
return fextl::make_unique<RAValidation>();
}
}
@@ -68,8 +68,8 @@ bool DeadFlagCalculationEliminination::Run(IREmitter *IREmit) {
return Changed;
}
std::unique_ptr<FEXCore::IR::Pass> CreateDeadFlagCalculationEliminination() {
return std::make_unique<DeadFlagCalculationEliminination>();
fextl::unique_ptr<FEXCore::IR::Pass> CreateDeadFlagCalculationEliminination() {
return fextl::make_unique<DeadFlagCalculationEliminination>();
}
}
@@ -98,6 +98,14 @@ namespace {
fextl::vector<SpillStackUnit> SpillStack;
fextl::unordered_map<IR::NodeID, fextl::unordered_set<IR::NodeID>> BlockPredecessors;
fextl::unordered_map<IR::NodeID, fextl::unordered_set<IR::NodeID>> VisitedNodePredecessors;
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
};
void ResetRegisterGraph(RegisterGraph *Graph, uint64_t NodeCount);
@@ -1559,7 +1567,7 @@ namespace {
return Changed;
}
std::unique_ptr<FEXCore::IR::RegisterAllocationPass> CreateRegisterAllocationPass(FEXCore::IR::Pass* CompactionPass, bool OptimizeSRA, bool SupportsAVX) {
return std::make_unique<ConstrainedRAPass>(CompactionPass, OptimizeSRA, SupportsAVX);
fextl::unique_ptr<FEXCore::IR::RegisterAllocationPass> CreateRegisterAllocationPass(FEXCore::IR::Pass* CompactionPass, bool OptimizeSRA, bool SupportsAVX) {
return fextl::make_unique<ConstrainedRAPass>(CompactionPass, OptimizeSRA, SupportsAVX);
}
}
@@ -82,8 +82,8 @@ bool SyscallOptimization::Run(IREmitter *IREmit) {
return Changed;
}
std::unique_ptr<FEXCore::IR::Pass> CreateSyscallOptimization() {
return std::make_unique<SyscallOptimization>();
fextl::unique_ptr<FEXCore::IR::Pass> CreateSyscallOptimization() {
return fextl::make_unique<SyscallOptimization>();
}
}
@@ -206,8 +206,8 @@ bool ValueDominanceValidation::Run(IREmitter *IREmit) {
return false;
}
std::unique_ptr<FEXCore::IR::Pass> CreateValueDominanceValidation() {
return std::make_unique<ValueDominanceValidation>();
fextl::unique_ptr<FEXCore::IR::Pass> CreateValueDominanceValidation() {
return fextl::make_unique<ValueDominanceValidation>();
}
}
+14 -3
View File
@@ -8,6 +8,7 @@
#include <FEXHeaderUtils/ScopedSignalMask.h>
#include <FEXHeaderUtils/Syscalls.h>
#include <FEXHeaderUtils/TypeDefines.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/vector.h>
#include <algorithm>
@@ -30,6 +31,14 @@ namespace Alloc::OSAllocator {
class OSAllocator_64Bit final : public Alloc::HostAllocator {
public:
void *operator new(size_t size) {
return ::malloc(size);
}
void operator delete(void *ptr) {
return ::free(ptr);
}
OSAllocator_64Bit();
virtual ~OSAllocator_64Bit();
void *AllocateSlab(size_t Size) override { return nullptr; }
@@ -142,7 +151,9 @@ namespace Alloc::OSAllocator {
[[maybe_unused]] auto Res = mprotect(reinterpret_cast<void*>(ReservedRegion->Base), SizePlusManagedData, PROT_READ | PROT_WRITE);
LOGMAN_THROW_AA_FMT(Res == 0, "Couldn't mprotect region: {} '{}' Likely occurs when running out of memory or Maximum VMAs", errno, strerror(errno));
if (Res == -1) {
LOGMAN_MSG_A_FMT("Couldn't mprotect region: {} '{}' Likely occurs when running out of memory or Maximum VMAs", errno, strerror(errno));
}
LiveVMARegion *LiveRange = new (reinterpret_cast<void*>(ReservedRegion->Base)) LiveVMARegion();
@@ -572,7 +583,7 @@ OSAllocator_64Bit::~OSAllocator_64Bit() {
}
}
std::unique_ptr<Alloc::HostAllocator> Create64BitAllocator() {
return std::make_unique<OSAllocator_64Bit>();
fextl::unique_ptr<Alloc::HostAllocator> Create64BitAllocator() {
return fextl::make_unique<OSAllocator_64Bit>();
}
}
+3 -2
View File
@@ -1,8 +1,9 @@
#pragma once
#include <FEXCore/fextl/allocator.h>
#include <FEXCore/fextl/memory.h>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <sys/types.h>
namespace Alloc {
@@ -35,5 +36,5 @@ namespace Alloc {
}
namespace Alloc::OSAllocator {
std::unique_ptr<Alloc::HostAllocator> Create64BitAllocator();
fextl::unique_ptr<Alloc::HostAllocator> Create64BitAllocator();
}
+4 -4
View File
@@ -1,12 +1,12 @@
#include <FEXCore/Utils/Allocator.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/Utils/Threads.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/deque.h>
#include <alloca.h>
#include <cstring>
#include <functional>
#include <memory>
#include <mutex>
#include <pthread.h>
#include <stdint.h>
@@ -167,10 +167,10 @@ namespace FEXCore::Threads {
return Result;
}
std::unique_ptr<FEXCore::Threads::Thread> CreateThread_PThread(
fextl::unique_ptr<FEXCore::Threads::Thread> CreateThread_PThread(
ThreadFunc Func,
void* Arg) {
return std::make_unique<PThread>(Func, Arg);
return fextl::make_unique<PThread>(Func, Arg);
}
void CleanupAfterFork_PThread() {
@@ -208,7 +208,7 @@ namespace FEXCore::Threads {
.CleanupAfterFork = CleanupAfterFork_PThread,
};
std::unique_ptr<FEXCore::Threads::Thread> FEXCore::Threads::Thread::Create(
fextl::unique_ptr<FEXCore::Threads::Thread> FEXCore::Threads::Thread::Create(
ThreadFunc Func,
void* Arg) {
return Ptrs.CreateThread(Func, Arg);
+6 -6
View File
@@ -3,11 +3,11 @@
#include <FEXCore/Core/Context.h>
#include <FEXCore/Utils/CompilerDefs.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/list.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/unordered_map.h>
#include <memory>
#include <optional>
#include <stdint.h>
@@ -170,7 +170,7 @@ namespace Type {
FEX_DEFAULT_VISIBILITY fextl::string FindContainer();
FEX_DEFAULT_VISIBILITY fextl::string FindContainerPrefix();
FEX_DEFAULT_VISIBILITY void AddLayer(std::unique_ptr<FEXCore::Config::Layer> _Layer);
FEX_DEFAULT_VISIBILITY void AddLayer(fextl::unique_ptr<FEXCore::Config::Layer> _Layer);
FEX_DEFAULT_VISIBILITY bool Exists(ConfigOption Option);
FEX_DEFAULT_VISIBILITY std::optional<LayerValue*> All(ConfigOption Option);
@@ -255,7 +255,7 @@ namespace Type {
*
* @return unique_ptr for that layer
*/
FEX_DEFAULT_VISIBILITY std::unique_ptr<FEXCore::Config::Layer> CreateGlobalMainLayer();
FEX_DEFAULT_VISIBILITY fextl::unique_ptr<FEXCore::Config::Layer> CreateGlobalMainLayer();
/**
* @brief Loads the main application config
@@ -265,7 +265,7 @@ namespace Type {
*
* @return unique_ptr for that layer
*/
FEX_DEFAULT_VISIBILITY std::unique_ptr<FEXCore::Config::Layer> CreateMainLayer(fextl::string const *File = nullptr);
FEX_DEFAULT_VISIBILITY fextl::unique_ptr<FEXCore::Config::Layer> CreateMainLayer(fextl::string const *File = nullptr);
/**
* @brief Create an application configuration loader
@@ -275,7 +275,7 @@ namespace Type {
*
* @return unique_ptr for that layer
*/
FEX_DEFAULT_VISIBILITY std::unique_ptr<FEXCore::Config::Layer> CreateAppLayer(const fextl::string& Filename, FEXCore::Config::LayerType Type);
FEX_DEFAULT_VISIBILITY fextl::unique_ptr<FEXCore::Config::Layer> CreateAppLayer(const fextl::string& Filename, FEXCore::Config::LayerType Type);
/**
* @brief iCreate an environment configuration loader
@@ -284,6 +284,6 @@ namespace Type {
*
* @return unique_ptr for that layer
*/
FEX_DEFAULT_VISIBILITY std::unique_ptr<FEXCore::Config::Layer> CreateEnvironmentLayer(char *const _envp[]);
FEX_DEFAULT_VISIBILITY fextl::unique_ptr<FEXCore::Config::Layer> CreateEnvironmentLayer(char *const _envp[]);
}
+2 -2
View File
@@ -6,13 +6,13 @@
#include <FEXCore/Core/CPUID.h>
#include <FEXCore/IR/IR.h>
#include <FEXCore/Utils/CompilerDefs.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/set.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/vector.h>
#include <istream>
#include <ostream>
#include <memory>
#include <mutex>
#include <shared_mutex>
@@ -75,7 +75,7 @@ namespace FEXCore::Context {
void *VDSO_kernel_rt_sigreturn;
};
using CustomCPUFactoryType = std::function<std::unique_ptr<FEXCore::CPU::CPUBackend> (FEXCore::Context::Context*, FEXCore::Core::InternalThreadState *Thread)>;
using CustomCPUFactoryType = std::function<fextl::unique_ptr<FEXCore::CPU::CPUBackend> (FEXCore::Context::Context*, FEXCore::Core::InternalThreadState *Thread)>;
using ExitHandler = std::function<void(uint64_t ThreadId, FEXCore::Context::ExitReason)>;
+27 -10
View File
@@ -7,11 +7,12 @@
#include <FEXCore/Utils/Event.h>
#include <FEXCore/Utils/InterruptableConditionVariable.h>
#include <FEXCore/Utils/Threads.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/robin_map.h>
#include <FEXCore/fextl/vector.h>
#include <tsl/robin_map.h>
#include <shared_mutex>
#include <type_traits>
namespace FEXCore {
class LookupCache;
@@ -62,6 +63,14 @@ namespace FEXCore::Core {
fextl::vector<DebugDataSubblock> Subblocks;
fextl::vector<DebugDataGuestOpcode> GuestOpcodes;
fextl::vector<FEXCore::CPU::Relocation> *Relocations;
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
};
enum class SignalEvent {
@@ -75,9 +84,9 @@ namespace FEXCore::Core {
struct LocalIREntry {
uint64_t StartAddr;
uint64_t Length;
std::unique_ptr<FEXCore::IR::IRListView, FEXCore::IR::IRListViewDeleter> IR;
fextl::unique_ptr<FEXCore::IR::IRListView, FEXCore::IR::IRListViewDeleter> IR;
FEXCore::IR::RegisterAllocationData::UniquePtr RAData;
std::unique_ptr<FEXCore::Core::DebugData> DebugData;
fextl::unique_ptr<FEXCore::Core::DebugData> DebugData;
};
struct InternalThreadState {
@@ -93,20 +102,20 @@ namespace FEXCore::Core {
FEXCore::Context::Context *CTX;
std::atomic<SignalEvent> SignalReason{SignalEvent::Nothing};
std::unique_ptr<FEXCore::Threads::Thread> ExecutionThread;
fextl::unique_ptr<FEXCore::Threads::Thread> ExecutionThread;
bool StartPaused {false};
InterruptableConditionVariable StartRunning;
Event ThreadWaiting;
std::unique_ptr<FEXCore::IR::OpDispatchBuilder> OpDispatcher;
fextl::unique_ptr<FEXCore::IR::OpDispatchBuilder> OpDispatcher;
std::unique_ptr<FEXCore::CPU::CPUBackend> CPUBackend;
std::unique_ptr<FEXCore::LookupCache> LookupCache;
fextl::unique_ptr<FEXCore::CPU::CPUBackend> CPUBackend;
fextl::unique_ptr<FEXCore::LookupCache> LookupCache;
tsl::robin_map<uint64_t, LocalIREntry> DebugStore;
std::unique_ptr<FEXCore::Frontend::Decoder> FrontendDecoder;
std::unique_ptr<FEXCore::IR::PassManager> PassManager;
fextl::unique_ptr<FEXCore::Frontend::Decoder> FrontendDecoder;
fextl::unique_ptr<FEXCore::IR::PassManager> PassManager;
FEXCore::HLE::ThreadManagement ThreadManager;
RuntimeStats Stats{};
@@ -118,6 +127,14 @@ namespace FEXCore::Core {
std::shared_mutex ObjectCacheRefCounter{};
bool DestroyedByParent{false}; // Should the parent destroy this thread, or it destory itself
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
alignas(16) FEXCore::Core::CpuStateFrame BaseFrameState{};
};
+2 -1
View File
@@ -1,5 +1,6 @@
#pragma once
#include <FEXCore/fextl/fmt.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/vector.h>
@@ -91,6 +92,6 @@ private:
class SourcecodeResolver {
public:
virtual std::unique_ptr<SourcecodeMap> GenerateMap(const std::string_view& GuestBinaryFile, const std::string_view& GuestBinaryFileId) = 0;
virtual fextl::unique_ptr<SourcecodeMap> GenerateMap(const std::string_view& GuestBinaryFile, const std::string_view& GuestBinaryFileId) = 0;
};
}
+10 -2
View File
@@ -170,6 +170,14 @@ public:
}
}
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
void Serialize(std::ostream& stream) const {
void *nul = nullptr;
//void *IRDataInternal;
@@ -183,7 +191,7 @@ public:
//uint64_t Flags;
uint64_t WrittenFlags = FLAG_Shared; //on disk format always has the Shared flag
stream.write((const char*)&WrittenFlags, sizeof(WrittenFlags));
// inline data
stream.write((const char*)GetData(), DataSize);
stream.write((const char*)GetListData(), ListSize);
@@ -202,7 +210,7 @@ public:
//uint64_t Flags;
uint64_t WrittenFlags = FLAG_Shared; //on disk format always has the Shared flag
memcpy(ptr, &WrittenFlags, sizeof(WrittenFlags)); ptr += sizeof(WrittenFlags);
// inline data
memcpy(ptr, (const void*)GetData(), DataSize); ptr += DataSize;
memcpy(ptr, (const void*)GetListData(), ListSize); ptr += ListSize;
+3 -3
View File
@@ -1,8 +1,8 @@
#pragma once
#include <cstddef>
#include <memory>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/fextl/memory.h>
namespace FEXCore {
@@ -17,7 +17,7 @@ namespace FEXCore {
static constexpr size_t Size = _Size;
T Items[Size];
std::unique_ptr<BucketList<Size, T>> Next;
fextl::unique_ptr<BucketList<Size, T>> Next;
void Clear() {
Items[0] = T{};
@@ -96,7 +96,7 @@ namespace FEXCore {
if (i < (Size-1)) {
that->Items[i+1] = T{};
} else {
that->Next = std::make_unique<BucketList<Size, T>>();
that->Next = fextl::make_unique<BucketList<Size, T>>();
}
}
void Erase(T Val) {
@@ -68,6 +68,14 @@ namespace FEXCore::Utils {
size_t Size;
std::atomic<std::chrono::time_point<ClockType>> LastUsed;
BufferOwnedFlag *CurrentClientOwnedFlag{};
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
};
// Ensure that the atomic objects of MemoryBuffer are lock free
static_assert(decltype(MemoryBuffer::LastUsed){}.is_always_lock_free, "Oops, needs to be lock free");
+4 -3
View File
@@ -1,12 +1,13 @@
#pragma once
#include <FEXCore/fextl/memory.h>
#include <functional>
#include <memory>
namespace FEXCore::Threads {
using ThreadFunc = void*(*)(void* user_ptr);
class Thread;
using CreateThreadFunc = std::function<std::unique_ptr<Thread>(ThreadFunc Func, void* Arg)>;
using CreateThreadFunc = std::function<fextl::unique_ptr<Thread>(ThreadFunc Func, void* Arg)>;
using CleanupAfterForkFunc = std::function<void()>;
struct Pointers {
@@ -27,7 +28,7 @@ namespace FEXCore::Threads {
* @name Calls provided API functions
* @{ */
static std::unique_ptr<Thread> Create(
static fextl::unique_ptr<Thread> Create(
ThreadFunc Func,
void* Arg);
@@ -1,13 +1,14 @@
#pragma once
#include <FEXCore/fextl/string.h>
#include <fcntl.h>
#include <string>
#include <sys/stat.h>
#include <span>
#include <unistd.h>
namespace FHU::Symlinks {
// Checks to see if a filepath is a symlink.
inline bool IsSymlink(const std::string &Filename) {
inline bool IsSymlink(const fextl::string &Filename) {
struct stat Buffer{};
int Result = lstat(Filename.c_str(), &Buffer);
return Result == 0 && S_ISLNK(Buffer.st_mode);
@@ -17,7 +18,7 @@ inline bool IsSymlink(const std::string &Filename) {
// Doesn't handle recursive symlinks.
// Doesn't append null terminator character.
// Returns a string_view of the resolved path, or an empty view on error.
inline std::string_view ResolveSymlink(const std::string &Filename, std::span<char> ResultBuffer) {
inline std::string_view ResolveSymlink(const fextl::string &Filename, std::span<char> ResultBuffer) {
ssize_t Result = readlink(Filename.c_str(), ResultBuffer.data(), ResultBuffer.size());
if (Result == -1) {
return {};
+1 -1
View File
@@ -122,7 +122,7 @@ namespace FEX::Config {
FEX::ArgLoader::LoadWithoutArguments(argc, argv);
}
else {
FEXCore::Config::AddLayer(std::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(fextl::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
}
FEXCore::Config::AddLayer(FEXCore::Config::CreateEnvironmentLayer(envp));
+1 -1
View File
@@ -357,7 +357,7 @@ int main(int argc, char **argv, char **const envp) {
}
FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0");
std::unique_ptr<FEX::HLE::MemAllocator> Allocator;
fextl::unique_ptr<FEX::HLE::MemAllocator> Allocator;
fextl::vector<FEXCore::Allocator::MemoryRegion> Base48Bit;
if (Loader.Is64BitMode()) {
+1 -1
View File
@@ -172,7 +172,7 @@ int main(int argc, char **argv, char **const envp)
LogMan::Msg::InstallHandler(MsgHandler);
FEXCore::Config::Initialize();
FEXCore::Config::AddLayer(std::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(fextl::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(FEXCore::Config::CreateEnvironmentLayer(envp));
FEXCore::Config::Load();
// Ensure the IRLoader runs in 64-bit mode.
@@ -5,6 +5,7 @@
#include <FEXHeaderUtils/Syscalls.h>
#include <FEXHeaderUtils/TypeDefines.h>
#include <FEXCore/fextl/map.h>
#include <FEXCore/fextl/memory.h>
#include <bitset>
#include <linux/mman.h>
@@ -44,6 +45,7 @@ public:
FindPageRangePtr = &MemAllocator32Bit::FindPageRange;
}
}
void *Mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) override;
int Munmap(void *addr, size_t length) override;
void *Mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address) override;
@@ -603,12 +605,12 @@ public:
}
};
std::unique_ptr<FEX::HLE::MemAllocator> Create32BitAllocator() {
return std::make_unique<MemAllocator32Bit>();
fextl::unique_ptr<FEX::HLE::MemAllocator> Create32BitAllocator() {
return fextl::make_unique<MemAllocator32Bit>();
}
std::unique_ptr<FEX::HLE::MemAllocator> CreatePassthroughAllocator() {
return std::make_unique<MemAllocatorPassThrough>();
fextl::unique_ptr<FEX::HLE::MemAllocator> CreatePassthroughAllocator() {
return fextl::make_unique<MemAllocatorPassThrough>();
}
}
+4 -2
View File
@@ -1,5 +1,7 @@
#pragma once
#include <FEXCore/fextl/memory.h>
#include <cstdint>
#include <memory>
@@ -16,6 +18,6 @@ namespace FEX::HLE {
virtual uint64_t Shmdt(const void* shmaddr) = 0;
};
std::unique_ptr<FEX::HLE::MemAllocator> Create32BitAllocator();
std::unique_ptr<FEX::HLE::MemAllocator> CreatePassthroughAllocator();
fextl::unique_ptr<FEX::HLE::MemAllocator> Create32BitAllocator();
fextl::unique_ptr<FEX::HLE::MemAllocator> CreatePassthroughAllocator();
}
@@ -25,6 +25,14 @@ namespace Core {
namespace FEX::HLE {
class SignalDelegator final : public FEXCore::SignalDelegator {
public:
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
// Returns true if the host handled the signal
// Arguments are the same as sigaction handler
SignalDelegator();
+3 -3
View File
@@ -867,7 +867,7 @@ static bool isHEX(char c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
}
std::unique_ptr<FEXCore::HLE::SourcecodeMap> SyscallHandler::GenerateMap(const std::string_view& GuestBinaryFile, const std::string_view& GuestBinaryFileId) {
fextl::unique_ptr<FEXCore::HLE::SourcecodeMap> SyscallHandler::GenerateMap(const std::string_view& GuestBinaryFile, const std::string_view& GuestBinaryFileId) {
ELFParser GuestELF;
@@ -929,7 +929,7 @@ std::unique_ptr<FEXCore::HLE::SourcecodeMap> SyscallHandler::GenerateMap(const s
goto DoGenerate;
}
auto rv = std::make_unique<FEXCore::HLE::SourcecodeMap>();
auto rv = fextl::make_unique<FEXCore::HLE::SourcecodeMap>();
{
auto len = rv->SourceFile.size();
@@ -1006,7 +1006,7 @@ std::unique_ptr<FEXCore::HLE::SourcecodeMap> SyscallHandler::GenerateMap(const s
uintptr_t CurrentOffset{};
int LastOffsetLine;
auto rv = std::make_unique<FEXCore::HLE::SourcecodeMap>();
auto rv = fextl::make_unique<FEXCore::HLE::SourcecodeMap>();
rv->SourceFile = GuestSourceFile;
+11 -2
View File
@@ -16,6 +16,7 @@ $end_info$
#include <FEXCore/IR/IR.h>
#include <FEXCore/Utils/CompilerDefs.h>
#include <FEXCore/fextl/map.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <FEXCore/fextl/vector.h>
@@ -94,6 +95,14 @@ uint64_t ExecveHandler(const char *pathname, char* const* argv, char* const* env
class SyscallHandler : public FEXCore::HLE::SyscallHandler, FEXCore::HLE::SourcecodeResolver {
public:
void *operator new(size_t size) {
return FEXCore::Allocator::malloc(size);
}
void operator delete(void *ptr) {
return FEXCore::Allocator::free(ptr);
}
virtual ~SyscallHandler();
// In the case that the syscall doesn't hit the optimized path then we still need to go here
@@ -252,9 +261,9 @@ private:
void Strace(FEXCore::HLE::SyscallArguments *Args, uint64_t Ret);
#endif
std::unique_ptr<FEX::HLE::MemAllocator> Alloc32Handler{};
fextl::unique_ptr<FEX::HLE::MemAllocator> Alloc32Handler{};
std::unique_ptr<FEXCore::HLE::SourcecodeMap> GenerateMap(const std::string_view& GuestBinaryFile, const std::string_view& GuestBinaryFileId) override;
fextl::unique_ptr<FEXCore::HLE::SourcecodeMap> GenerateMap(const std::string_view& GuestBinaryFile, const std::string_view& GuestBinaryFileId) override;
///// VMA (Virtual Memory Area) tracking /////
+4 -3
View File
@@ -11,6 +11,7 @@ $end_info$
#include <FEXCore/HLE/SyscallHandler.h>
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/fextl/memory.h>
#include <bitset>
#include <cerrno>
@@ -39,7 +40,7 @@ namespace FEX::HLE::x32 {
void RegisterTime(FEX::HLE::SyscallHandler *Handler);
void RegisterTimer(FEX::HLE::SyscallHandler *Handler);
x32SyscallHandler::x32SyscallHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, std::unique_ptr<MemAllocator> Allocator)
x32SyscallHandler::x32SyscallHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, fextl::unique_ptr<MemAllocator> Allocator)
: SyscallHandler{ctx, _SignalDelegation}, AllocHandler{std::move(Allocator)} {
OSABI = FEXCore::HLE::SyscallOSABI::OS_LINUX32;
RegisterSyscallHandlers();
@@ -110,8 +111,8 @@ namespace FEX::HLE::x32 {
#endif
}
std::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, std::unique_ptr<MemAllocator> Allocator) {
return std::make_unique<x32SyscallHandler>(ctx, _SignalDelegation, std::move(Allocator));
fextl::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, fextl::unique_ptr<MemAllocator> Allocator) {
return fextl::make_unique<x32SyscallHandler>(ctx, _SignalDelegation, std::move(Allocator));
}
}
+5 -4
View File
@@ -6,6 +6,7 @@ $end_info$
#pragma once
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include "Tests/LinuxSyscalls/Syscalls.h"
@@ -33,7 +34,7 @@ namespace FEX::HLE::x32 {
class x32SyscallHandler final : public FEX::HLE::SyscallHandler {
public:
x32SyscallHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, std::unique_ptr<MemAllocator> Allocator);
x32SyscallHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation, fextl::unique_ptr<MemAllocator> Allocator);
FEX::HLE::MemAllocator *GetAllocator() { return AllocHandler.get(); }
void *GuestMmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) override;
@@ -69,12 +70,12 @@ public:
private:
void RegisterSyscallHandlers();
std::unique_ptr<MemAllocator> AllocHandler{};
fextl::unique_ptr<MemAllocator> AllocHandler{};
};
std::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx,
fextl::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx,
FEX::HLE::SignalDelegator *_SignalDelegation,
std::unique_ptr<MemAllocator> Allocator);
fextl::unique_ptr<MemAllocator> Allocator);
//////
// REGISTER_SYSCALL_IMPL implementation
// Given a syscall name + a lambda, and it will generate an strace string, extract number of arguments
+2 -2
View File
@@ -113,7 +113,7 @@ namespace FEX::HLE::x64 {
#endif
}
std::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation) {
return std::make_unique<x64SyscallHandler>(ctx, _SignalDelegation);
fextl::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation) {
return fextl::make_unique<x64SyscallHandler>(ctx, _SignalDelegation);
}
}
+2 -1
View File
@@ -11,6 +11,7 @@ $end_info$
#include <FEXCore/HLE/SyscallHandler.h>
#include <FEXCore/IR/IR.h>
#include <FEXCore/fextl/memory.h>
#include <FEXCore/fextl/string.h>
#include <atomic>
@@ -70,7 +71,7 @@ class x64SyscallHandler final : public FEX::HLE::SyscallHandler {
void RegisterSyscallHandlers();
};
std::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation);
fextl::unique_ptr<FEX::HLE::SyscallHandler> CreateHandler(FEXCore::Context::Context *ctx, FEX::HLE::SignalDelegator *_SignalDelegation);
//////
// REGISTER_SYSCALL_IMPL implementation
+3 -3
View File
@@ -118,7 +118,7 @@ int main(int argc, char **argv, char **const envp) {
LogMan::Throw::InstallHandler(AssertHandler);
LogMan::Msg::InstallHandler(MsgHandler);
FEXCore::Config::Initialize();
FEXCore::Config::AddLayer(std::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(fextl::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(FEXCore::Config::CreateEnvironmentLayer(envp));
FEXCore::Config::Load();
@@ -132,14 +132,14 @@ int main(int argc, char **argv, char **const envp) {
FEX::HarnessHelper::HarnessCodeLoader Loader{Args[0], Args[1].c_str()};
// Adds in environment options from the test harness config
FEXCore::Config::AddLayer(std::make_unique<TestEnvLoader>(Loader.GetEnvironmentOptions()));
FEXCore::Config::AddLayer(fextl::make_unique<TestEnvLoader>(Loader.GetEnvironmentOptions()));
FEXCore::Config::ReloadMetaLayer();
FEXCore::Config::Set(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0");
FEX_CONFIG_OPT(Core, CORE);
std::unique_ptr<FEX::HLE::MemAllocator> Allocator;
fextl::unique_ptr<FEX::HLE::MemAllocator> Allocator;
if (!Loader.Is64BitMode()) {
// Setup our userspace allocator
+1 -1
View File
@@ -13,7 +13,7 @@ $end_info$
int main(int argc, char **argv, char **const envp) {
FEXCore::Config::Initialize();
FEXCore::Config::AddLayer(FEXCore::Config::CreateMainLayer());
FEXCore::Config::AddLayer(std::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(fextl::make_unique<FEX::ArgLoader::ArgLoader>(argc, argv));
FEXCore::Config::AddLayer(FEXCore::Config::CreateEnvironmentLayer(envp));
FEXCore::Config::Load();