Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 153773002: A64: Synchronize with r16679. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 case kHidden: return "/hidden/"; 168 case kHidden: return "/hidden/";
169 case kObject: return "/object/"; 169 case kObject: return "/object/";
170 case kClosure: return "/closure/"; 170 case kClosure: return "/closure/";
171 case kString: return "/string/"; 171 case kString: return "/string/";
172 case kCode: return "/code/"; 172 case kCode: return "/code/";
173 case kArray: return "/array/"; 173 case kArray: return "/array/";
174 case kRegExp: return "/regexp/"; 174 case kRegExp: return "/regexp/";
175 case kHeapNumber: return "/number/"; 175 case kHeapNumber: return "/number/";
176 case kNative: return "/native/"; 176 case kNative: return "/native/";
177 case kSynthetic: return "/synthetic/"; 177 case kSynthetic: return "/synthetic/";
178 case kConsString: return "/concatenated string/";
179 case kSlicedString: return "/sliced string/";
178 default: return "???"; 180 default: return "???";
179 } 181 }
180 } 182 }
181 183
182 184
183 // It is very important to keep objects that form a heap snapshot 185 // It is very important to keep objects that form a heap snapshot
184 // as small as possible. 186 // as small as possible.
185 namespace { // Avoid littering the global namespace. 187 namespace { // Avoid littering the global namespace.
186 188
187 template <size_t ptr_size> struct SnapshotSizeConstants; 189 template <size_t ptr_size> struct SnapshotSizeConstants;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 return id; 465 return id;
464 } 466 }
465 467
466 468
467 void HeapObjectsMap::StopHeapObjectsTracking() { 469 void HeapObjectsMap::StopHeapObjectsTracking() {
468 time_intervals_.Clear(); 470 time_intervals_.Clear();
469 } 471 }
470 472
471 473
472 void HeapObjectsMap::UpdateHeapObjectsMap() { 474 void HeapObjectsMap::UpdateHeapObjectsMap() {
473 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, 475 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask,
474 "HeapSnapshotsCollection::UpdateHeapObjectsMap"); 476 "HeapSnapshotsCollection::UpdateHeapObjectsMap");
475 HeapIterator iterator(heap_); 477 HeapIterator iterator(heap_);
476 for (HeapObject* obj = iterator.next(); 478 for (HeapObject* obj = iterator.next();
477 obj != NULL; 479 obj != NULL;
478 obj = iterator.next()) { 480 obj = iterator.next()) {
479 FindOrAddEntry(obj->address(), obj->Size()); 481 FindOrAddEntry(obj->address(), obj->Size());
480 } 482 }
481 RemoveDeadEntries(); 483 RemoveDeadEntries();
482 } 484 }
483 485
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 ComputePointerHash(entry_info.addr)); 553 ComputePointerHash(entry_info.addr));
552 } 554 }
553 } 555 }
554 } 556 }
555 entries_.Rewind(first_free_entry); 557 entries_.Rewind(first_free_entry);
556 ASSERT(static_cast<uint32_t>(entries_.length()) - 1 == 558 ASSERT(static_cast<uint32_t>(entries_.length()) - 1 ==
557 entries_map_.occupancy()); 559 entries_map_.occupancy());
558 } 560 }
559 561
560 562
561 SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { 563 SnapshotObjectId HeapObjectsMap::GenerateId(Heap* heap,
564 v8::RetainedObjectInfo* info) {
562 SnapshotObjectId id = static_cast<SnapshotObjectId>(info->GetHash()); 565 SnapshotObjectId id = static_cast<SnapshotObjectId>(info->GetHash());
563 const char* label = info->GetLabel(); 566 const char* label = info->GetLabel();
564 id ^= StringHasher::HashSequentialString(label, 567 id ^= StringHasher::HashSequentialString(label,
565 static_cast<int>(strlen(label)), 568 static_cast<int>(strlen(label)),
566 HEAP->HashSeed()); 569 heap->HashSeed());
567 intptr_t element_count = info->GetElementCount(); 570 intptr_t element_count = info->GetElementCount();
568 if (element_count != -1) 571 if (element_count != -1)
569 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), 572 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count),
570 v8::internal::kZeroHashSeed); 573 v8::internal::kZeroHashSeed);
571 return id << 1; 574 return id << 1;
572 } 575 }
573 576
574 577
575 size_t HeapObjectsMap::GetUsedMemorySize() const { 578 size_t HeapObjectsMap::GetUsedMemorySize() const {
576 return 579 return
577 sizeof(*this) + 580 sizeof(*this) +
578 sizeof(HashMap::Entry) * entries_map_.capacity() + 581 sizeof(HashMap::Entry) * entries_map_.capacity() +
579 GetMemoryUsedByList(entries_) + 582 GetMemoryUsedByList(entries_) +
580 GetMemoryUsedByList(time_intervals_); 583 GetMemoryUsedByList(time_intervals_);
581 } 584 }
582 585
583 586
584 HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap) 587 HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap)
585 : is_tracking_objects_(false), 588 : is_tracking_objects_(false),
589 names_(heap),
586 ids_(heap) { 590 ids_(heap) {
587 } 591 }
588 592
589 593
590 static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) { 594 static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) {
591 delete *snapshot_ptr; 595 delete *snapshot_ptr;
592 } 596 }
593 597
594 598
595 HeapSnapshotsCollection::~HeapSnapshotsCollection() { 599 HeapSnapshotsCollection::~HeapSnapshotsCollection() {
(...skipping 18 matching lines...) Expand all
614 618
615 619
616 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { 620 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) {
617 snapshots_.RemoveElement(snapshot); 621 snapshots_.RemoveElement(snapshot);
618 } 622 }
619 623
620 624
621 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById( 625 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById(
622 SnapshotObjectId id) { 626 SnapshotObjectId id) {
623 // First perform a full GC in order to avoid dead objects. 627 // First perform a full GC in order to avoid dead objects.
624 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, 628 heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
625 "HeapSnapshotsCollection::FindHeapObjectById"); 629 "HeapSnapshotsCollection::FindHeapObjectById");
626 DisallowHeapAllocation no_allocation; 630 DisallowHeapAllocation no_allocation;
627 HeapObject* object = NULL; 631 HeapObject* object = NULL;
628 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); 632 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable);
629 // Make sure that object with the given id is still reachable. 633 // Make sure that object with the given id is still reachable.
630 for (HeapObject* obj = iterator.next(); 634 for (HeapObject* obj = iterator.next();
631 obj != NULL; 635 obj != NULL;
632 obj = iterator.next()) { 636 obj = iterator.next()) {
633 if (ids_.FindEntry(obj->address()) == id) { 637 if (ids_.FindEntry(obj->address()) == id) {
634 ASSERT(object == NULL); 638 ASSERT(object == NULL);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 const char* name = collection_->names()->GetName( 779 const char* name = collection_->names()->GetName(
776 GetConstructorName(JSObject::cast(object))); 780 GetConstructorName(JSObject::cast(object)));
777 if (object->IsJSGlobalObject()) { 781 if (object->IsJSGlobalObject()) {
778 const char* tag = objects_tags_.GetTag(object); 782 const char* tag = objects_tags_.GetTag(object);
779 if (tag != NULL) { 783 if (tag != NULL) {
780 name = collection_->names()->GetFormatted("%s / %s", name, tag); 784 name = collection_->names()->GetFormatted("%s / %s", name, tag);
781 } 785 }
782 } 786 }
783 return AddEntry(object, HeapEntry::kObject, name); 787 return AddEntry(object, HeapEntry::kObject, name);
784 } else if (object->IsString()) { 788 } else if (object->IsString()) {
789 String* string = String::cast(object);
790 if (string->IsConsString())
791 return AddEntry(object,
792 HeapEntry::kConsString,
793 "(concatenated string)");
794 if (string->IsSlicedString())
795 return AddEntry(object,
796 HeapEntry::kSlicedString,
797 "(sliced string)");
785 return AddEntry(object, 798 return AddEntry(object,
786 HeapEntry::kString, 799 HeapEntry::kString,
787 collection_->names()->GetName(String::cast(object))); 800 collection_->names()->GetName(String::cast(object)));
788 } else if (object->IsCode()) { 801 } else if (object->IsCode()) {
789 return AddEntry(object, HeapEntry::kCode, ""); 802 return AddEntry(object, HeapEntry::kCode, "");
790 } else if (object->IsSharedFunctionInfo()) { 803 } else if (object->IsSharedFunctionInfo()) {
791 String* name = String::cast(SharedFunctionInfo::cast(object)->name()); 804 String* name = String::cast(SharedFunctionInfo::cast(object)->name());
792 return AddEntry(object, 805 return AddEntry(object,
793 HeapEntry::kCode, 806 HeapEntry::kCode,
794 collection_->names()->GetName(name)); 807 collection_->names()->GetName(name));
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 v8::RetainedObjectInfo* info = reinterpret_cast<v8::RetainedObjectInfo*>(ptr); 1927 v8::RetainedObjectInfo* info = reinterpret_cast<v8::RetainedObjectInfo*>(ptr);
1915 intptr_t elements = info->GetElementCount(); 1928 intptr_t elements = info->GetElementCount();
1916 intptr_t size = info->GetSizeInBytes(); 1929 intptr_t size = info->GetSizeInBytes();
1917 const char* name = elements != -1 1930 const char* name = elements != -1
1918 ? collection_->names()->GetFormatted( 1931 ? collection_->names()->GetFormatted(
1919 "%s / %" V8_PTR_PREFIX "d entries", info->GetLabel(), elements) 1932 "%s / %" V8_PTR_PREFIX "d entries", info->GetLabel(), elements)
1920 : collection_->names()->GetCopy(info->GetLabel()); 1933 : collection_->names()->GetCopy(info->GetLabel());
1921 return snapshot_->AddEntry( 1934 return snapshot_->AddEntry(
1922 entries_type_, 1935 entries_type_,
1923 name, 1936 name,
1924 HeapObjectsMap::GenerateId(info), 1937 HeapObjectsMap::GenerateId(collection_->heap(), info),
1925 size != -1 ? static_cast<int>(size) : 0); 1938 size != -1 ? static_cast<int>(size) : 0);
1926 } 1939 }
1927 1940
1928 1941
1929 NativeObjectsExplorer::NativeObjectsExplorer( 1942 NativeObjectsExplorer::NativeObjectsExplorer(
1930 HeapSnapshot* snapshot, 1943 HeapSnapshot* snapshot,
1931 SnapshottingProgressReportingInterface* progress) 1944 SnapshottingProgressReportingInterface* progress)
1932 : isolate_(snapshot->collection()->heap()->isolate()), 1945 : isolate_(snapshot->collection()->heap()->isolate()),
1933 snapshot_(snapshot), 1946 snapshot_(snapshot),
1934 collection_(snapshot_->collection()), 1947 collection_(snapshot_->collection()),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 const char* label_; 2103 const char* label_;
2091 }; 2104 };
2092 2105
2093 2106
2094 NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo( 2107 NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo(
2095 const char* label) { 2108 const char* label) {
2096 const char* label_copy = collection_->names()->GetCopy(label); 2109 const char* label_copy = collection_->names()->GetCopy(label);
2097 uint32_t hash = StringHasher::HashSequentialString( 2110 uint32_t hash = StringHasher::HashSequentialString(
2098 label_copy, 2111 label_copy,
2099 static_cast<int>(strlen(label_copy)), 2112 static_cast<int>(strlen(label_copy)),
2100 HEAP->HashSeed()); 2113 isolate_->heap()->HashSeed());
2101 HashMap::Entry* entry = native_groups_.Lookup(const_cast<char*>(label_copy), 2114 HashMap::Entry* entry = native_groups_.Lookup(const_cast<char*>(label_copy),
2102 hash, true); 2115 hash, true);
2103 if (entry->value == NULL) { 2116 if (entry->value == NULL) {
2104 entry->value = new NativeGroupRetainedObjectInfo(label); 2117 entry->value = new NativeGroupRetainedObjectInfo(label);
2105 } 2118 }
2106 return static_cast<NativeGroupRetainedObjectInfo*>(entry->value); 2119 return static_cast<NativeGroupRetainedObjectInfo*>(entry->value);
2107 } 2120 }
2108 2121
2109 2122
2110 void NativeObjectsExplorer::SetNativeRootReference( 2123 void NativeObjectsExplorer::SetNativeRootReference(
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 JSON_A( 2591 JSON_A(
2579 JSON_S("hidden") "," 2592 JSON_S("hidden") ","
2580 JSON_S("array") "," 2593 JSON_S("array") ","
2581 JSON_S("string") "," 2594 JSON_S("string") ","
2582 JSON_S("object") "," 2595 JSON_S("object") ","
2583 JSON_S("code") "," 2596 JSON_S("code") ","
2584 JSON_S("closure") "," 2597 JSON_S("closure") ","
2585 JSON_S("regexp") "," 2598 JSON_S("regexp") ","
2586 JSON_S("number") "," 2599 JSON_S("number") ","
2587 JSON_S("native") "," 2600 JSON_S("native") ","
2588 JSON_S("synthetic")) "," 2601 JSON_S("synthetic") ","
2602 JSON_S("concatenated string") ","
2603 JSON_S("sliced string")) ","
2589 JSON_S("string") "," 2604 JSON_S("string") ","
2590 JSON_S("number") "," 2605 JSON_S("number") ","
2591 JSON_S("number") "," 2606 JSON_S("number") ","
2592 JSON_S("number") "," 2607 JSON_S("number") ","
2593 JSON_S("number") "," 2608 JSON_S("number") ","
2594 JSON_S("number")) "," 2609 JSON_S("number")) ","
2595 JSON_S("edge_fields") ":" JSON_A( 2610 JSON_S("edge_fields") ":" JSON_A(
2596 JSON_S("type") "," 2611 JSON_S("type") ","
2597 JSON_S("name_or_index") "," 2612 JSON_S("name_or_index") ","
2598 JSON_S("to_node")) "," 2613 JSON_S("to_node")) ","
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 2720
2706 2721
2707 void HeapSnapshotJSONSerializer::SortHashMap( 2722 void HeapSnapshotJSONSerializer::SortHashMap(
2708 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2723 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2709 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2724 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2710 sorted_entries->Add(p); 2725 sorted_entries->Add(p);
2711 sorted_entries->Sort(SortUsingEntryValue); 2726 sorted_entries->Sort(SortUsingEntryValue);
2712 } 2727 }
2713 2728
2714 } } // namespace v8::internal 2729 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698