MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_FinalizationRegistryCleanup

Function fx_FinalizationRegistryCleanup

xs/sources/xsMapSet.c:2030–2089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2028}
2029
2030void fx_FinalizationRegistryCleanup(txMachine* the, txSlot* registry, txSlot* callback)
2031{
2032 txSlot* slot;
2033 txUnsigned flags;
2034 txSlot** address;
2035 txSlot* value;
2036
2037 if (!(registry->value.finalizationRegistry.flags & XS_FINALIZATION_REGISTRY_CHANGED))
2038 return;
2039
2040 slot = registry->value.finalizationRegistry.callback->next;
2041 flags = 0;
2042 while (slot) {
2043 slot = slot->next;
2044 if (slot->value.finalizationCell.target == C_NULL) {
2045 flags = 1;
2046 break;
2047 }
2048 slot = slot->next;
2049 }
2050 if (!flags)
2051 return;
2052 if (!callback)
2053 callback = registry->value.finalizationRegistry.callback;
2054 flags = registry->value.finalizationRegistry.flags;
2055 {
2056 mxTry(the) {
2057 address = &(registry->value.finalizationRegistry.callback->next);
2058 while ((value = *address)) {
2059 slot = value->next;
2060 if (slot->value.finalizationCell.target == C_NULL) {
2061 *address = slot->next;
2062 mxPushUndefined();
2063 mxPushSlot(callback);
2064 mxCall();
2065 mxPushSlot(value);
2066 mxRunCount(1);
2067 mxPop();
2068 }
2069 else
2070 address = &(slot->next);
2071 }
2072 registry->value.finalizationRegistry.flags = flags;
2073 }
2074 mxCatch(the) {
2075 registry->value.finalizationRegistry.flags = flags;
2076 fxJump(the);
2077 }
2078 }
2079
2080 slot = registry->value.finalizationRegistry.callback->next;
2081 while (slot) {
2082 slot = slot->next;
2083 if (slot->value.finalizationCell.target == C_NULL)
2084 break;
2085 slot = slot->next;
2086 }
2087 if (!slot)

Calls 1

fxJumpFunction · 0.85

Tested by

no test coverage detected