JIT compiler update and disable wrong assert.
This commit is contained in:
parent
90ae0ae01e
commit
f768448fd3
|
@ -1050,8 +1050,8 @@ switch(*cc)
|
||||||
return cc + 1 + 2 + cc[1];
|
return cc + 1 + 2 + cc[1];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* All opcodes are supported now! */
|
/* Unsupported opcodes: OP_ASSERT_NA and OP_ASSERTBACK_NA */
|
||||||
SLJIT_UNREACHABLE();
|
/* SLJIT_UNREACHABLE(); */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,10 +118,20 @@ static SLJIT_INLINE int get_map_jit_flag()
|
||||||
if (map_jit_flag == -1) {
|
if (map_jit_flag == -1) {
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
|
|
||||||
|
map_jit_flag = 0;
|
||||||
uname(&name);
|
uname(&name);
|
||||||
|
|
||||||
/* Kernel version for 10.14.0 (Mojave) */
|
/* Kernel version for 10.14.0 (Mojave) */
|
||||||
map_jit_flag = (atoi(name.release) >= 18) ? MAP_JIT : 0;
|
if (atoi(name.release) >= 18) {
|
||||||
|
/* Only use MAP_JIT if a hardened runtime is used, because MAP_JIT is incompatible with fork(). */
|
||||||
|
void *ptr = mmap(NULL, getpagesize(), PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||||
|
|
||||||
|
if (ptr == MAP_FAILED) {
|
||||||
|
map_jit_flag = MAP_JIT;
|
||||||
|
} else {
|
||||||
|
munmap(ptr, getpagesize());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map_jit_flag;
|
return map_jit_flag;
|
||||||
|
@ -137,6 +147,7 @@ static SLJIT_INLINE int get_map_jit_flag()
|
||||||
static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
|
static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
|
||||||
{
|
{
|
||||||
void *retval;
|
void *retval;
|
||||||
|
const int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
|
||||||
|
|
||||||
#ifdef MAP_ANON
|
#ifdef MAP_ANON
|
||||||
|
|
||||||
|
@ -146,16 +157,25 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
|
||||||
flags |= get_map_jit_flag();
|
flags |= get_map_jit_flag();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, flags, -1, 0);
|
retval = mmap(NULL, size, prot, flags, -1, 0);
|
||||||
#else /* !MAP_ANON */
|
#else /* !MAP_ANON */
|
||||||
if (dev_zero < 0) {
|
if (dev_zero < 0) {
|
||||||
if (open_dev_zero())
|
if (open_dev_zero())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0);
|
retval = mmap(NULL, size, prot, MAP_PRIVATE, dev_zero, 0);
|
||||||
#endif /* MAP_ANON */
|
#endif /* MAP_ANON */
|
||||||
|
|
||||||
return (retval != MAP_FAILED) ? retval : NULL;
|
if (retval == MAP_FAILED)
|
||||||
|
retval = NULL;
|
||||||
|
else {
|
||||||
|
if (mprotect(retval, size, prot) < 0) {
|
||||||
|
munmap(retval, size);
|
||||||
|
retval = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
|
static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
|
||||||
|
|
|
@ -154,7 +154,13 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void)
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#else
|
#else
|
||||||
/* Provides mmap function. */
|
/* Provides mmap function. */
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#ifndef MAP_ANON
|
||||||
|
#ifdef MAP_ANONYMOUS
|
||||||
|
#define MAP_ANON MAP_ANONYMOUS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
/* For detecting the page size. */
|
/* For detecting the page size. */
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue