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

Function fxFrameToProfilerID

xs/sources/xsDebug.c:3330–3367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3328#endif
3329
3330txID fxFrameToProfilerID(txMachine* the, txSlot* frame)
3331{
3332 txProfiler* profiler = the->profiler;
3333 txSlot* function = frame + 2;
3334 txSlot* code = C_NULL;
3335 txID id = XS_NO_ID;
3336 if (function->kind == XS_REFERENCE_KIND) {
3337 function = function->value.reference;
3338 if (mxIsFunction(function)) {
3339 code = mxFunctionInstanceCode(function);
3340 id = mxFunctionInstanceHome(function)->ID;
3341 }
3342 }
3343#if mxHostFunctionPrimitive
3344 else if (function->kind == XS_HOST_FUNCTION_KIND)
3345 id = function->value.hostFunction.profileID;
3346#endif
3347 if (id != XS_NO_ID) {
3348 txInteger recordIndex = id >> 3;
3349 txInteger recordMask = 1 << (id & 0x07);
3350 txInteger recordCount = profiler->recordCount;
3351 if (recordIndex >= recordCount) {
3352 while (recordIndex >= recordCount)
3353 recordCount += 128;
3354 profiler->records = c_realloc(profiler->records, recordCount);
3355 if (profiler->records == C_NULL)
3356 fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
3357 c_memset(profiler->records + profiler->recordCount, 0, (recordCount - profiler->recordCount));
3358 profiler->recordCount = recordCount;
3359 }
3360 else if (profiler->records[recordIndex] & recordMask)
3361 return id;
3362 profiler->records[recordIndex] |= recordMask;
3363 fxSendProfilerRecord(the, frame, id, code);
3364 return id;
3365 }
3366 return 0;
3367}
3368
3369txMicroseconds fxGetMicroSeconds()
3370{

Callers 1

fxCheckProfilerFunction · 0.85

Calls 2

fxSendProfilerRecordFunction · 0.85
fxAbortFunction · 0.70

Tested by

no test coverage detected