Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable jemalloc for ARM64EC #3570

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ endif()
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm64ec")
set(_M_ARM_64EC 1)
add_definitions(-D_M_ARM_64EC=1)

# Required as FEX is not allowed to lock the CRT heap lock during compilation or callbacks
set(ENABLE_JEMALLOC TRUE)
endif()

if (ENABLE_CCACHE)
Expand Down
24 changes: 12 additions & 12 deletions FEXCore/include/FEXCore/Utils/AllocatorHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,18 @@ namespace FEXCore::Allocator {
#endif

// Memory allocation routines aliased to jemalloc functions.
#ifdef _WIN32
#ifdef ENABLE_JEMALLOC
inline void *malloc(size_t size) { return ::je_malloc(size); }
inline void *calloc(size_t n, size_t size) { return ::je_calloc(n, size); }
inline void *memalign(size_t align, size_t s) { return ::je_memalign(align, s); }
inline void *valloc(size_t size) { return ::je_valloc(size); }
inline int posix_memalign(void** r, size_t a, size_t s) { return ::je_posix_memalign(r, a, s); }
inline void *realloc(void* ptr, size_t size) { return ::je_realloc(ptr, size); }
inline void free(void* ptr) { return ::je_free(ptr); }
inline size_t malloc_usable_size(void *ptr) { return ::je_malloc_usable_size(ptr); }
inline void *aligned_alloc(size_t a, size_t s) { return ::je_aligned_alloc(a, s); }
inline void aligned_free(void* ptr) { return ::je_free(ptr); }
#elif defined(_WIN32)
inline void *malloc(size_t size) { return ::malloc(size); }
inline void *calloc(size_t n, size_t size) { return ::calloc(n, size); }
inline void *memalign(size_t align, size_t s) { return ::_aligned_malloc(s, align); }
Expand All @@ -110,17 +121,6 @@ namespace FEXCore::Allocator {
inline size_t malloc_usable_size(void *ptr) { return ::_msize(ptr); }
inline void *aligned_alloc(size_t a, size_t s) { return ::_aligned_malloc(s, a); }
inline void aligned_free(void* ptr) { return ::_aligned_free(ptr); }
#elif defined(ENABLE_JEMALLOC)
inline void *malloc(size_t size) { return ::je_malloc(size); }
inline void *calloc(size_t n, size_t size) { return ::je_calloc(n, size); }
inline void *memalign(size_t align, size_t s) { return ::je_memalign(align, s); }
inline void *valloc(size_t size) { return ::je_valloc(size); }
inline int posix_memalign(void** r, size_t a, size_t s) { return ::je_posix_memalign(r, a, s); }
inline void *realloc(void* ptr, size_t size) { return ::je_realloc(ptr, size); }
inline void free(void* ptr) { return ::je_free(ptr); }
inline size_t malloc_usable_size(void *ptr) { return ::je_malloc_usable_size(ptr); }
inline void *aligned_alloc(size_t a, size_t s) { return ::je_aligned_alloc(a, s); }
inline void aligned_free(void* ptr) { return ::je_free(ptr); }
#else
inline void *malloc(size_t size) { return ::malloc(size); }
inline void *calloc(size_t n, size_t size) { return ::calloc(n, size); }
Expand Down
Loading