| 338 | } |
| 339 | |
| 340 | Valdi::JavaScriptContextMemoryStatistics JavaScriptCoreContext::dumpMemoryStatistics() { |
| 341 | if (s_dumpMemoryStatisticsOverride) { |
| 342 | return s_dumpMemoryStatisticsOverride(_globalContext); |
| 343 | } |
| 344 | |
| 345 | Valdi::JavaScriptContextMemoryStatistics out; |
| 346 | |
| 347 | if constexpr (!snap::kIsAppstoreBuild || !snap::isIos()) { |
| 348 | // JSGetMemoryUsageStatistics() is currently a private symbol, so we use it |
| 349 | // only on Android/Desktop or non production iOS. |
| 350 | |
| 351 | if (JSGetMemoryUsageStatistics) { |
| 352 | auto memoryUsageJs = JSGetMemoryUsageStatistics(_globalContext); |
| 353 | |
| 354 | if (!memoryUsageJs) { |
| 355 | return out; |
| 356 | } |
| 357 | |
| 358 | Valdi::JSExceptionTracker exceptionTracker(*this); |
| 359 | auto memoryUsage = Valdi::jsValueToValue( |
| 360 | *this, |
| 361 | toValdiJSValue(JSCoreRef(memoryUsageJs, JSValueGetType(_globalContext, memoryUsageJs))), |
| 362 | Valdi::ReferenceInfoBuilder(), |
nothing calls this directly
no test coverage detected