summaryrefslogtreecommitdiff
path: root/src/lj_mcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_mcode.c')
-rw-r--r--src/lj_mcode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index e9921601..be3ea1c0 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -110,10 +110,10 @@ static void mcode_free(jit_State *J, void *p, size_t sz)
110/* Get memory within relative jump distance of our code in 64 bit mode. */ 110/* Get memory within relative jump distance of our code in 64 bit mode. */
111static void *mcode_alloc(jit_State *J, size_t sz, int prot) 111static void *mcode_alloc(jit_State *J, size_t sz, int prot)
112{ 112{
113 /* Target an address in the static assembler code. 113 /* Target an address in the static assembler code (64K aligned).
114 ** Try addresses within a distance of target-1GB+1MB .. target+1GB-1MB. 114 ** Try addresses within a distance of target-1GB+1MB .. target+1GB-1MB.
115 */ 115 */
116 uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler; 116 uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff;
117 const uintptr_t range = (1u<<31) - (1u << 21); 117 const uintptr_t range = (1u<<31) - (1u << 21);
118 int i; 118 int i;
119 /* First try a contiguous area below the last one. */ 119 /* First try a contiguous area below the last one. */
@@ -128,7 +128,7 @@ static void *mcode_alloc(jit_State *J, size_t sz, int prot)
128 uintptr_t hint; 128 uintptr_t hint;
129 void *p; 129 void *p;
130 do { 130 do {
131 hint = LJ_PRNG_BITS(J, 15) << 16; 131 hint = LJ_PRNG_BITS(J, 15) << 16; /* 64K aligned. */
132 } while (!(hint + sz < range && 132 } while (!(hint + sz < range &&
133 target + hint - (range>>1) < (uintptr_t)1<<47)); 133 target + hint - (range>>1) < (uintptr_t)1<<47));
134 p = mcode_alloc_at(J, target + hint - (range>>1), sz, prot); 134 p = mcode_alloc_at(J, target + hint - (range>>1), sz, prot);