mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 10:00:16 +02:00
Allocator: Still need to return memory regions to frontend
This commit is contained in:
3 files changed
+8
-4
No files matched your search
@@ -304,10 +304,10 @@ fextl::vector<MemoryRegion> StealMemoryRegion(uintptr_t Begin, uintptr_t End) {
|
||||
return Regions;
|
||||
}
|
||||
|
||||
void Setup48BitAllocatorIfExists() {
|
||||
fextl::vector<MemoryRegion> Setup48BitAllocatorIfExists() {
|
||||
size_t Bits = FEXCore::Allocator::DetermineVASize();
|
||||
if (Bits < 48) {
|
||||
return;
|
||||
return {};
|
||||
}
|
||||
|
||||
uintptr_t Begin48BitVA = 0x0'8000'0000'0000ULL;
|
||||
@@ -316,6 +316,8 @@ void Setup48BitAllocatorIfExists() {
|
||||
|
||||
Alloc64 = Alloc::OSAllocator::Create64BitAllocatorWithRegions(Regions);
|
||||
AssignHookOverrides();
|
||||
|
||||
return Regions;
|
||||
}
|
||||
|
||||
void ReclaimMemoryRegion(const fextl::vector<MemoryRegion>& Regions) {
|
||||
|
||||
@@ -86,7 +86,7 @@ FEX_DEFAULT_VISIBILITY void ReclaimMemoryRegion(const fextl::vector<MemoryRegion
|
||||
// AArch64 canonical addresses are only up to bits 48/52 with the remainder being other things
|
||||
// Use this to reserve the top 128TB of VA so the guest never see it
|
||||
// Returns nullptr on host VA < 48bits
|
||||
FEX_DEFAULT_VISIBILITY void Setup48BitAllocatorIfExists();
|
||||
FEX_DEFAULT_VISIBILITY fextl::vector<MemoryRegion> Setup48BitAllocatorIfExists();
|
||||
|
||||
#ifndef _WIN32
|
||||
FEX_DEFAULT_VISIBILITY void RegisterTLSData(FEXCore::Core::InternalThreadState* Thread);
|
||||
|
||||
@@ -491,11 +491,12 @@ int main(int argc, char** argv, char** const envp) {
|
||||
FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0");
|
||||
|
||||
fextl::unique_ptr<FEX::HLE::MemAllocator> Allocator;
|
||||
fextl::vector<FEXCore::Allocator::MemoryRegion> Base48Bit;
|
||||
fextl::vector<FEXCore::Allocator::MemoryRegion> Low4GB;
|
||||
|
||||
if (Loader.Is64BitMode()) {
|
||||
// Destroy the 48th bit if it exists
|
||||
FEXCore::Allocator::Setup48BitAllocatorIfExists();
|
||||
Base48Bit = FEXCore::Allocator::Setup48BitAllocatorIfExists();
|
||||
} else {
|
||||
// Reserve [0x1_0000_0000, 0x2_0000_0000).
|
||||
// Safety net if 32-bit address calculation overflows in to 64-bit range.
|
||||
@@ -684,6 +685,7 @@ int main(int argc, char** argv, char** const envp) {
|
||||
LogMan::Msg::UnInstallHandler();
|
||||
|
||||
FEXCore::Allocator::ClearHooks();
|
||||
FEXCore::Allocator::ReclaimMemoryRegion(Base48Bit);
|
||||
FEXCore::Allocator::ReclaimMemoryRegion(Low4GB);
|
||||
|
||||
// Allocator is now original system allocator
|
||||
|
||||
Reference in new issue
Block a user