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.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index 8d0f7213..279854f8 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -162,20 +162,7 @@ static void mcode_protect(jit_State *J, int prot)
162#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000) 162#define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000)
163#endif 163#endif
164 164
165#if LJ_TARGET_X64 165#ifdef LJ_TARGET_JUMPRANGE
166#define MCODE_JUMPRANGE 31
167#elif LJ_TARGET_ARM
168#define MCODE_JUMPRANGE 26
169#else
170#define MCODE_JUMPRANGE 32
171#endif
172
173#if MCODE_JUMPRANGE == 32
174
175/* All 32 bit memory addresses are reachable by relative jumps. */
176#define mcode_alloc(J, sz) mcode_alloc_at((J), 0, (sz), MCPROT_GEN)
177
178#else
179 166
180/* Get memory within relative jump distance of our code in 64 bit mode. */ 167/* Get memory within relative jump distance of our code in 64 bit mode. */
181static void *mcode_alloc(jit_State *J, size_t sz) 168static void *mcode_alloc(jit_State *J, size_t sz)
@@ -184,7 +171,7 @@ static void *mcode_alloc(jit_State *J, size_t sz)
184 ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB. 171 ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB.
185 */ 172 */
186 uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff; 173 uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff;
187 const uintptr_t range = (1u << MCODE_JUMPRANGE) - (1u << 21); 174 const uintptr_t range = (1u << LJ_TARGET_JUMPRANGE) - (1u << 21);
188 /* First try a contiguous area below the last one. */ 175 /* First try a contiguous area below the last one. */
189 uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; 176 uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
190 int i; 177 int i;
@@ -208,6 +195,11 @@ static void *mcode_alloc(jit_State *J, size_t sz)
208 return NULL; 195 return NULL;
209} 196}
210 197
198#else
199
200/* All memory addresses are reachable by relative jumps. */
201#define mcode_alloc(J, sz) mcode_alloc_at((J), 0, (sz), MCPROT_GEN)
202
211#endif 203#endif
212 204
213/* -- MCode area management ----------------------------------------------- */ 205/* -- MCode area management ----------------------------------------------- */