MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / remarkupvals

Function remarkupvals

3rd/lua-5.4.3/src/lgc.c:361–385  ·  view source on GitHub ↗

** 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

Source from the content-addressed store, hash-verified

359** upvalue later, it will be linked in the list again.)
360*/
361static int remarkupvals (global_State *g) {
362 lua_State *thread;
363 lua_State **p = &g->twups;
364 int work = 0; /* estimate of how much work was done here */
365 while ((thread = *p) != NULL) {
366 work++;
367 if (!iswhite(thread) && thread->openupval != NULL)
368 p = &thread->twups; /* keep marked thread with upvalues in the list */
369 else { /* thread is not marked or without upvalues */
370 UpVal *uv;
371 lua_assert(!isold(thread) || thread->openupval == NULL);
372 *p = thread->twups; /* remove thread from the list */
373 thread->twups = thread; /* mark that it is out of list */
374 for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) {
375 lua_assert(getage(uv) <= getage(thread));
376 work++;
377 if (!iswhite(uv)) { /* upvalue already visited? */
378 lua_assert(upisopen(uv) && isgray(uv));
379 markvalue(g, uv->v); /* mark its value */
380 }
381 }
382 }
383 }
384 return work;
385}
386
387
388static void cleargraylists (global_State *g) {

Callers 1

atomicFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected