** Check GC invariants. For incremental mode, a black object cannot ** point to a white one. For generational mode, really old objects ** cannot point to young objects. Both old1 and touched2 objects ** cannot point to new objects (but can point to survivals). ** (Threads and open upvalues, despite being marked "really old", ** continue to be visited in all collections, and therefore can point to
| 295 | ** new objects. They, and only they, are old but gray.) |
| 296 | */ |
| 297 | static int testobjref1 (global_State *g, GCObject *f, GCObject *t) { |
| 298 | if (isdead(g,t)) return 0; |
| 299 | if (issweepphase(g)) |
| 300 | return 1; /* no invariants */ |
| 301 | else if (g->gckind == KGC_INC) |
| 302 | return !(isblack(f) && iswhite(t)); /* basic incremental invariant */ |
| 303 | else { /* generational mode */ |
| 304 | if ((getage(f) == G_OLD && isblack(f)) && !isold(t)) |
| 305 | return 0; |
| 306 | if (((getage(f) == G_OLD1 || getage(f) == G_TOUCHED2) && isblack(f)) && |
| 307 | getage(t) == G_NEW) |
| 308 | return 0; |
| 309 | return 1; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | static void printobj (global_State *g, GCObject *o) { |