macOS: Add support for Apple Silicon and usage of the MAP_JIT flag.
This commit is contained in:
parent
f63b06f5f6
commit
33da24d0e2
3 changed files with 22 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#if defined __APPLE__ && defined __aarch64__
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
#include "ibm.h"
|
#include "ibm.h"
|
||||||
#include "x86.h"
|
#include "x86.h"
|
||||||
#include "x86_ops.h"
|
#include "x86_ops.h"
|
||||||
|
|
@ -410,6 +413,9 @@ static inline void exec_recompiler(void)
|
||||||
|
|
||||||
cpu_new_blocks++;
|
cpu_new_blocks++;
|
||||||
|
|
||||||
|
#if defined __APPLE__ && defined __aarch64__
|
||||||
|
pthread_jit_write_protect_np(0);
|
||||||
|
#endif
|
||||||
codegen_block_start_recompile(block);
|
codegen_block_start_recompile(block);
|
||||||
codegen_in_recompile = 1;
|
codegen_in_recompile = 1;
|
||||||
|
|
||||||
|
|
@ -481,6 +487,9 @@ static inline void exec_recompiler(void)
|
||||||
codegen_reset();
|
codegen_reset();
|
||||||
|
|
||||||
codegen_in_recompile = 0;
|
codegen_in_recompile = 0;
|
||||||
|
#if defined __APPLE__ && defined __aarch64__
|
||||||
|
pthread_jit_write_protect_np(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (!cpu_state.abrt)
|
else if (!cpu_state.abrt)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ void codegen_allocator_init()
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32 || defined _WIN32
|
||||||
mem_block_alloc = VirtualAlloc(NULL, MEM_BLOCK_NR * MEM_BLOCK_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
mem_block_alloc = VirtualAlloc(NULL, MEM_BLOCK_NR * MEM_BLOCK_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
|
/* TODO: check deployment target: older Intel-based versions of macOS don't play
|
||||||
|
nice with MAP_JIT. */
|
||||||
|
#elif defined(__APPLE__) && defined(MAP_JIT)
|
||||||
|
mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE|MAP_JIT, 0, 0);
|
||||||
#else
|
#else
|
||||||
mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, 0, 0);
|
mem_block_alloc = mmap(0, MEM_BLOCK_NR * MEM_BLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
9
src/pc.c
9
src/pc.c
|
|
@ -1,6 +1,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#if defined(__APPLE__) && defined(__aarch64__)
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
#include "ibm.h"
|
#include "ibm.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
|
|
@ -307,7 +310,13 @@ void initpc(int argc, char *argv[])
|
||||||
loadbios();
|
loadbios();
|
||||||
mem_add_bios();
|
mem_add_bios();
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__aarch64__)
|
||||||
|
pthread_jit_write_protect_np(0);
|
||||||
|
#endif
|
||||||
codegen_init();
|
codegen_init();
|
||||||
|
#if defined(__APPLE__) && defined(__aarch64__)
|
||||||
|
pthread_jit_write_protect_np(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
timer_reset();
|
timer_reset();
|
||||||
sound_reset();
|
sound_reset();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue