OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3483 | 3483 |
3484 void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge) { | 3484 void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge) { |
3485 // The buffer needs space for 3 ints, 3 commas and \0 | 3485 // The buffer needs space for 3 ints, 3 commas and \0 |
3486 static const int kBufferSize = | 3486 static const int kBufferSize = |
3487 MaxDecimalDigitsIn<sizeof(int)>::kSigned * 3 + 3 + 1; // NOLINT | 3487 MaxDecimalDigitsIn<sizeof(int)>::kSigned * 3 + 3 + 1; // NOLINT |
3488 EmbeddedVector<char, kBufferSize> buffer; | 3488 EmbeddedVector<char, kBufferSize> buffer; |
3489 int edge_name_or_index = edge->type() == HeapGraphEdge::kElement | 3489 int edge_name_or_index = edge->type() == HeapGraphEdge::kElement |
3490 || edge->type() == HeapGraphEdge::kHidden | 3490 || edge->type() == HeapGraphEdge::kHidden |
3491 || edge->type() == HeapGraphEdge::kWeak | 3491 || edge->type() == HeapGraphEdge::kWeak |
3492 ? edge->index() : GetStringId(edge->name()); | 3492 ? edge->index() : GetStringId(edge->name()); |
| 3493 STATIC_CHECK(sizeof(int) == sizeof(edge->type())); // NOLINT |
| 3494 STATIC_CHECK(sizeof(int) == sizeof(edge_name_or_index)); // NOLINT |
| 3495 STATIC_CHECK(sizeof(int) == sizeof(GetNodeId(edge->to()))); // NOLINT |
3493 int result = OS::SNPrintF(buffer, ",%d,%d,%d", | 3496 int result = OS::SNPrintF(buffer, ",%d,%d,%d", |
3494 edge->type(), edge_name_or_index, GetNodeId(edge->to())); | 3497 edge->type(), edge_name_or_index, GetNodeId(edge->to())); |
3495 USE(result); | 3498 USE(result); |
3496 ASSERT(result != -1); | 3499 ASSERT(result != -1); |
3497 writer_->AddString(buffer.start()); | 3500 writer_->AddString(buffer.start()); |
3498 } | 3501 } |
3499 | 3502 |
3500 | 3503 |
3501 void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) { | 3504 void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) { |
3502 // The buffer needs space for 7 ints, 7 commas, \n and \0 | 3505 // The buffer needs space for 6 ints, 1 uint64_t, 7 commas, \n and \0 |
3503 static const int kBufferSize = | 3506 static const int kBufferSize = |
3504 MaxDecimalDigitsIn<sizeof(int)>::kSigned * 7 + 7 + 1 + 1; // NOLINT | 3507 6 * MaxDecimalDigitsIn<sizeof(int)>::kSigned // NOLINT |
| 3508 + MaxDecimalDigitsIn<sizeof(uint64_t)>::kUnsigned // NOLINT |
| 3509 + 7 + 1 + 1; |
3505 EmbeddedVector<char, kBufferSize> buffer; | 3510 EmbeddedVector<char, kBufferSize> buffer; |
3506 Vector<HeapGraphEdge> children = entry->children(); | 3511 Vector<HeapGraphEdge> children = entry->children(); |
3507 int result = OS::SNPrintF(buffer, "\n,%d,%d,%d,%d,%d,%d,%d", | 3512 STATIC_CHECK(sizeof(int) == sizeof(entry->type())); // NOLINT |
| 3513 STATIC_CHECK(sizeof(int) == sizeof(GetStringId(entry->name()))); // NOLINT |
| 3514 STATIC_CHECK(sizeof(uint64_t) == sizeof(entry->id())); // NOLINT |
| 3515 STATIC_CHECK(sizeof(int) == sizeof(entry->self_size())); // NOLINT |
| 3516 STATIC_CHECK(sizeof(int) == sizeof(entry->retained_size())); // NOLINT |
| 3517 STATIC_CHECK(sizeof(int) == sizeof(GetNodeId(entry->dominator()))); // NOLINT |
| 3518 STATIC_CHECK(sizeof(int) == sizeof(children.length())); // NOLINT |
| 3519 int result = OS::SNPrintF(buffer, "\n,%d,%d,%llu,%d,%d,%d,%d", |
3508 entry->type(), | 3520 entry->type(), |
3509 GetStringId(entry->name()), | 3521 GetStringId(entry->name()), |
3510 entry->id(), | 3522 entry->id(), |
3511 entry->self_size(), | 3523 entry->self_size(), |
3512 entry->retained_size(), | 3524 entry->retained_size(), |
3513 GetNodeId(entry->dominator()), | 3525 GetNodeId(entry->dominator()), |
3514 children.length()); | 3526 children.length()); |
3515 USE(result); | 3527 USE(result); |
3516 ASSERT(result != -1); | 3528 ASSERT(result != -1); |
3517 writer_->AddString(buffer.start()); | 3529 writer_->AddString(buffer.start()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3698 | 3710 |
3699 | 3711 |
3700 void HeapSnapshotJSONSerializer::SortHashMap( | 3712 void HeapSnapshotJSONSerializer::SortHashMap( |
3701 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3713 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3702 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3714 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3703 sorted_entries->Add(p); | 3715 sorted_entries->Add(p); |
3704 sorted_entries->Sort(SortUsingEntryValue); | 3716 sorted_entries->Sort(SortUsingEntryValue); |
3705 } | 3717 } |
3706 | 3718 |
3707 } } // namespace v8::internal | 3719 } } // namespace v8::internal |
OLD | NEW |