MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / sweepgen

Function sweepgen

extlibs/lua/src/lgc.c:999–1026  ·  view source on GitHub ↗

** Sweep for generational mode. Delete dead objects. (Because the ** collection is not incremental, there are no "new white" objects ** during the sweep. So, any white object must be dead.) For ** non-dead objects, advance their ages and clear the color of ** new objects. (Old objects keep their colors.) */

Source from the content-addressed store, hash-verified

997** new objects. (Old objects keep their colors.)
998*/
999static GCObject **sweepgen (lua_State *L, global_State *g, GCObject **p,
1000 GCObject *limit) {
1001 static const lu_byte nextage[] = {
1002 G_SURVIVAL, /* from G_NEW */
1003 G_OLD1, /* from G_SURVIVAL */
1004 G_OLD1, /* from G_OLD0 */
1005 G_OLD, /* from G_OLD1 */
1006 G_OLD, /* from G_OLD (do not change) */
1007 G_TOUCHED1, /* from G_TOUCHED1 (do not change) */
1008 G_TOUCHED2 /* from G_TOUCHED2 (do not change) */
1009 };
1010 int white = luaC_white(g);
1011 GCObject *curr;
1012 while ((curr = *p) != limit) {
1013 if (iswhite(curr)) { /* is 'curr' dead? */
1014 lua_assert(!isold(curr) && isdead(g, curr));
1015 *p = curr->next; /* remove 'curr' from list */
1016 freeobj(L, curr); /* erase 'curr' */
1017 }
1018 else { /* correct mark and age */
1019 if (getage(curr) == G_NEW)
1020 curr->marked = cast_byte((curr->marked & maskgencolors) | white);
1021 setage(curr, nextage[getage(curr)]);
1022 p = &curr->next; /* go to next element */
1023 }
1024 }
1025 return p;
1026}
1027
1028
1029/*

Callers 1

youngcollectionFunction · 0.85

Calls 1

freeobjFunction · 0.85

Tested by

no test coverage detected