Skip to content

Commit

Permalink
Merge pull request #3346 from Sonicadvance1/remove_32bit_allocator
Browse files Browse the repository at this point in the history
FEX: Removes legacy kernel 32-bit allocator
  • Loading branch information
Sonicadvance1 authored Dec 22, 2023
2 parents b1c3737 + 1c34b25 commit de2cd46
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 43 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
BUILD_TYPE: Release
CC: clang
CXX: clang++
FEX_FORCE32BITALLOCATOR: 1
FEX_ENABLEAVX: 1

jobs:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/glibc_fault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ env:
BUILD_TYPE: Release
CC: clang
CXX: clang++
FEX_FORCE32BITALLOCATOR: 1
FEX_ENABLEAVX: 1

jobs:
Expand Down
10 changes: 0 additions & 10 deletions FEXCore/Source/Interface/Config/Config.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,6 @@
"Set to false to disable Static Register Allocation"
]
},
"Force32BitAllocator": {
"Type": "bool",
"Default": "false",
"Desc": [
"Forces use of the 32-bit allocator on 32-bit applications",
"Used to work around ulimit problems of CI runner",
"Potentially useful for debugging memory problems",
"32-bit allocator is always used if your host kernel is older than 4.17"
]
},
"GlobalJITNaming": {
"Type": "bool",
"Default": "false",
Expand Down
32 changes: 12 additions & 20 deletions Source/Tools/FEXLoader/FEXLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,26 +423,18 @@ int main(int argc, char **argv, char **const envp) {
Base48Bit = FEXCore::Allocator::Steal48BitVA();
} else {
// Setup our userspace allocator

FEX_CONFIG_OPT(Use32BitAllocator, FORCE32BITALLOCATOR);
const bool is_legacy_kernel = (KernelVersion < FEX::HLE::SyscallHandler::KernelVersion(4, 17));

if (Use32BitAllocator || is_legacy_kernel) {
Allocator = FEX::HLE::Create32BitAllocator();
} else {
FEXCore::Allocator::SetupHooks();
Allocator = FEX::HLE::CreatePassthroughAllocator();

// Now that the upper 32-bit address space is blocked for future allocations,
// exhaust all of jemalloc's remaining internal allocations that it reserved before.
// TODO: It's unclear how reliably this exhausts those reserves
FEXCore::Allocator::YesIKnowImNotSupposedToUseTheGlibcAllocator glibc;
void* data;
do {
data = malloc(0x1);
} while (reinterpret_cast<uintptr_t>(data) >> 32 != 0);
free(data);
}
FEXCore::Allocator::SetupHooks();
Allocator = FEX::HLE::CreatePassthroughAllocator();

// Now that the upper 32-bit address space is blocked for future allocations,
// exhaust all of jemalloc's remaining internal allocations that it reserved before.
// TODO: It's unclear how reliably this exhausts those reserves
FEXCore::Allocator::YesIKnowImNotSupposedToUseTheGlibcAllocator glibc;
void* data;
do {
data = malloc(0x1);
} while (reinterpret_cast<uintptr_t>(data) >> 32 != 0);
free(data);
}

// System allocator is now system allocator or FEX
Expand Down
13 changes: 2 additions & 11 deletions Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,8 @@ int main(int argc, char **argv, char **const envp) {

if (!Loader.Is64BitMode()) {
// Setup our userspace allocator
uint32_t KernelVersion = FEX::HLE::SyscallHandler::CalculateHostKernelVersion();
if (KernelVersion >= FEX::HLE::SyscallHandler::KernelVersion(4, 17)) {
FEXCore::Allocator::SetupHooks();
}

if (KernelVersion < FEX::HLE::SyscallHandler::KernelVersion(4, 17)) {
Allocator = FEX::HLE::Create32BitAllocator();
}
else {
Allocator = FEX::HLE::CreatePassthroughAllocator();
}
FEXCore::Allocator::SetupHooks();
Allocator = FEX::HLE::CreatePassthroughAllocator();
}
#endif

Expand Down

0 comments on commit de2cd46

Please sign in to comment.