mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2025-10-30 08:02:29 +00:00
Enable JIT for macOS
This commit is contained in:
parent
7dd81bcb6c
commit
b1fd1e798e
2 changed files with 12 additions and 1 deletions
|
|
@ -227,6 +227,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
void unprotect(void* target_func, uint64_t* old_flags) {
|
void unprotect(void* target_func, uint64_t* old_flags) {
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
pthread_jit_write_protect_np(false);
|
||||||
|
#endif
|
||||||
// Align the address to a page boundary.
|
// Align the address to a page boundary.
|
||||||
uintptr_t page_start = (uintptr_t)target_func;
|
uintptr_t page_start = (uintptr_t)target_func;
|
||||||
int page_size = getpagesize();
|
int page_size = getpagesize();
|
||||||
|
|
@ -238,6 +241,9 @@ void unprotect(void* target_func, uint64_t* old_flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void protect(void* target_func, uint64_t old_flags) {
|
void protect(void* target_func, uint64_t old_flags) {
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
pthread_jit_write_protect_np(true);
|
||||||
|
#endif
|
||||||
// Align the address to a page boundary.
|
// Align the address to a page boundary.
|
||||||
uintptr_t page_start = (uintptr_t)target_func;
|
uintptr_t page_start = (uintptr_t)target_func;
|
||||||
int page_size = getpagesize();
|
int page_size = getpagesize();
|
||||||
|
|
|
||||||
|
|
@ -707,7 +707,12 @@ void recomp::start(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
rdram = (uint8_t*)mmap(NULL, allocation_size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
int map_flags = MAP_ANONYMOUS | MAP_PRIVATE;
|
||||||
|
#if defined(__APPLE__) && defined(__aarch64__)
|
||||||
|
map_flags |= MAP_JIT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rdram = (uint8_t*)mmap(NULL, allocation_size, PROT_NONE, map_flags, -1, 0);
|
||||||
alloc_failed = rdram == reinterpret_cast<uint8_t*>(MAP_FAILED);
|
alloc_failed = rdram == reinterpret_cast<uint8_t*>(MAP_FAILED);
|
||||||
if (!alloc_failed) {
|
if (!alloc_failed) {
|
||||||
// mprotect returns -1 on failure.
|
// mprotect returns -1 on failure.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue