Skip to content
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ detect_architecture("__arm__" ARM)
detect_architecture("__aarch64__" ARM64)

cmake_dependent_option(ENABLE_JIT "Enable JIT recompiler" ON
"ARCHITECTURE STREQUAL x86_64 OR ARCHITECTURE STREQUAL ARM64;NOT ARCHITECTURE STREQUAL x86_64 OR NOT APPLE" OFF)
"ARCHITECTURE STREQUAL x86_64 OR ARCHITECTURE STREQUAL ARM64" OFF)
cmake_dependent_option(ENABLE_JIT_PROFILING "Enable JIT profiling with VTune" OFF "ENABLE_JIT" OFF)
option(ENABLE_OGLRENDERER "Enable OpenGL renderer" ON)

Expand Down
16 changes: 6 additions & 10 deletions src/ARMJIT_Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ namespace ARMJIT_Global

std::mutex globalMutex;

#if defined(__APPLE__) && defined(__aarch64__)
#define APPLE_AARCH64
#endif

#if !defined(APPLE_AARCH64) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#if !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
static constexpr size_t NumCodeMemSlices = 4;
static constexpr size_t CodeMemoryAlignedSize = NumCodeMemSlices * CodeMemorySliceSize;

Expand All @@ -46,7 +42,7 @@ void* AllocateCodeMem()
{
std::lock_guard guard(globalMutex);

#if !defined(APPLE_AARCH64) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#if !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
if (AvailableCodeMemSlices)
{
int slice = __builtin_ctz(AvailableCodeMemSlices);
Expand All @@ -59,7 +55,7 @@ void* AllocateCodeMem()
// allocate
#ifdef _WIN32
return VirtualAlloc(nullptr, CodeMemorySliceSize, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#elif defined(APPLE_AARCH64)
#elif defined(__APPLE__) && defined(__aarch64__)
return mmap(NULL, CodeMemorySliceSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_JIT,-1, 0);
#elif defined(__NetBSD__)
return mmap(nullptr, CodeMemorySliceSize, PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC), MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
Expand All @@ -73,7 +69,7 @@ void FreeCodeMem(void* codeMem)
{
std::lock_guard guard(globalMutex);

#if !defined(APPLE_AARCH64) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#if !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
for (int i = 0; i < NumCodeMemSlices; i++)
{
if (codeMem == &GetAlignedCodeMemoryStart()[CodeMemorySliceSize * i])
Expand Down Expand Up @@ -102,8 +98,8 @@ void Init()
#ifdef _WIN32
DWORD dummy;
VirtualProtect(GetAlignedCodeMemoryStart(), CodeMemoryAlignedSize, PAGE_EXECUTE_READWRITE, &dummy);
#elif defined(APPLE_AARCH64) || defined(__NetBSD__) || defined(__OpenBSD__)
// Apple aarch64 always uses dynamic allocation
#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
// these platforms always use dynamic allocation
#else
mprotect(GetAlignedCodeMemoryStart(), CodeMemoryAlignedSize, PROT_EXEC | PROT_READ | PROT_WRITE);
#endif
Expand Down
Loading