Skip to content

Commit

Permalink
Merge pull request FEX-Emu#3570 from bylaws/ec_pt8
Browse files Browse the repository at this point in the history
Enable jemalloc for ARM64EC
  • Loading branch information
Sonicadvance1 authored Apr 11, 2024
2 parents ae5e388 + 7ff4cd9 commit a9b7ad8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
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

0 comments on commit a9b7ad8

Please sign in to comment.