aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/lgc.c b/lgc.c
index 0f423282..f291cd17 100644
--- a/lgc.c
+++ b/lgc.c
@@ -553,10 +553,12 @@ static void traversestrongtable (global_State *g, Table *h) {
553static lu_mem traversetable (global_State *g, Table *h) { 553static lu_mem traversetable (global_State *g, Table *h) {
554 const char *weakkey, *weakvalue; 554 const char *weakkey, *weakvalue;
555 const TValue *mode = gfasttm(g, h->metatable, TM_MODE); 555 const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
556 TString *smode;
556 markobjectN(g, h->metatable); 557 markobjectN(g, h->metatable);
557 if (mode && ttisstring(mode) && /* is there a weak mode? */ 558 if (mode && ttisshrstring(mode) && /* is there a weak mode? */
558 (cast_void(weakkey = strchr(svalue(mode), 'k')), 559 (cast_void(smode = tsvalue(mode)),
559 cast_void(weakvalue = strchr(svalue(mode), 'v')), 560 cast_void(weakkey = strchr(getshrstr(smode), 'k')),
561 cast_void(weakvalue = strchr(getshrstr(smode), 'v')),
560 (weakkey || weakvalue))) { /* is really weak? */ 562 (weakkey || weakvalue))) { /* is really weak? */
561 if (!weakkey) /* strong keys? */ 563 if (!weakkey) /* strong keys? */
562 traverseweakvalue(g, h); 564 traverseweakvalue(g, h);
@@ -649,7 +651,9 @@ static int traversethread (global_State *g, lua_State *th) {
649 for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) 651 for (uv = th->openupval; uv != NULL; uv = uv->u.open.next)
650 markobject(g, uv); /* open upvalues cannot be collected */ 652 markobject(g, uv); /* open upvalues cannot be collected */
651 if (g->gcstate == GCSatomic) { /* final traversal? */ 653 if (g->gcstate == GCSatomic) { /* final traversal? */
652 for (; o < th->stack_last.p + EXTRA_STACK; o++) 654 if (!g->gcemergency)
655 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
656 for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++)
653 setnilvalue(s2v(o)); /* clear dead stack slice */ 657 setnilvalue(s2v(o)); /* clear dead stack slice */
654 /* 'remarkupvals' may have removed thread from 'twups' list */ 658 /* 'remarkupvals' may have removed thread from 'twups' list */
655 if (!isintwups(th) && th->openupval != NULL) { 659 if (!isintwups(th) && th->openupval != NULL) {
@@ -657,8 +661,6 @@ static int traversethread (global_State *g, lua_State *th) {
657 g->twups = th; 661 g->twups = th;
658 } 662 }
659 } 663 }
660 else if (!g->gcemergency)
661 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
662 return 1 + stacksize(th); 664 return 1 + stacksize(th);
663} 665}
664 666
@@ -1420,7 +1422,7 @@ static void stepgenfull (lua_State *L, global_State *g) {
1420 setminordebt(g); 1422 setminordebt(g);
1421 } 1423 }
1422 else { /* another bad collection; stay in incremental mode */ 1424 else { /* another bad collection; stay in incremental mode */
1423 g->GCestimate = gettotalbytes(g); /* first estimate */; 1425 g->GCestimate = gettotalbytes(g); /* first estimate */
1424 entersweep(L); 1426 entersweep(L);
1425 luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ 1427 luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */
1426 setpause(g); 1428 setpause(g);
@@ -1615,7 +1617,7 @@ static lu_mem singlestep (lua_State *L) {
1615 case GCSenteratomic: { 1617 case GCSenteratomic: {
1616 work = atomic(L); /* work is what was traversed by 'atomic' */ 1618 work = atomic(L); /* work is what was traversed by 'atomic' */
1617 entersweep(L); 1619 entersweep(L);
1618 g->GCestimate = gettotalbytes(g); /* first estimate */; 1620 g->GCestimate = gettotalbytes(g); /* first estimate */
1619 break; 1621 break;
1620 } 1622 }
1621 case GCSswpallgc: { /* sweep "regular" objects */ 1623 case GCSswpallgc: { /* sweep "regular" objects */
@@ -1721,6 +1723,8 @@ static void fullinc (lua_State *L, global_State *g) {
1721 entersweep(L); /* sweep everything to turn them back to white */ 1723 entersweep(L); /* sweep everything to turn them back to white */
1722 /* finish any pending sweep phase to start a new cycle */ 1724 /* finish any pending sweep phase to start a new cycle */
1723 luaC_runtilstate(L, bitmask(GCSpause)); 1725 luaC_runtilstate(L, bitmask(GCSpause));
1726 luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */
1727 g->gcstate = GCSenteratomic; /* go straight to atomic phase ??? */
1724 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ 1728 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */
1725 /* estimate must be correct after a full GC cycle */ 1729 /* estimate must be correct after a full GC cycle */
1726 lua_assert(g->GCestimate == gettotalbytes(g)); 1730 lua_assert(g->GCestimate == gettotalbytes(g));