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

Function fxWriteSnapshot

xs/sources/xsSnapshot.c:2309–2473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2307}
2308
2309int fxWriteSnapshot(txMachine* the, txSnapshot* snapshot)
2310{
2311 txSlot* heap;
2312 txSlot* stack;
2313 txSlot** slots;
2314 txSize size;
2315 txByte byte;
2316 txProjection** projectionAddress = &(snapshot->firstProjection);
2317 txProjection* projection;
2318 txSize chunkSize = 0;
2319 txSize namesSize = the->nameModulo * sizeof(txSlot*);
2320 txSize keysSize = the->keyIndex * sizeof(txSlot*);
2321 txSize slotSize = 0;
2322 txSize stackSize = (txSize)((the->stackTop - the->stack) * sizeof(txSlot));
2323 txSize symbolsSize = the->symbolModulo * sizeof(txSlot*);
2324 txCreation creation;
2325
2326 mxTry(the) {
2327 snapshot->error = 0;
2328
2329#if defined(mxInstrument) || defined(mxProfile)
2330 mxAssert(the->profiler == C_NULL, "# snapshot: not while profiling!\n");
2331#endif
2332
2333 fxCollectGarbage(the);
2334 fxUnlinkChunks(the);
2335
2336 fxIndexSlots(the, snapshot);
2337
2338 stack = the->stackTop - 1;
2339 while (stack >= the->stack) {
2340 fxMeasureSlot(the, snapshot, stack, &chunkSize);
2341 stack--;
2342 }
2343 slotSize = snapshot->slotSize;
2344 slots = snapshot->slots;
2345 slotSize--;
2346 slots++;
2347 while (slotSize) {
2348 txSlot* slot = *slots;
2349 fxMeasureSlot(the, snapshot, slot, &chunkSize);
2350 slotSize--;
2351 slots++;
2352 }
2353
2354 slotSize = (snapshot->slotSize - 1) * sizeof(txSlot);
2355
2356 creation.initialChunkSize = the->maximumChunksSize;
2357 creation.incrementalChunkSize = the->minimumChunksSize;
2358 creation.initialHeapCount = the->maximumHeapCount + 1;
2359 creation.incrementalHeapCount = the->minimumHeapCount;
2360 creation.stackCount = (txSize)(the->stackTop - the->stackBottom);
2361 creation.initialKeyCount = the->keyCount;
2362 creation.incrementalKeyCount = the->keyDelta;
2363 creation.nameModulo = the->nameModulo;
2364 creation.symbolModulo = the->symbolModulo;
2365 creation.parserBufferSize = the->parserBufferSize;
2366 creation.parserTableModulo = the->parserTableModulo;

Callers

nothing calls this directly

Calls 9

fxCollectGarbageFunction · 0.85
fxUnlinkChunksFunction · 0.85
fxIndexSlotsFunction · 0.85
fxWriteChunksFunction · 0.85
fxWriteSlotsFunction · 0.85
fxWriteStackFunction · 0.85
fxWriteSlotTableFunction · 0.85
fxLinkChunksFunction · 0.85
fxMeasureSlotFunction · 0.70

Tested by

no test coverage detected