Skip to content

Commit

Permalink
Fix and debug
Browse files Browse the repository at this point in the history
  • Loading branch information
diegorusso committed Oct 18, 2024
1 parent 2eb5182 commit 9200042
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Python/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ jit_alloc(size_t size)
int failed = memory == NULL;
#elif defined(__APPLE__)
int flags = MAP_ANONYMOUS | MAP_PRIVATE;
int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
int prot = PROT_READ | PROT_WRITE;
if (pthread_jit_write_protect_supported_np()) {
flags |= MAP_JIT;
prot |= PROT_EXEC;
}
unsigned char *memory = mmap(NULL, size, prot, flags, -1, 0);
int failed = memory == MAP_FAILED;
Expand Down Expand Up @@ -114,11 +115,15 @@ mark_executable(unsigned char *memory, size_t size)
int old;
int failed = !VirtualProtect(memory, size, PAGE_EXECUTE_READ, &old);
#elif defined(__APPLE__)
int failed = 0;
__builtin___clear_cache((char *)memory, (char *)memory + size);
if (pthread_jit_write_protect_supported_np()) {
printf("pthread supported\n");
pthread_jit_write_protect_np(1);
} else {
printf("pthread NOT supported\n");
failed = mprotect(memory, size, PROT_EXEC | PROT_READ);
}
int failed = 0;
#else
__builtin___clear_cache((char *)memory, (char *)memory + size);
int failed = mprotect(memory, size, PROT_EXEC | PROT_READ);
Expand Down

0 comments on commit 9200042

Please sign in to comment.