mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 17:00:19 +02:00
Switches more usages of memory allocation routines over to FEX internal
This commit is contained in:
1 parent
d256bc59fd
commit
5143100a73
6 files changed
+19
-12
No files matched your search
+4
-3
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "Common/MathUtils.h"
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
|
||||
#include <cstring>
|
||||
@@ -17,15 +18,15 @@ struct BitSet final {
|
||||
void Allocate(size_t Elements) {
|
||||
size_t AllocateSize = AlignUp(Elements, MinimumSizeBits) / MinimumSize;
|
||||
LOGMAN_THROW_A((AllocateSize * MinimumSize) >= Elements, "Fail");
|
||||
Memory = static_cast<ElementType*>(malloc(AllocateSize));
|
||||
Memory = static_cast<ElementType*>(FEXCore::Allocator::malloc(AllocateSize));
|
||||
}
|
||||
void Realloc(size_t Elements) {
|
||||
size_t AllocateSize = AlignUp(Elements, MinimumSizeBits) / MinimumSize;
|
||||
LOGMAN_THROW_A((AllocateSize * MinimumSize) >= Elements, "Fail");
|
||||
Memory = static_cast<ElementType*>(realloc(Memory, AllocateSize));
|
||||
Memory = static_cast<ElementType*>(FEXCore::Allocator::realloc(Memory, AllocateSize));
|
||||
}
|
||||
void Free() {
|
||||
free(Memory);
|
||||
FEXCore::Allocator::free(Memory);
|
||||
Memory = nullptr;
|
||||
}
|
||||
bool Get(T Element) {
|
||||
|
||||
+4
-3
@@ -28,6 +28,7 @@ $end_info$
|
||||
#include <FEXCore/Core/CPUBackend.h>
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/HLE/SyscallHandler.h>
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
|
||||
#include "Interface/HLE/Thunks/Thunks.h"
|
||||
#include "FEXCore/Utils/Allocator.h"
|
||||
@@ -180,7 +181,7 @@ namespace FEXCore::Context {
|
||||
for (auto &Mod: AOTIRCaptureCache) {
|
||||
for (auto &Entry: Mod.second) {
|
||||
delete Entry.second.IR;
|
||||
free(Entry.second.RAData);
|
||||
FEXCore::Allocator::free(Entry.second.RAData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +437,7 @@ namespace FEXCore::Context {
|
||||
static void *ThreadHandler(void* Data) {
|
||||
ExecutionThreadHandler *Handler = reinterpret_cast<ExecutionThreadHandler*>(Data);
|
||||
Handler->This->ExecutionThread(Handler->Thread);
|
||||
free(Handler);
|
||||
FEXCore::Allocator::free(Handler);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -444,7 +445,7 @@ namespace FEXCore::Context {
|
||||
InitializeThreadData(Thread);
|
||||
|
||||
// This will create the execution thread but it won't actually start executing
|
||||
ExecutionThreadHandler *Arg = reinterpret_cast<ExecutionThreadHandler*>(malloc(sizeof(ExecutionThreadHandler)));
|
||||
ExecutionThreadHandler *Arg = reinterpret_cast<ExecutionThreadHandler*>(FEXCore::Allocator::malloc(sizeof(ExecutionThreadHandler)));
|
||||
Arg->This = this;
|
||||
Arg->Thread = Thread;
|
||||
Thread->ExecutionThread = FEXCore::Threads::Thread::Create(ThreadHandler, Arg);
|
||||
|
||||
@@ -8,6 +8,7 @@ $end_info$
|
||||
#include "Interface/IR/Passes/RegisterAllocationPass.h"
|
||||
#include "Interface/IR/Passes.h"
|
||||
#include "Interface/Core/OpcodeDispatcher.h"
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
|
||||
#include <iterator>
|
||||
#include <unordered_set>
|
||||
@@ -262,7 +263,7 @@ namespace {
|
||||
Graph->Nodes.resize(NodeCount);
|
||||
Graph->VisitedNodePredecessors.clear();
|
||||
Graph->AllocData.reset();
|
||||
Graph->AllocData.reset((FEXCore::IR::RegisterAllocationData*)malloc(FEXCore::IR::RegisterAllocationData::Size(NodeCount)));
|
||||
Graph->AllocData.reset((FEXCore::IR::RegisterAllocationData*)FEXCore::Allocator::malloc(FEXCore::IR::RegisterAllocationData::Size(NodeCount)));
|
||||
memset(&Graph->AllocData->Map[0], INVALID_REGCLASS.Raw, NodeCount);
|
||||
Graph->AllocData->MapCount = NodeCount;
|
||||
Graph->AllocData->IsShared = false; // not shared by default
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "FEXCore/IR/IR.h"
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
|
||||
#include <cassert>
|
||||
@@ -25,12 +26,13 @@ class DualIntrusiveAllocator final {
|
||||
DualIntrusiveAllocator(DualIntrusiveAllocator &&) = delete;
|
||||
DualIntrusiveAllocator(size_t Size)
|
||||
: MemorySize {Size} {
|
||||
Data = reinterpret_cast<uintptr_t>(malloc(Size * 2));
|
||||
Data = reinterpret_cast<uintptr_t>(FEXCore::Allocator::malloc(Size * 2));
|
||||
List = reinterpret_cast<uintptr_t>(Data + Size);
|
||||
}
|
||||
|
||||
|
||||
~DualIntrusiveAllocator() {
|
||||
free(reinterpret_cast<void*>(Data));
|
||||
FEXCore::Allocator::free(reinterpret_cast<void*>(Data));
|
||||
}
|
||||
|
||||
bool DataCheckSize(size_t Size) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "IR.h"
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
|
||||
namespace FEXCore::IR {
|
||||
|
||||
@@ -47,9 +48,9 @@ class RegisterAllocationData {
|
||||
struct RegisterAllocationDataDeleter {
|
||||
void operator()(RegisterAllocationData* r) {
|
||||
if (!r->IsShared) {
|
||||
free(r);
|
||||
FEXCore::Allocator::free(r);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ $end_info$
|
||||
#include "Tests/LinuxSyscalls/SignalDelegator.h"
|
||||
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
|
||||
#include <string.h>
|
||||
@@ -341,7 +342,7 @@ namespace FEX::HLE {
|
||||
|
||||
// Set up our signal alternative stack
|
||||
// This is per thread rather than per signal
|
||||
ThreadData.AltStackPtr = malloc(SIGSTKSZ);
|
||||
ThreadData.AltStackPtr = FEXCore::Allocator::malloc(SIGSTKSZ);
|
||||
stack_t altstack{};
|
||||
altstack.ss_sp = ThreadData.AltStackPtr;
|
||||
altstack.ss_size = SIGSTKSZ;
|
||||
|
||||
Reference in new issue
Block a user