aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lgc.c b/lgc.c
index f68c5af0..81682454 100644
--- a/lgc.c
+++ b/lgc.c
@@ -533,10 +533,12 @@ static void traversestrongtable (global_State *g, Table *h) {
533static void traversetable (global_State *g, Table *h) { 533static void traversetable (global_State *g, Table *h) {
534 const char *weakkey, *weakvalue; 534 const char *weakkey, *weakvalue;
535 const TValue *mode = gfasttm(g, h->metatable, TM_MODE); 535 const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
536 TString *smode;
536 markobjectN(g, h->metatable); 537 markobjectN(g, h->metatable);
537 if (mode && ttisstring(mode) && /* is there a weak mode? */ 538 if (mode && ttisshrstring(mode) && /* is there a weak mode? */
538 (cast_void(weakkey = strchr(svalue(mode), 'k')), 539 (cast_void(smode = tsvalue(mode)),
539 cast_void(weakvalue = strchr(svalue(mode), 'v')), 540 cast_void(weakkey = strchr(getshrstr(smode), 'k')),
541 cast_void(weakvalue = strchr(getshrstr(smode), 'v')),
540 (weakkey || weakvalue))) { /* is really weak? */ 542 (weakkey || weakvalue))) { /* is really weak? */
541 if (!weakkey) /* strong keys? */ 543 if (!weakkey) /* strong keys? */
542 traverseweakvalue(g, h); 544 traverseweakvalue(g, h);
@@ -624,7 +626,9 @@ static void traversethread (global_State *g, lua_State *th) {
624 for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) 626 for (uv = th->openupval; uv != NULL; uv = uv->u.open.next)
625 markobject(g, uv); /* open upvalues cannot be collected */ 627 markobject(g, uv); /* open upvalues cannot be collected */
626 if (g->gcstate == GCSatomic) { /* final traversal? */ 628 if (g->gcstate == GCSatomic) { /* final traversal? */
627 for (; o < th->stack_last.p + EXTRA_STACK; o++) 629 if (!g->gcemergency)
630 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
631 for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++)
628 setnilvalue(s2v(o)); /* clear dead stack slice */ 632 setnilvalue(s2v(o)); /* clear dead stack slice */
629 /* 'remarkupvals' may have removed thread from 'twups' list */ 633 /* 'remarkupvals' may have removed thread from 'twups' list */
630 if (!isintwups(th) && th->openupval != NULL) { 634 if (!isintwups(th) && th->openupval != NULL) {
@@ -632,8 +636,6 @@ static void traversethread (global_State *g, lua_State *th) {
632 g->twups = th; 636 g->twups = th;
633 } 637 }
634 } 638 }
635 else if (!g->gcemergency)
636 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
637} 639}
638 640
639 641
@@ -1644,6 +1646,8 @@ static void fullinc (lua_State *L, global_State *g) {
1644 entersweep(L); /* sweep everything to turn them back to white */ 1646 entersweep(L); /* sweep everything to turn them back to white */
1645 /* finish any pending sweep phase to start a new cycle */ 1647 /* finish any pending sweep phase to start a new cycle */
1646 luaC_runtilstate(L, bitmask(GCSpause)); 1648 luaC_runtilstate(L, bitmask(GCSpause));
1649 luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */
1650 g->gcstate = GCSenteratomic; /* go straight to atomic phase ??? */
1647 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ 1651 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */
1648 /* 'marked' must be correct after a full GC cycle */ 1652 /* 'marked' must be correct after a full GC cycle */
1649 lua_assert(g->marked == gettotalobjs(g)); 1653 lua_assert(g->marked == gettotalobjs(g));