MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / correctgraylist

Function correctgraylist

third-party/lua-5.5.0/src/lgc.c:1227–1254  ·  view source on GitHub ↗

** Correct a list of gray objects. Return a pointer to the last element ** left on the list, so that we can link another list to the end of ** this one. ** Because this correction is done after sweeping, young objects might ** be turned white and still be in the list. They are only removed. ** 'TOUCHED1' objects are advanced to 'TOUCHED2' and remain on the list; ** Non-white threads also remain on

Source from the content-addressed store, hash-verified

1225** from the list.
1226*/
1227static GCObject **correctgraylist (GCObject **p) {
1228 GCObject *curr;
1229 while ((curr = *p) != NULL) {
1230 GCObject **next = getgclist(curr);
1231 if (iswhite(curr))
1232 goto remove; /* remove all white objects */
1233 else if (getage(curr) == G_TOUCHED1) { /* touched in this cycle? */
1234 lua_assert(isgray(curr));
1235 nw2black(curr); /* make it black, for next barrier */
1236 setage(curr, G_TOUCHED2);
1237 goto remain; /* keep it in the list and go to next element */
1238 }
1239 else if (curr->tt == LUA_VTHREAD) {
1240 lua_assert(isgray(curr));
1241 goto remain; /* keep non-white threads on the list */
1242 }
1243 else { /* everything else is removed */
1244 lua_assert(isold(curr)); /* young objects should be white here */
1245 if (getage(curr) == G_TOUCHED2) /* advance from TOUCHED2... */
1246 setage(curr, G_OLD); /* ... to OLD */
1247 nw2black(curr); /* make object black (to be removed) */
1248 goto remove;
1249 }
1250 remove: *p = *next; continue;
1251 remain: p = next; continue;
1252 }
1253 return p;
1254}
1255
1256
1257/*

Callers 1

correctgraylistsFunction · 0.70

Calls 1

getgclistFunction · 0.70

Tested by

no test coverage detected