MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / sweep2old

Function sweep2old

lib/lua/src/lgc.c:1079–1101  ·  view source on GitHub ↗

** Sweep a list of objects to enter generational mode. Deletes dead ** objects and turns the non dead to old. All non-dead threads---which ** are now old---must be in a gray list. Everything else is not in a ** gray list. Open upvalues are also kept gray. */

Source from the content-addressed store, hash-verified

1077** gray list. Open upvalues are also kept gray.
1078*/
1079static void sweep2old (lua_State *L, GCObject **p) {
1080 GCObject *curr;
1081 global_State *g = G(L);
1082 while ((curr = *p) != NULL) {
1083 if (iswhite(curr)) { /* is 'curr' dead? */
1084 lua_assert(isdead(g, curr));
1085 *p = curr->next; /* remove 'curr' from list */
1086 freeobj(L, curr); /* erase 'curr' */
1087 }
1088 else { /* all surviving objects become old */
1089 setage(curr, G_OLD);
1090 if (curr->tt == LUA_VTHREAD) { /* threads must be watched */
1091 lua_State *th = gco2th(curr);
1092 linkgclist(th, g->grayagain); /* insert into 'grayagain' list */
1093 }
1094 else if (curr->tt == LUA_VUPVAL && upisopen(gco2upv(curr)))
1095 set2gray(curr); /* open upvalues are always gray */
1096 else /* everything else is black */
1097 nw2black(curr);
1098 p = &curr->next; /* go to next element */
1099 }
1100 }
1101}
1102
1103
1104/*

Callers 1

atomic2genFunction · 0.85

Calls 2

freeobjFunction · 0.85
GFunction · 0.50

Tested by

no test coverage detected