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

Function fxCollect

xs/sources/xsMemory.c:280–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void fxCollect(txMachine* the, txFlag theFlag)
281{
282 txSize aCount;
283 txSlot* freeSlot;
284 txSlot* aSlot;
285 txSlot* bSlot;
286 txSlot* cSlot;
287
288 if ((the->collectFlag & XS_COLLECTING_FLAG) == 0) {
289 the->collectFlag |= XS_SKIPPED_COLLECT_FLAG;
290 return;
291 }
292 the->collectFlag |= theFlag & (XS_COLLECT_KEYS_FLAG | XS_ORGANIC_FLAG);
293
294#ifdef mxNever
295 if (theFlag & XS_ORGANIC_FLAG) {
296 if (theFlag & XS_COMPACT_FLAG)
297 startTime(&gxChunksGarbageCollectionTime);
298 else if (theFlag & XS_COLLECT_KEYS_FLAG)
299 startTime(&gxKeysGarbageCollectionTime);
300 else
301 startTime(&gxSlotsGarbageCollectionTime);
302 }
303 else
304 startTime(&gxForcedGarbageCollectionTime);
305 startTime(&gxMarkTime);
306#endif
307 if (theFlag & XS_COMPACT_FLAG) {
308 fxInvalidateStringInfoCache(the);
309 fxMark(the, fxMarkValue);
310 fxMarkWeakStuff(the);
311 #ifdef mxNever
312 stopTime(&gxMarkTime);
313 #endif
314 fxSweep(the);
315 }
316 else {
317 fxMark(the, fxMarkReference);
318 fxMarkWeakStuff(the);
319 #ifdef mxNever
320 stopTime(&gxMarkTime);
321 startTime(&gxSweepSlotTime);
322 #endif
323 aCount = 0;
324 freeSlot = C_NULL;
325 aSlot = the->firstHeap;
326 while (aSlot) {
327 bSlot = aSlot + 1;
328 cSlot = aSlot->value.reference;
329 while (bSlot < cSlot) {
330 if (bSlot->flag & XS_MARK_FLAG) {
331 bSlot->flag &= ~XS_MARK_FLAG;
332
333 if (bSlot->kind == XS_REFERENCE_KIND) {
334 mxCheck(the, bSlot->value.reference->kind == XS_INSTANCE_KIND);
335 }
336
337 aCount++;

Callers 7

fxFindChunkFunction · 0.85
fxFindKeyFunction · 0.85
fxNewSlotFunction · 0.85
fxCollectGarbageFunction · 0.85
fxAllocateSlotsFunction · 0.85
fxAllocateSlotsFunction · 0.85
fxAllocateSlotsFunction · 0.85

Calls 7

startTimeFunction · 0.85
fxMarkFunction · 0.85
fxMarkWeakStuffFunction · 0.85
stopTimeFunction · 0.85
fxSweepFunction · 0.85
fxCheckProfilerFunction · 0.70

Tested by

no test coverage detected