MCPcopy Create free account
hub / github.com/Snapchat/Valdi / newFunction

Method newFunction

valdi/src/valdi/jscore/JavaScriptCoreContext.cpp:340–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338 Valdi::JavaScriptContextMemoryStatistics out;
339
340 if constexpr (!snap::kIsAppstoreBuild || !snap::isIos()) {
341 // JSGetMemoryUsageStatistics() is currently a private symbol, so we use it
342 // only on Android/Desktop or non production iOS.
343
344 if (JSGetMemoryUsageStatistics) {
345 auto memoryUsageJs = JSGetMemoryUsageStatistics(_globalContext);
346
347 if (!memoryUsageJs) {
348 return out;
349 }
350
351 Valdi::JSExceptionTracker exceptionTracker(*this);
352 auto memoryUsage = Valdi::jsValueToValue(
353 *this,
354 toValdiJSValue(JSCoreRef(memoryUsageJs, JSValueGetType(_globalContext, memoryUsageJs))),
355 Valdi::ReferenceInfoBuilder(),
356 exceptionTracker);
357
358 exceptionTracker.clearError();
359
360 out.memoryUsageBytes = static_cast<size_t>(memoryUsage.getMapValue("heapCapacity").toLong());
361 out.objectsCount = static_cast<size_t>(memoryUsage.getMapValue("objectCount").toLong());
362 }

Callers

nothing calls this directly

Calls 7

unsafeBridgeRetainFunction · 0.85
fromValdiJSValueFunction · 0.70
getMethod · 0.65
isEmptyMethod · 0.45
getNameMethod · 0.45
toStringViewMethod · 0.45

Tested by

no test coverage detected