File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/*
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 $
33** Garbage Collector
44** See Copyright Notice in lua.h
55*/
@@ -1486,7 +1486,9 @@ void luaC_runtilstate (lua_State *L, int statesmask) {
14861486static void incstep (lua_State * L , global_State * g ) {
14871487 int stepmul = (g -> gcstepmul | 1 ); /* avoid division by 0 */
14881488 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 ;
14901492 stepsize = - ((stepsize / WORK2MEM ) * stepmul );
14911493 do { /* repeat until pause or enough "credit" (negative debt) */
14921494 lu_mem work = singlestep (L ); /* perform one single step */
Original file line number Diff line number Diff line change 11/*
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 $
33** Limits, basic types, and some other 'installation-dependent' definitions
44** See Copyright Notice in lua.h
55*/
@@ -51,6 +51,13 @@ typedef unsigned char lu_byte;
5151#define MAX_INT INT_MAX /* maximum value of an int */
5252
5353
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+
5461/*
5562** conversion of pointer to unsigned integer:
5663** this is for hashing only; there is no problem if the integer
You can’t perform that action at this time.
0 commit comments