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

Function fxShare

xs/sources/xsMemory.c:1815–1881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813
1814#if mxAliasInstance
1815void fxShare(txMachine* the)
1816{
1817 txID aliasCount = 0;
1818 txSlot *heap, *slot, *limit;
1819
1820 heap = the->firstHeap;
1821 while (heap) {
1822 slot = heap + 1;
1823 limit = heap->value.reference;
1824 while (slot < limit) {
1825 if (slot->kind == XS_INSTANCE_KIND) {
1826 txBoolean frozen = (slot->flag & XS_DONT_PATCH_FLAG) ? 1 : 0;
1827 if (frozen) {
1828 txSlot *property = slot->next;
1829 while (property) {
1830 if (property->kind == XS_ARRAY_KIND) {
1831 txSlot* item = property->value.array.address;
1832 txInteger length = (txInteger)fxGetIndexSize(the, property);
1833 while (length > 0) {
1834 if (item->kind != XS_ACCESSOR_KIND)
1835 if (!(item->flag & XS_DONT_SET_FLAG))
1836 frozen = 0;
1837 if (!(item->flag & XS_DONT_DELETE_FLAG))
1838 frozen = 0;
1839 item++;
1840 length--;
1841 }
1842 }
1843 else {
1844 if (property->kind != XS_ACCESSOR_KIND)
1845 if (!(property->flag & XS_DONT_SET_FLAG))
1846 frozen = 0;
1847 if (!(property->flag & XS_DONT_DELETE_FLAG))
1848 frozen = 0;
1849 }
1850 property = property->next;
1851 }
1852 }
1853 if (frozen)
1854 slot->ID = XS_NO_ID;
1855 else
1856 slot->ID = aliasCount++;
1857 }
1858 else if (slot->kind == XS_CLOSURE_KIND) {
1859 txSlot* closure = slot->value.closure;
1860 if (closure->flag & XS_DONT_SET_FLAG)
1861 closure->flag |= XS_DONT_DELETE_FLAG;
1862 else {
1863 if (closure->ID == XS_NO_ID)
1864 closure->ID = aliasCount++;
1865 slot->flag &= ~XS_DONT_SET_FLAG;
1866 }
1867 }
1868 slot->flag |= XS_MARK_FLAG;
1869 slot++;
1870 }
1871 heap = heap->next;
1872 }

Callers 1

fxShareMachineFunction · 0.85

Calls 1

fxGetIndexSizeFunction · 0.85

Tested by

no test coverage detected