diff options
Diffstat (limited to 'src/3rdParty/lua/lgc.c')
-rw-r--r-- | src/3rdParty/lua/lgc.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/3rdParty/lua/lgc.c b/src/3rdParty/lua/lgc.c index 2e74990..253a289 100644 --- a/src/3rdParty/lua/lgc.c +++ b/src/3rdParty/lua/lgc.c | |||
@@ -542,10 +542,12 @@ static void traversestrongtable (global_State *g, Table *h) { | |||
542 | static lu_mem traversetable (global_State *g, Table *h) { | 542 | static lu_mem traversetable (global_State *g, Table *h) { |
543 | const char *weakkey, *weakvalue; | 543 | const char *weakkey, *weakvalue; |
544 | const TValue *mode = gfasttm(g, h->metatable, TM_MODE); | 544 | const TValue *mode = gfasttm(g, h->metatable, TM_MODE); |
545 | TString *smode; | ||
545 | markobjectN(g, h->metatable); | 546 | markobjectN(g, h->metatable); |
546 | if (mode && ttisstring(mode) && /* is there a weak mode? */ | 547 | if (mode && ttisshrstring(mode) && /* is there a weak mode? */ |
547 | (cast_void(weakkey = strchr(svalue(mode), 'k')), | 548 | (cast_void(smode = tsvalue(mode)), |
548 | cast_void(weakvalue = strchr(svalue(mode), 'v')), | 549 | cast_void(weakkey = strchr(getshrstr(smode), 'k')), |
550 | cast_void(weakvalue = strchr(getshrstr(smode), 'v')), | ||
549 | (weakkey || weakvalue))) { /* is really weak? */ | 551 | (weakkey || weakvalue))) { /* is really weak? */ |
550 | if (!weakkey) /* strong keys? */ | 552 | if (!weakkey) /* strong keys? */ |
551 | traverseweakvalue(g, h); | 553 | traverseweakvalue(g, h); |
@@ -638,7 +640,9 @@ static int traversethread (global_State *g, lua_State *th) { | |||
638 | for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) | 640 | for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) |
639 | markobject(g, uv); /* open upvalues cannot be collected */ | 641 | markobject(g, uv); /* open upvalues cannot be collected */ |
640 | if (g->gcstate == GCSatomic) { /* final traversal? */ | 642 | if (g->gcstate == GCSatomic) { /* final traversal? */ |
641 | for (; o < th->stack_last.p + EXTRA_STACK; o++) | 643 | if (!g->gcemergency) |
644 | luaD_shrinkstack(th); /* do not change stack in emergency cycle */ | ||
645 | for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++) | ||
642 | setnilvalue(s2v(o)); /* clear dead stack slice */ | 646 | setnilvalue(s2v(o)); /* clear dead stack slice */ |
643 | /* 'remarkupvals' may have removed thread from 'twups' list */ | 647 | /* 'remarkupvals' may have removed thread from 'twups' list */ |
644 | if (!isintwups(th) && th->openupval != NULL) { | 648 | if (!isintwups(th) && th->openupval != NULL) { |
@@ -646,8 +650,6 @@ static int traversethread (global_State *g, lua_State *th) { | |||
646 | g->twups = th; | 650 | g->twups = th; |
647 | } | 651 | } |
648 | } | 652 | } |
649 | else if (!g->gcemergency) | ||
650 | luaD_shrinkstack(th); /* do not change stack in emergency cycle */ | ||
651 | return 1 + stacksize(th); | 653 | return 1 + stacksize(th); |
652 | } | 654 | } |
653 | 655 | ||
@@ -1409,7 +1411,7 @@ static void stepgenfull (lua_State *L, global_State *g) { | |||
1409 | setminordebt(g); | 1411 | setminordebt(g); |
1410 | } | 1412 | } |
1411 | else { /* another bad collection; stay in incremental mode */ | 1413 | else { /* another bad collection; stay in incremental mode */ |
1412 | g->GCestimate = gettotalbytes(g); /* first estimate */; | 1414 | g->GCestimate = gettotalbytes(g); /* first estimate */ |
1413 | entersweep(L); | 1415 | entersweep(L); |
1414 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ | 1416 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ |
1415 | setpause(g); | 1417 | setpause(g); |
@@ -1604,7 +1606,7 @@ static lu_mem singlestep (lua_State *L) { | |||
1604 | case GCSenteratomic: { | 1606 | case GCSenteratomic: { |
1605 | work = atomic(L); /* work is what was traversed by 'atomic' */ | 1607 | work = atomic(L); /* work is what was traversed by 'atomic' */ |
1606 | entersweep(L); | 1608 | entersweep(L); |
1607 | g->GCestimate = gettotalbytes(g); /* first estimate */; | 1609 | g->GCestimate = gettotalbytes(g); /* first estimate */ |
1608 | break; | 1610 | break; |
1609 | } | 1611 | } |
1610 | case GCSswpallgc: { /* sweep "regular" objects */ | 1612 | case GCSswpallgc: { /* sweep "regular" objects */ |
@@ -1681,12 +1683,15 @@ static void incstep (lua_State *L, global_State *g) { | |||
1681 | } | 1683 | } |
1682 | 1684 | ||
1683 | /* | 1685 | /* |
1684 | ** performs a basic GC step if collector is running | 1686 | ** Performs a basic GC step if collector is running. (If collector is |
1687 | ** not running, set a reasonable debt to avoid it being called at | ||
1688 | ** every single check.) | ||
1685 | */ | 1689 | */ |
1686 | void luaC_step (lua_State *L) { | 1690 | void luaC_step (lua_State *L) { |
1687 | global_State *g = G(L); | 1691 | global_State *g = G(L); |
1688 | lua_assert(!g->gcemergency); | 1692 | if (!gcrunning(g)) /* not running? */ |
1689 | if (gcrunning(g)) { /* running? */ | 1693 | luaE_setdebt(g, -2000); |
1694 | else { | ||
1690 | if(isdecGCmodegen(g)) | 1695 | if(isdecGCmodegen(g)) |
1691 | genstep(L, g); | 1696 | genstep(L, g); |
1692 | else | 1697 | else |
@@ -1707,6 +1712,8 @@ static void fullinc (lua_State *L, global_State *g) { | |||
1707 | entersweep(L); /* sweep everything to turn them back to white */ | 1712 | entersweep(L); /* sweep everything to turn them back to white */ |
1708 | /* finish any pending sweep phase to start a new cycle */ | 1713 | /* finish any pending sweep phase to start a new cycle */ |
1709 | luaC_runtilstate(L, bitmask(GCSpause)); | 1714 | luaC_runtilstate(L, bitmask(GCSpause)); |
1715 | luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */ | ||
1716 | g->gcstate = GCSenteratomic; /* go straight to atomic phase ??? */ | ||
1710 | luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ | 1717 | luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ |
1711 | /* estimate must be correct after a full GC cycle */ | 1718 | /* estimate must be correct after a full GC cycle */ |
1712 | lua_assert(g->GCestimate == gettotalbytes(g)); | 1719 | lua_assert(g->GCestimate == gettotalbytes(g)); |