| 333 | } |
| 334 | |
| 335 | void JavaScriptHeapDumpParser::parseNodes(JSONReader& reader, int32_t nodeCount) { |
| 336 | if (!reader.parseBeginArray()) { |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | auto fieldsCountPerNode = _fieldsIndexes.fieldsCountPerNode; |
| 341 | std::vector<uint32_t> components; |
| 342 | if (!parseComponents(reader, components, fieldsCountPerNode * nodeCount)) { |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | auto* componentsPtr = components.data(); |
| 347 | |
| 348 | size_t edgesStart = 0; |
| 349 | auto nodeTypeMaxSize = static_cast<uint32_t>(_fieldsIndexes.nodeTypeByIndex.size()); |
| 350 | |
| 351 | for (int32_t i = 0; i < nodeCount; i++) { |
| 352 | auto typeIndex = componentsPtr[_fieldsIndexes.nodes.type]; |
| 353 | auto nameIndex = componentsPtr[_fieldsIndexes.nodes.name]; |
| 354 | auto id = componentsPtr[_fieldsIndexes.nodes.id]; |
| 355 | auto selfSizeBytes = componentsPtr[_fieldsIndexes.nodes.selfSize]; |
| 356 | auto edgesCount = componentsPtr[_fieldsIndexes.nodes.edgeCount]; |
| 357 | |
| 358 | if (typeIndex >= nodeTypeMaxSize) { |
| 359 | reader.setErrorAtCurrentPosition("Out of bounds edgeType"); |
| 360 | return; |
| 361 | } |
| 362 | |
| 363 | _nodes.emplace_back( |
| 364 | this, _fieldsIndexes.nodeTypeByIndex[typeIndex], nameIndex, id, selfSizeBytes, edgesStart, edgesCount); |
| 365 | |
| 366 | edgesStart += edgesCount; |
| 367 | componentsPtr += fieldsCountPerNode; |
| 368 | } |
| 369 | |
| 370 | reader.parseEndArray(); |
| 371 | } |
| 372 | |
| 373 | void JavaScriptHeapDumpParser::parseEdges(JSONReader& reader, int32_t edgeCount) { |
| 374 | if (!reader.parseBeginArray()) { |
nothing calls this directly
no test coverage detected