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

Function fxSweep

xs/sources/xsMemory.c:1884–2120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1882#endif
1883
1884void fxSweep(txMachine* the)
1885{
1886 txSize aTotal;
1887#if mxNoChunks
1888 txChunk** address;
1889 txChunk* chunk;
1890#else
1891 txBlock* aBlock;
1892 txByte* limit;
1893 txByte* next;
1894#endif
1895 txByte* current;
1896 txByte* temporary;
1897 txSize aSize;
1898 txByte** aCodeAddress;
1899 txSlot* aSlot;
1900 txSlot* bSlot;
1901 txSlot* cSlot;
1902 txSlot* freeSlot;
1903 txJump* jump;
1904
1905#ifdef mxNever
1906 startTime(&gxSweepChunkTime);
1907#endif
1908
1909 aTotal = 0;
1910#if mxNoChunks
1911 address = (txChunk**)&(the->firstBlock);
1912 while ((chunk = *address)) {
1913 aSize = chunk->size;
1914 if (aSize & mxChunkFlag) {
1915 aSize &= ~mxChunkFlag;
1916 temporary = c_malloc_noforcefail(aSize);
1917 if (!temporary)
1918 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT); // should never happen
1919 c_memcpy(temporary, chunk, aSize);
1920 ((txChunk*)temporary)->size = aSize;
1921 chunk->temporary = temporary;
1922 address = (txChunk**)&(((txChunk*)temporary)->temporary);
1923 aTotal += aSize;
1924 }
1925 else {
1926 *address = (txChunk*)(chunk->temporary);
1927 c_free(chunk);
1928 }
1929 }
1930#else
1931 aBlock = the->firstBlock;
1932 while (aBlock) {
1933 current = ((txByte*)aBlock) + sizeof(txBlock);
1934 limit = aBlock->current;
1935 temporary = current;
1936 while (current < limit) {
1937 aSize = ((txChunk*)current)->size;
1938 next = ((txChunk*)current)->temporary;
1939 if (aSize & mxChunkFlag) {
1940 aSize &= ~mxChunkFlag;
1941 ((txChunk*)current)->temporary = temporary;

Callers 1

fxCollectFunction · 0.85

Calls 4

startTimeFunction · 0.85
fxSweepValueFunction · 0.85
stopTimeFunction · 0.85
fxAbortFunction · 0.70

Tested by

no test coverage detected