** For each non-marked thread, simulates a barrier between each open ** upvalue and its value. (If the thread is collected, the value will be ** assigned to the upvalue, but then it can be too late for the barrier ** to act. The "barrier" does not need to check colors: A non-marked ** thread must be young; upvalues cannot be older than their threads; so ** any visited upvalue must be young too.) A
| 404 | ** upvalue later, it will be linked in the list again.) |
| 405 | */ |
| 406 | static void remarkupvals (global_State *g) { |
| 407 | lua_State *thread; |
| 408 | lua_State **p = &g->twups; |
| 409 | while ((thread = *p) != NULL) { |
| 410 | if (!iswhite(thread) && thread->openupval != NULL) |
| 411 | p = &thread->twups; /* keep marked thread with upvalues in the list */ |
| 412 | else { /* thread is not marked or without upvalues */ |
| 413 | UpVal *uv; |
| 414 | lua_assert(!isold(thread) || thread->openupval == NULL); |
| 415 | *p = thread->twups; /* remove thread from the list */ |
| 416 | thread->twups = thread; /* mark that it is out of list */ |
| 417 | for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) { |
| 418 | lua_assert(getage(uv) <= getage(thread)); |
| 419 | if (!iswhite(uv)) { /* upvalue already visited? */ |
| 420 | lua_assert(upisopen(uv) && isgray(uv)); |
| 421 | markvalue(g, uv->v.p); /* mark its value */ |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | |
| 429 | static void cleargraylists (global_State *g) { |