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 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 | 2571 |
2572 filler_->SetNamedReference(type, | 2572 filler_->SetNamedReference(type, |
2573 parent_entry, | 2573 parent_entry, |
2574 name, | 2574 name, |
2575 child_entry); | 2575 child_entry); |
2576 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); | 2576 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); |
2577 } | 2577 } |
2578 } | 2578 } |
2579 | 2579 |
2580 | 2580 |
2581 void V8HeapExplorer::SetPropertyShortcutReference(HeapObject* parent_obj, | |
2582 int parent_entry, | |
2583 String* reference_name, | |
2584 Object* child_obj) { | |
2585 HeapEntry* child_entry = GetEntry(child_obj); | |
2586 if (child_entry != NULL) { | |
2587 filler_->SetNamedReference(HeapGraphEdge::kShortcut, | |
2588 parent_entry, | |
2589 collection_->names()->GetName(reference_name), | |
2590 child_entry); | |
2591 } | |
2592 } | |
2593 | |
2594 | |
2595 void V8HeapExplorer::SetRootGcRootsReference() { | 2581 void V8HeapExplorer::SetRootGcRootsReference() { |
2596 filler_->SetIndexedAutoIndexReference( | 2582 filler_->SetIndexedAutoIndexReference( |
2597 HeapGraphEdge::kElement, | 2583 HeapGraphEdge::kElement, |
2598 snapshot_->root()->index(), | 2584 snapshot_->root()->index(), |
2599 snapshot_->gc_roots()); | 2585 snapshot_->gc_roots()); |
2600 } | 2586 } |
2601 | 2587 |
2602 | 2588 |
2603 void V8HeapExplorer::SetUserGlobalReference(Object* child_obj) { | 2589 void V8HeapExplorer::SetUserGlobalReference(Object* child_obj) { |
2604 HeapEntry* child_entry = GetEntry(child_obj); | 2590 HeapEntry* child_entry = GetEntry(child_obj); |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3356 int last_digit = value % 10; | 3342 int last_digit = value % 10; |
3357 buffer[--buffer_pos] = '0' + last_digit; | 3343 buffer[--buffer_pos] = '0' + last_digit; |
3358 value /= 10; | 3344 value /= 10; |
3359 } while (value); | 3345 } while (value); |
3360 return result; | 3346 return result; |
3361 } | 3347 } |
3362 | 3348 |
3363 | 3349 |
3364 void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge, | 3350 void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge, |
3365 bool first_edge) { | 3351 bool first_edge) { |
3366 // The buffer needs space for 3 unsigned ints, 3 commas and \0 | 3352 // The buffer needs space for 3 unsigned ints, 3 commas, \n and \0 |
3367 static const int kBufferSize = | 3353 static const int kBufferSize = |
3368 MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned * 3 + 3 + 1; // NOLINT | 3354 MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned * 3 + 3 + 2; // NOLINT |
3369 EmbeddedVector<char, kBufferSize> buffer; | 3355 EmbeddedVector<char, kBufferSize> buffer; |
3370 int edge_name_or_index = edge->type() == HeapGraphEdge::kElement | 3356 int edge_name_or_index = edge->type() == HeapGraphEdge::kElement |
3371 || edge->type() == HeapGraphEdge::kHidden | 3357 || edge->type() == HeapGraphEdge::kHidden |
3372 || edge->type() == HeapGraphEdge::kWeak | 3358 || edge->type() == HeapGraphEdge::kWeak |
3373 ? edge->index() : GetStringId(edge->name()); | 3359 ? edge->index() : GetStringId(edge->name()); |
3374 int buffer_pos = 0; | 3360 int buffer_pos = 0; |
3375 if (!first_edge) { | 3361 if (!first_edge) { |
3376 buffer[buffer_pos++] = ','; | 3362 buffer[buffer_pos++] = ','; |
3377 } | 3363 } |
3378 buffer_pos = utoa(edge->type(), buffer, buffer_pos); | 3364 buffer_pos = utoa(edge->type(), buffer, buffer_pos); |
3379 buffer[buffer_pos++] = ','; | 3365 buffer[buffer_pos++] = ','; |
3380 buffer_pos = utoa(edge_name_or_index, buffer, buffer_pos); | 3366 buffer_pos = utoa(edge_name_or_index, buffer, buffer_pos); |
3381 buffer[buffer_pos++] = ','; | 3367 buffer[buffer_pos++] = ','; |
3382 buffer_pos = utoa(entry_index(edge->to()), buffer, buffer_pos); | 3368 buffer_pos = utoa(entry_index(edge->to()), buffer, buffer_pos); |
| 3369 buffer[buffer_pos++] = '\n'; |
3383 buffer[buffer_pos++] = '\0'; | 3370 buffer[buffer_pos++] = '\0'; |
3384 writer_->AddString(buffer.start()); | 3371 writer_->AddString(buffer.start()); |
3385 } | 3372 } |
3386 | 3373 |
3387 | 3374 |
3388 void HeapSnapshotJSONSerializer::SerializeEdges() { | 3375 void HeapSnapshotJSONSerializer::SerializeEdges() { |
3389 List<HeapGraphEdge*>& edges = snapshot_->children(); | 3376 List<HeapGraphEdge*>& edges = snapshot_->children(); |
3390 for (int i = 0; i < edges.length(); ++i) { | 3377 for (int i = 0; i < edges.length(); ++i) { |
3391 ASSERT(i == 0 || | 3378 ASSERT(i == 0 || |
3392 edges[i - 1]->from()->index() <= edges[i]->from()->index()); | 3379 edges[i - 1]->from()->index() <= edges[i]->from()->index()); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3579 | 3566 |
3580 | 3567 |
3581 void HeapSnapshotJSONSerializer::SortHashMap( | 3568 void HeapSnapshotJSONSerializer::SortHashMap( |
3582 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3569 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3583 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3570 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3584 sorted_entries->Add(p); | 3571 sorted_entries->Add(p); |
3585 sorted_entries->Sort(SortUsingEntryValue); | 3572 sorted_entries->Sort(SortUsingEntryValue); |
3586 } | 3573 } |
3587 | 3574 |
3588 } } // namespace v8::internal | 3575 } } // namespace v8::internal |
OLD | NEW |