MCPcopy Create free account
hub / github.com/F-Stack/f-stack / traverseephemeron

Function traverseephemeron

freebsd/contrib/openzfs/module/lua/lgc.c:377–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

traversetableFunction · 0.85
convergeephemeronsFunction · 0.85

Calls 3

reallymarkobjectFunction · 0.70
removeentryFunction · 0.70
isclearedFunction · 0.70

Tested by

no test coverage detected