| 1188 | #pragma clang diagnostic pop |
| 1189 | |
| 1190 | void QuickJSJavaScriptContext::dumpHeap(Valdi::JavaScriptHeapDumpBuilder& heapDumpBuilder) { |
| 1191 | auto guard = _threadAccessChecker.guard(); |
| 1192 | auto* oldOpaque = JS_GetRuntimeOpaque(_runtime); |
| 1193 | |
| 1194 | // We shove the heap dump builder as an opaque so that we can retrieve it while visiting |
| 1195 | // the heap. |
| 1196 | JS_SetRuntimeOpaque(_runtime, reinterpret_cast<Valdi::JavaScriptHeapDumpBuilder*>(&heapDumpBuilder)); |
| 1197 | JS_VisitAllGCObjects(_runtime, &onObjectBegin, &onObjectEdgeProperty, &onObjectEdge); |
| 1198 | |
| 1199 | auto stashedJSValues = getAllStashedJSValues(); |
| 1200 | // Emit the stashed JS values as a separate node |
| 1201 | heapDumpBuilder.beginNode(Valdi::JavaScriptHeapDumpNodeType::HIDDEN, |
| 1202 | STRING_LITERAL("System / ExportedReferences"), |
| 1203 | this, |
| 1204 | sizeof(JSValue) * stashedJSValues.size()); |
| 1205 | |
| 1206 | size_t index = 0; |
| 1207 | for (const auto& jsValue : stashedJSValues) { |
| 1208 | auto indexStr = std::to_string(index); |
| 1209 | JS_VisitObjectEdge( |
| 1210 | _runtime, fromValdiJSValue(jsValue), indexStr.c_str(), JS_EDGE_TYPE_ELEMENT, &onObjectEdgeProperty); |
| 1211 | index++; |
| 1212 | } |
| 1213 | |
| 1214 | // Restore old opaque |
| 1215 | JS_SetRuntimeOpaque(_runtime, oldOpaque); |
| 1216 | } |
| 1217 | |
| 1218 | JSContext* QuickJSJavaScriptContext::getContext() const { |
| 1219 | return _context; |
nothing calls this directly
no test coverage detected