summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2017-03-08 22:59:44 +0100
committerMike Pall <mike>2017-03-08 22:59:44 +0100
commit4e308361bf730ef3d288db5b71489ecf442f738c (patch)
tree2578459d15eaa93433303cd4e6b9b62ab845edba
parentff648369aa1f028750afa517ac095577ed8278d1 (diff)
downloadluajit2-4e308361bf730ef3d288db5b71489ecf442f738c.tar.gz
Fix overly restrictive range calculation in mcode allocation.
Contributed by Alexey Kopytov.
-rw-r--r--src/lj_mcode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index b363136d..f0cf22ca 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -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;