** 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
| 1225 | ** from the list. |
| 1226 | */ |
| 1227 | static 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 | /* |
no test coverage detected