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

Function fxAllocate

xs/sources/xsMemory.c:165–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void fxAllocate(txMachine* the, txCreation* theCreation)
166{
167#ifdef mxNever
168 startTime(&gxLifeTime);
169#endif
170#if mxStress
171 gxStress = 0;
172#endif
173
174 the->currentChunksSize = 0;
175 the->peakChunksSize = 0;
176 the->maximumChunksSize = 0;
177 the->minimumChunksSize = theCreation->incrementalChunkSize;
178
179 the->currentHeapCount = 0;
180 the->peakHeapCount = 0;
181 the->maximumHeapCount = 0;
182 the->minimumHeapCount = theCreation->incrementalHeapCount;
183
184 the->firstBlock = C_NULL;
185 the->firstHeap = C_NULL;
186
187#if mxNoChunks
188 the->maximumChunksSize = theCreation->initialChunkSize;
189#else
190 fxGrowChunks(the, theCreation->initialChunkSize);
191#endif
192
193 the->stackBottom = fxAllocateSlots(the, theCreation->stackCount);
194 the->stackTop = the->stackBottom + theCreation->stackCount;
195 the->stackIntrinsics = the->stackTop;
196 the->stackPrototypes = the->stackTop - XS_INTRINSICS_COUNT;
197 the->stack = the->stackTop;
198#ifdef mxInstrument
199 the->stackPeak = the->stackTop;
200#endif
201
202 fxGrowSlots(the, theCreation->initialHeapCount);
203
204 the->keyCount = (txID)theCreation->initialKeyCount;
205 the->keyDelta = (txID)theCreation->incrementalKeyCount;
206 the->keyIndex = 0;
207 the->keyArray = (txSlot **)c_malloc_uint32(theCreation->initialKeyCount * sizeof(txSlot*));
208 if (!the->keyArray)
209 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
210
211 the->nameModulo = theCreation->nameModulo;
212 the->nameTable = (txSlot **)c_malloc_uint32(theCreation->nameModulo * sizeof(txSlot*));
213 if (!the->nameTable)
214 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
215
216 the->symbolModulo = theCreation->symbolModulo;
217 the->symbolTable = (txSlot **)c_malloc_uint32(theCreation->symbolModulo * sizeof(txSlot*));
218 if (!the->symbolTable)
219 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
220
221 fxAllocateStringInfoCache(the);
222

Callers 3

fxCreateMachineFunction · 0.85
fxCloneMachineFunction · 0.85
fxReadSnapshotFunction · 0.85

Calls 7

startTimeFunction · 0.85
fxGrowChunksFunction · 0.85
fxGrowSlotsFunction · 0.85
fxCStackLimitFunction · 0.85
fxAllocateSlotsFunction · 0.70
fxAbortFunction · 0.70

Tested by

no test coverage detected