]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix jump-range constrained mcode allocation.
authorMike Pall <mike>
Fri, 5 Apr 2013 18:22:41 +0000 (20:22 +0200)
committerMike Pall <mike>
Fri, 5 Apr 2013 18:22:41 +0000 (20:22 +0200)
src/lj_mcode.c

index 5f7582c4833ae9f568934de1e599a4f4f928a62e..cb79e8cdd7fd889774eb5274adf5219bb5d9766f 100644 (file)
@@ -206,6 +206,7 @@ static void *mcode_alloc(jit_State *J, size_t sz)
 {
   /* Target an address in the static assembler code (64K aligned).
   ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB.
+  ** Use half the jump range so every address in the range can reach any other.
   */
 #if LJ_TARGET_MIPS
   /* Use the middle of the 256MB-aligned region. */
@@ -214,7 +215,7 @@ static void *mcode_alloc(jit_State *J, size_t sz)
 #else
   uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff;
 #endif
-  const uintptr_t range = (1u << LJ_TARGET_JUMPRANGE) - (1u << 21);
+  const uintptr_t range = (1u << (LJ_TARGET_JUMPRANGE-1)) - (1u << 21);
   /* First try a contiguous area below the last one. */
   uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
   int i;