|
@ -143,10 +143,14 @@ void jit_free(void *ptr) |
|
|
@*/ |
|
|
@*/ |
|
|
void *jit_malloc_exec(unsigned int size) |
|
|
void *jit_malloc_exec(unsigned int size) |
|
|
{ |
|
|
{ |
|
|
#ifdef JIT_USE_MMAP |
|
|
#if defined(JIT_WIN32_PLATFORM) |
|
|
void *ptr = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, |
|
|
return VirtualAlloc(NULL, size, |
|
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
|
|
MEM_COMMIT | MEM_RESERVE, |
|
|
|
|
|
PAGE_EXECUTE_READWRITE); |
|
|
|
|
|
#elif defined(JIT_USE_MMAP) |
|
|
|
|
|
void *ptr = mmap(0, size, |
|
|
|
|
|
PROT_READ | PROT_WRITE | PROT_EXEC, |
|
|
|
|
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
|
|
if(ptr == (void *)-1) |
|
|
if(ptr == (void *)-1) |
|
|
{ |
|
|
{ |
|
|
return (void *)0; |
|
|
return (void *)0; |
|
@ -169,11 +173,13 @@ void jit_free_exec(void *ptr, unsigned int size) |
|
|
{ |
|
|
{ |
|
|
if(ptr) |
|
|
if(ptr) |
|
|
{ |
|
|
{ |
|
|
#ifdef JIT_USE_MMAP |
|
|
#if defined(JIT_WIN32_PLATFORM) |
|
|
|
|
|
VirtualFree(ptr, size, MEM_DECOMMIT | MEM_RELEASE); |
|
|
|
|
|
#elif defined(JIT_USE_MMAP) |
|
|
munmap(ptr, size); |
|
|
munmap(ptr, size); |
|
|
#else |
|
|
#else |
|
|
free(ptr); |
|
|
free(ptr); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|