diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-13 15:45:57 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-13 15:45:57 -0300 |
commit | 5d8b5b9290c932bdfd7dcc670a5af957bdd58392 (patch) | |
tree | 17915e03d62517c47ddf3dd7db6c07596f8d5748 /lgc.c | |
parent | 40565b4a089f44fdcb16f4ed0080b0ca3755e4aa (diff) | |
download | lua-5d8b5b9290c932bdfd7dcc670a5af957bdd58392.tar.gz lua-5d8b5b9290c932bdfd7dcc670a5af957bdd58392.tar.bz2 lua-5d8b5b9290c932bdfd7dcc670a5af957bdd58392.zip |
Changed signal of GC debt
Positive debts seems more natural then negative ones.
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -242,7 +242,7 @@ GCObject *luaC_newobjdt (lua_State *L, int tt, size_t sz, size_t offset) { | |||
242 | global_State *g = G(L); | 242 | global_State *g = G(L); |
243 | char *p = cast_charp(luaM_newobject(L, novariant(tt), sz)); | 243 | char *p = cast_charp(luaM_newobject(L, novariant(tt), sz)); |
244 | GCObject *o = cast(GCObject *, p + offset); | 244 | GCObject *o = cast(GCObject *, p + offset); |
245 | g->GCdebt++; | 245 | g->GCdebt--; |
246 | o->marked = luaC_white(g); | 246 | o->marked = luaC_white(g); |
247 | o->tt = tt; | 247 | o->tt = tt; |
248 | o->next = g->allgc; | 248 | o->next = g->allgc; |
@@ -1034,8 +1034,8 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { | |||
1034 | */ | 1034 | */ |
1035 | static void setpause (global_State *g) { | 1035 | static void setpause (global_State *g) { |
1036 | l_obj threshold = applygcparam(g, gcpause, g->marked); | 1036 | l_obj threshold = applygcparam(g, gcpause, g->marked); |
1037 | l_obj debt = gettotalobjs(g) - threshold; | 1037 | l_obj debt = threshold - gettotalobjs(g); |
1038 | if (debt > 0) debt = 0; | 1038 | if (debt < 0) debt = 0; |
1039 | luaE_setdebt(g, debt); | 1039 | luaE_setdebt(g, debt); |
1040 | } | 1040 | } |
1041 | 1041 | ||
@@ -1285,7 +1285,7 @@ static void atomic2gen (lua_State *L, global_State *g) { | |||
1285 | ** total number of objects grows 'genminormul'%. | 1285 | ** total number of objects grows 'genminormul'%. |
1286 | */ | 1286 | */ |
1287 | static void setminordebt (global_State *g) { | 1287 | static void setminordebt (global_State *g) { |
1288 | luaE_setdebt(g, -applygcparam(g, genminormul, gettotalobjs(g))); | 1288 | luaE_setdebt(g, applygcparam(g, genminormul, gettotalobjs(g))); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | 1291 | ||
@@ -1378,13 +1378,13 @@ static void genmajorstep (lua_State *L, global_State *g) { | |||
1378 | ** Does a generational "step". If the total number of objects grew | 1378 | ** Does a generational "step". If the total number of objects grew |
1379 | ** more than 'majormul'% since the last major collection, does a | 1379 | ** more than 'majormul'% since the last major collection, does a |
1380 | ** major collection. Otherwise, does a minor collection. The test | 1380 | ** major collection. Otherwise, does a minor collection. The test |
1381 | ** ('GCdebt' > 0) avoids major collections when the step originated from | 1381 | ** ('GCdebt' != 0) avoids major collections when the step originated from |
1382 | ** 'collectgarbage("step")'. | 1382 | ** 'collectgarbage("step")'. |
1383 | */ | 1383 | */ |
1384 | static void genstep (lua_State *L, global_State *g) { | 1384 | static void genstep (lua_State *L, global_State *g) { |
1385 | l_obj majorbase = g->GClastmajor; /* count after last major collection */ | 1385 | l_obj majorbase = g->GClastmajor; /* count after last major collection */ |
1386 | l_obj majorinc = applygcparam(g, genmajormul, majorbase); | 1386 | l_obj majorinc = applygcparam(g, genmajormul, majorbase); |
1387 | if (g->GCdebt > 0 && gettotalobjs(g) > majorbase + majorinc) { | 1387 | if (g->GCdebt != 0 && gettotalobjs(g) > majorbase + majorinc) { |
1388 | /* do a major collection */ | 1388 | /* do a major collection */ |
1389 | enterinc(g); | 1389 | enterinc(g); |
1390 | g->gckind = KGC_GENMAJOR; | 1390 | g->gckind = KGC_GENMAJOR; |
@@ -1605,7 +1605,7 @@ static void incstep (lua_State *L, global_State *g) { | |||
1605 | if (g->gcstate == GCSpause) | 1605 | if (g->gcstate == GCSpause) |
1606 | setpause(g); /* pause until next cycle */ | 1606 | setpause(g); /* pause until next cycle */ |
1607 | else { | 1607 | else { |
1608 | luaE_setdebt(g, -stepsize); | 1608 | luaE_setdebt(g, stepsize); |
1609 | } | 1609 | } |
1610 | } | 1610 | } |
1611 | 1611 | ||
@@ -1618,7 +1618,7 @@ void luaC_step (lua_State *L) { | |||
1618 | global_State *g = G(L); | 1618 | global_State *g = G(L); |
1619 | lua_assert(!g->gcemergency); | 1619 | lua_assert(!g->gcemergency); |
1620 | if (!gcrunning(g)) /* not running? */ | 1620 | if (!gcrunning(g)) /* not running? */ |
1621 | luaE_setdebt(g, -2000); | 1621 | luaE_setdebt(g, 2000); |
1622 | else { | 1622 | else { |
1623 | switch (g->gckind) { | 1623 | switch (g->gckind) { |
1624 | case KGC_INC: | 1624 | case KGC_INC: |