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

Function fxMarkWeakStuff

xs/sources/xsMemory.c:1577–1640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1575}
1576
1577void fxMarkWeakStuff(txMachine* the)
1578{
1579 txSlot* slot;
1580 txSlot** address;
1581
1582 {
1583 txSlot* list;
1584 txSlot** listAddress = &the->firstWeakListLink;
1585 while ((list = *listAddress)) {
1586 if (list->flag & XS_MARK_FLAG) {
1587 txSlot* listEntry;
1588 txSlot** listEntryAddress = &list->value.weakList.first;
1589 while ((listEntry = *listEntryAddress)) {
1590 txSlot* value = listEntry->value.weakEntry.value;
1591 if ((value->flag & XS_MARK_FLAG) && (value->kind != XS_UNINITIALIZED_KIND)) {
1592 listEntryAddress = &listEntry->next;
1593 }
1594 else {
1595 listEntry->flag &= ~XS_MARK_FLAG;
1596 *listEntryAddress = listEntry->next;
1597 }
1598 }
1599 listAddress = &list->value.weakList.link;
1600 }
1601 else {
1602 txSlot* listEntry = list->value.weakList.first;
1603 while (listEntry) {
1604 txSlot* key = listEntry->value.weakEntry.check;
1605 if (key->flag & XS_MARK_FLAG) {
1606 txSlot* keyEntry;
1607 txSlot** keyEntryAddress = &key->next;
1608 while ((keyEntry = *keyEntryAddress)) {
1609 if (!(keyEntry->flag & XS_INTERNAL_FLAG))
1610 break;
1611 if ((keyEntry->kind == XS_WEAK_ENTRY_KIND) && (keyEntry->value.weakEntry.check == list)) {
1612 keyEntry->flag &= ~XS_MARK_FLAG;
1613 *keyEntryAddress = keyEntry->next;
1614 break;
1615 }
1616 keyEntryAddress = &keyEntry->next;
1617 }
1618 }
1619 listEntry = listEntry->next;
1620 }
1621 *listAddress = list->value.weakList.link;
1622 }
1623 }
1624 }
1625 address = &the->firstWeakRefLink;
1626 while ((slot = *address)) {
1627 if (!(slot->value.weakRef.target->flag & XS_MARK_FLAG))
1628 slot->value.weakRef.target = C_NULL;
1629 *address = C_NULL;
1630 address = &(slot->value.weakRef.link);
1631 }
1632
1633 if (mxFinalizationRegistries.kind == XS_REFERENCE_KIND) {
1634 slot = mxFinalizationRegistries.value.reference->next;

Callers 1

fxCollectFunction · 0.85

Calls 1

Tested by

no test coverage detected