mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-02-01 03:52:52 +00:00
CodeReview
This commit is contained in:
parent
97daec3dba
commit
546a1edb55
@ -90,7 +90,7 @@ namespace {
|
||||
IR::OrderedNode *SpilledNode;
|
||||
};
|
||||
|
||||
struct RegisterGraph {
|
||||
struct RegisterGraph : public FEXCore::Allocator::FEXAllocOperators {
|
||||
IR::RegisterAllocationData::UniquePtr AllocData;
|
||||
RegisterSet Set;
|
||||
fextl::vector<RegisterNode> Nodes{};
|
||||
@ -98,15 +98,6 @@ 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;
|
||||
|
||||
// Required due to raw new usage.
|
||||
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);
|
||||
|
@ -58,20 +58,11 @@ namespace FEXCore::Core {
|
||||
*
|
||||
* Needs to remain around for as long as the code could be executed at least
|
||||
*/
|
||||
struct DebugData {
|
||||
struct DebugData : public FEXCore::Allocator::FEXAllocOperators {
|
||||
uint64_t HostCodeSize; ///< The size of the code generated in the host JIT
|
||||
fextl::vector<DebugDataSubblock> Subblocks;
|
||||
fextl::vector<DebugDataGuestOpcode> GuestOpcodes;
|
||||
fextl::vector<FEXCore::CPU::Relocation> *Relocations;
|
||||
|
||||
// Required due to raw new usage.
|
||||
void *operator new(size_t size) {
|
||||
return FEXCore::Allocator::malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr) {
|
||||
return FEXCore::Allocator::free(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
enum class SignalEvent {
|
||||
@ -90,7 +81,7 @@ namespace FEXCore::Core {
|
||||
fextl::unique_ptr<FEXCore::Core::DebugData> DebugData;
|
||||
};
|
||||
|
||||
struct InternalThreadState {
|
||||
struct InternalThreadState : public FEXCore::Allocator::FEXAllocOperators {
|
||||
FEXCore::Core::CpuStateFrame* const CurrentFrame = &BaseFrameState;
|
||||
|
||||
struct {
|
||||
@ -128,15 +119,6 @@ namespace FEXCore::Core {
|
||||
std::shared_mutex ObjectCacheRefCounter{};
|
||||
bool DestroyedByParent{false}; // Should the parent destroy this thread, or it destory itself
|
||||
|
||||
// Required due to raw new usage.
|
||||
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{};
|
||||
|
||||
};
|
||||
|
@ -120,7 +120,7 @@ class DualIntrusiveAllocatorThreadPool final : public DualIntrusiveAllocator {
|
||||
Utils::FixedSizePooledAllocation<uintptr_t, 5000, 500> PoolObject;
|
||||
};
|
||||
|
||||
class IRListView final {
|
||||
class IRListView final : public FEXCore::Allocator::FEXAllocOperators {
|
||||
enum Flags {
|
||||
FLAG_IsCopy = 1,
|
||||
FLAG_Shared = 2,
|
||||
@ -170,15 +170,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Required due to raw new usage.
|
||||
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;
|
||||
|
@ -30,4 +30,16 @@ namespace FEXCore::Allocator {
|
||||
FEX_DEFAULT_VISIBILITY extern FREE_Hook free;
|
||||
FEX_DEFAULT_VISIBILITY extern MALLOC_USABLE_SIZE_Hook malloc_usable_size;
|
||||
FEX_DEFAULT_VISIBILITY extern ALIGNED_ALLOC_Hook aligned_alloc;
|
||||
|
||||
struct FEXAllocOperators {
|
||||
FEXAllocOperators() = default;
|
||||
|
||||
void *operator new(size_t size) {
|
||||
return FEXCore::Allocator::malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr) {
|
||||
return FEXCore::Allocator::free(ptr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -63,19 +63,16 @@ namespace FEXCore::Utils {
|
||||
|
||||
using BufferOwnedFlag = std::atomic<ClientFlags>;
|
||||
|
||||
struct MemoryBuffer {
|
||||
struct MemoryBuffer : public FEXCore::Allocator::FEXAllocOperators {
|
||||
MemoryBuffer(void* Ptr, size_t Size, std::chrono::time_point<ClockType> LastUsed)
|
||||
: Ptr {Ptr}
|
||||
, Size {Size}
|
||||
, LastUsed {LastUsed} {}
|
||||
|
||||
void* Ptr;
|
||||
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");
|
||||
|
@ -222,8 +222,6 @@ namespace FHU::Filesystem {
|
||||
fextl::pmr::fixed_size_monotonic_buffer_resource mbr(Data, DataSize);
|
||||
std::pmr::polymorphic_allocator pa {&mbr};
|
||||
std::pmr::list<std::string_view> Parts{pa};
|
||||
// Calculate the expected string size while parsing to reduce allocations.
|
||||
size_t ExpectedStringSize{};
|
||||
|
||||
size_t CurrentOffset{};
|
||||
do {
|
||||
@ -235,7 +233,6 @@ namespace FHU::Filesystem {
|
||||
const auto Begin = Path.begin() + CurrentOffset;
|
||||
const auto End = Path.begin() + FoundSeperator;
|
||||
const auto Size = End - Begin;
|
||||
ExpectedStringSize += Size;
|
||||
|
||||
// Only insert parts that contain data.
|
||||
if (Size != 0) {
|
||||
@ -258,7 +255,6 @@ namespace FHU::Filesystem {
|
||||
if (CurrentIterDistance > 0 || IsAbsolutePath) {
|
||||
// Erasing this iterator, don't increase iter distances
|
||||
iter = Parts.erase(iter);
|
||||
--ExpectedStringSize;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -275,14 +271,12 @@ namespace FHU::Filesystem {
|
||||
if (*PreviousIter == ".") {
|
||||
// Erasing the previous iterator, iterator distance has subtracted by one
|
||||
--CurrentIterDistance;
|
||||
ExpectedStringSize -= PreviousIter->size();
|
||||
Parts.erase(PreviousIter);
|
||||
}
|
||||
else if (*PreviousIter != "..") {
|
||||
// Erasing the previous iterator, iterator distance has subtracted by one
|
||||
// Also erasing current iterator, which means iterator distance also doesn't increase by one.
|
||||
--CurrentIterDistance;
|
||||
ExpectedStringSize -= PreviousIter->size() + 2;
|
||||
Parts.erase(PreviousIter);
|
||||
iter = Parts.erase(iter);
|
||||
continue;
|
||||
@ -290,7 +284,6 @@ namespace FHU::Filesystem {
|
||||
}
|
||||
else if (IsAbsolutePath) {
|
||||
// `..` at the base. Just remove this
|
||||
ExpectedStringSize -= 2;
|
||||
iter = Parts.erase(iter);
|
||||
continue;
|
||||
}
|
||||
|
@ -23,16 +23,8 @@ namespace Core {
|
||||
}
|
||||
|
||||
namespace FEX::HLE {
|
||||
class SignalDelegator final : public FEXCore::SignalDelegator {
|
||||
class SignalDelegator final : public FEXCore::SignalDelegator, public FEXCore::Allocator::FEXAllocOperators {
|
||||
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();
|
||||
|
@ -93,16 +93,8 @@ struct ExecveAtArgs {
|
||||
|
||||
uint64_t ExecveHandler(const char *pathname, char* const* argv, char* const* envp, ExecveAtArgs Args);
|
||||
|
||||
class SyscallHandler : public FEXCore::HLE::SyscallHandler, FEXCore::HLE::SourcecodeResolver {
|
||||
class SyscallHandler : public FEXCore::HLE::SyscallHandler, FEXCore::HLE::SourcecodeResolver, public FEXCore::Allocator::FEXAllocOperators {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user