MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / remarkupvals

Function remarkupvals

lib/lua/src/lgc.c:367–391  ·  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

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

Callers 1

atomicFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected