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

Function fxMark

xs/sources/xsMemory.c:743–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741}
742
743void fxMark(txMachine* the, void (*theMarker)(txMachine*, txSlot*))
744{
745 txSlot** p;
746 txSlot** q;
747 txSlot* slot;
748
749#if mxAliasInstance
750 p = the->aliasArray;
751 q = p + the->aliasCount;
752 while (p < q) {
753 if ((slot = *p)) {
754 (*theMarker)(the, slot);
755 slot->flag |= XS_MARK_FLAG;
756 }
757 p++;
758 }
759#endif
760
761 slot = the->stackTop;
762 while (slot > the->stack) {
763 slot--;
764 (*theMarker)(the, slot);
765 }
766 slot = the->cRoot;
767 while (slot) {
768 (*theMarker)(the, slot);
769 slot = slot->next;
770 }
771
772#if mxKeysGarbageCollection
773 if (the->collectFlag & XS_COLLECT_KEYS_FLAG) {
774 txInteger deletions = 0;
775 p = the->keyArray;
776 q = p + the->keyIndex - the->keyOffset;
777 while (p < q) {
778 slot = *p++;
779 if (!(slot->flag & XS_MARK_FLAG)) {
780 if (slot->flag & XS_DONT_DELETE_FLAG)
781 slot->flag |= XS_MARK_FLAG;
782 else if (slot->flag & XS_DONT_ENUM_FLAG)
783 deletions++;
784 }
785 }
786
787 // fprintf(stderr, "\n### KEYS GC %d", deletions);
788 p = the->nameTable;
789 q = the->nameTable + the->nameModulo;
790 while ((p < q) && deletions) {
791 txSlot** address = p;
792 while (((slot = *address)) && deletions) {
793 if (slot->flag & XS_MARK_FLAG)
794 address = &(slot->next);
795 else {
796 *address = slot->next;
797 deletions--;
798 }
799 }
800 p++;

Callers 1

fxCollectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected