diff options
| -rw-r--r-- | lgc.c | 6 | ||||
| -rw-r--r-- | llimits.h | 9 |
2 files changed, 12 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.228 2017/05/04 13:32:01 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.229 2017/05/26 19:14:29 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -1486,7 +1486,9 @@ void luaC_runtilstate (lua_State *L, int statesmask) { | |||
| 1486 | static void incstep (lua_State *L, global_State *g) { | 1486 | static void incstep (lua_State *L, global_State *g) { |
| 1487 | int stepmul = (g->gcstepmul | 1); /* avoid division by 0 */ | 1487 | int stepmul = (g->gcstepmul | 1); /* avoid division by 0 */ |
| 1488 | l_mem debt = (g->GCdebt / WORK2MEM) * stepmul; | 1488 | l_mem debt = (g->GCdebt / WORK2MEM) * stepmul; |
| 1489 | l_mem stepsize = cast(l_mem, 1) << g->gcstepsize; | 1489 | l_mem stepsize = (g->gcstepsize <= log2maxs(l_mem)) |
| 1490 | ? cast(l_mem, 1) << g->gcstepsize | ||
| 1491 | : MAX_LMEM; | ||
| 1490 | stepsize = -((stepsize / WORK2MEM) * stepmul); | 1492 | stepsize = -((stepsize / WORK2MEM) * stepmul); |
| 1491 | do { /* repeat until pause or enough "credit" (negative debt) */ | 1493 | do { /* repeat until pause or enough "credit" (negative debt) */ |
| 1492 | lu_mem work = singlestep(L); /* perform one single step */ | 1494 | lu_mem work = singlestep(L); /* perform one single step */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llimits.h,v 1.141 2015/11/19 19:16:22 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.142 2017/04/24 18:06:12 roberto Exp roberto $ |
| 3 | ** Limits, basic types, and some other 'installation-dependent' definitions | 3 | ** Limits, basic types, and some other 'installation-dependent' definitions |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -52,6 +52,13 @@ typedef unsigned char lu_byte; | |||
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | /* | 54 | /* |
| 55 | ** floor of the log2 of the maximum signed value for integral type 't'. | ||
| 56 | ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) | ||
| 57 | */ | ||
| 58 | #define log2maxs(t) (sizeof(t) * 8 - 2) | ||
| 59 | |||
| 60 | |||
| 61 | /* | ||
| 55 | ** conversion of pointer to unsigned integer: | 62 | ** conversion of pointer to unsigned integer: |
| 56 | ** this is for hashing only; there is no problem if the integer | 63 | ** this is for hashing only; there is no problem if the integer |
| 57 | ** cannot hold the whole pointer value | 64 | ** cannot hold the whole pointer value |
