]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix overly restrictive range calculation in mcode allocation.
authorMike Pall <mike>
Wed, 8 Mar 2017 21:59:44 +0000 (22:59 +0100)
committerMike Pall <mike>
Wed, 8 Mar 2017 21:59:44 +0000 (22:59 +0100)
Contributed by Alexey Kopytov.

src/lj_mcode.c

index b363136d000e817fa9f5659ad5b41a280f6a0741..f0cf22ca178ecb654db607dcd4faa83791a7262b 100644 (file)
@@ -239,11 +239,11 @@ static void *mcode_alloc(jit_State *J, size_t sz)
        return p;
       if (p) mcode_free(J, p, sz);  /* Free badly placed area. */
     }
-    /* Next try probing pseudo-random addresses. */
+    /* Next try probing 64K-aligned pseudo-random addresses. */
     do {
-      hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16;  /* 64K aligned. */
-    } while (!(hint + sz < range));
-    hint = target + hint - (range>>1);
+      hint = LJ_PRNG_BITS(J, LJ_TARGET_JUMPRANGE-16) << 16;
+    } while (!(hint + sz < range+range));
+    hint = target + hint - range;
   }
   lj_trace_err(J, LJ_TRERR_MCODEAL);  /* Give up. OS probably ignores hints? */
   return NULL;