MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / sweep2old

Function sweep2old

3rd/lua-5.4.3/src/lgc.c:1052–1074  ·  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

1050** gray list. Open upvalues are also kept gray.
1051*/
1052static void sweep2old (lua_State *L, GCObject **p) {
1053 GCObject *curr;
1054 global_State *g = G(L);
1055 while ((curr = *p) != NULL) {
1056 if (iswhite(curr)) { /* is 'curr' dead? */
1057 lua_assert(isdead(g, curr));
1058 *p = curr->next; /* remove 'curr' from list */
1059 freeobj(L, curr); /* erase 'curr' */
1060 }
1061 else { /* all surviving objects become old */
1062 setage(curr, G_OLD);
1063 if (curr->tt == LUA_VTHREAD) { /* threads must be watched */
1064 lua_State *th = gco2th(curr);
1065 linkgclist(th, g->grayagain); /* insert into 'grayagain' list */
1066 }
1067 else if (curr->tt == LUA_VUPVAL && upisopen(gco2upv(curr)))
1068 set2gray(curr); /* open upvalues are always gray */
1069 else /* everything else is black */
1070 nw2black(curr);
1071 p = &curr->next; /* go to next element */
1072 }
1073 }
1074}
1075
1076
1077/*

Callers 1

atomic2genFunction · 0.85

Calls 1

freeobjFunction · 0.85

Tested by

no test coverage detected