]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Limit mcode alloc probing, depending on the available pool size.
authorMike Pall <mike>
Wed, 8 Mar 2017 22:01:47 +0000 (23:01 +0100)
committerMike Pall <mike>
Wed, 8 Mar 2017 22:01:47 +0000 (23:01 +0100)
Contributed by Alexey Kopytov.

src/lj_mcode.c

index f0cf22ca178ecb654db607dcd4faa83791a7262b..bb7cf96baae105897432a63132cf1ed91f7ce77b 100644 (file)
@@ -230,7 +230,8 @@ static void *mcode_alloc(jit_State *J, size_t sz)
   /* First try a contiguous area below the last one. */
   uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
   int i;
-  for (i = 0; i < 32; i++) {  /* 32 attempts ought to be enough ... */
+  /* Limit probing iterations, depending on the available pool size. */
+  for (i = 0; i < LJ_TARGET_JUMPRANGE; i++) {
     if (mcode_validptr(hint)) {
       void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN);