MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / traverseephemeron

Function traverseephemeron

third-party/lua-5.2.4/src/lgc.c:378–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376
377
378static int traverseephemeron (global_State *g, Table *h) {
379 int marked = 0; /* true if an object is marked in this traversal */
380 int hasclears = 0; /* true if table has white keys */
381 int prop = 0; /* true if table has entry "white-key -> white-value" */
382 Node *n, *limit = gnodelast(h);
383 int i;
384 /* traverse array part (numeric keys are 'strong') */
385 for (i = 0; i < h->sizearray; i++) {
386 if (valiswhite(&h->array[i])) {
387 marked = 1;
388 reallymarkobject(g, gcvalue(&h->array[i]));
389 }
390 }
391 /* traverse hash part */
392 for (n = gnode(h, 0); n < limit; n++) {
393 checkdeadkey(n);
394 if (ttisnil(gval(n))) /* entry is empty? */
395 removeentry(n); /* remove it */
396 else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */
397 hasclears = 1; /* table must be cleared */
398 if (valiswhite(gval(n))) /* value not marked yet? */
399 prop = 1; /* must propagate again */
400 }
401 else if (valiswhite(gval(n))) { /* value not marked yet? */
402 marked = 1;
403 reallymarkobject(g, gcvalue(gval(n))); /* mark it now */
404 }
405 }
406 if (g->gcstate != GCSatomic || prop)
407 linktable(h, &g->ephemeron); /* have to propagate again */
408 else if (hasclears) /* does table have white keys? */
409 linktable(h, &g->allweak); /* may have to clean white keys */
410 else /* no white keys */
411 linktable(h, &g->grayagain); /* no need to clean */
412 return marked;
413}
414
415
416static void traversestrongtable (global_State *g, Table *h) {

Callers 2

traversetableFunction · 0.70
convergeephemeronsFunction · 0.70

Calls 3

reallymarkobjectFunction · 0.70
removeentryFunction · 0.70
isclearedFunction · 0.70

Tested by

no test coverage detected