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

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

Issue 23708030: Get rid of most uses of 'Temporary macro' HEAP (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nits Created 7 years, 3 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/isolate.h » ('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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 return id; 465 return id;
466 } 466 }
467 467
468 468
469 void HeapObjectsMap::StopHeapObjectsTracking() { 469 void HeapObjectsMap::StopHeapObjectsTracking() {
470 time_intervals_.Clear(); 470 time_intervals_.Clear();
471 } 471 }
472 472
473 473
474 void HeapObjectsMap::UpdateHeapObjectsMap() { 474 void HeapObjectsMap::UpdateHeapObjectsMap() {
475 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, 475 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask,
476 "HeapSnapshotsCollection::UpdateHeapObjectsMap"); 476 "HeapSnapshotsCollection::UpdateHeapObjectsMap");
477 HeapIterator iterator(heap_); 477 HeapIterator iterator(heap_);
478 for (HeapObject* obj = iterator.next(); 478 for (HeapObject* obj = iterator.next();
479 obj != NULL; 479 obj != NULL;
480 obj = iterator.next()) { 480 obj = iterator.next()) {
481 FindOrAddEntry(obj->address(), obj->Size()); 481 FindOrAddEntry(obj->address(), obj->Size());
482 } 482 }
483 RemoveDeadEntries(); 483 RemoveDeadEntries();
484 } 484 }
485 485
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 ComputePointerHash(entry_info.addr)); 553 ComputePointerHash(entry_info.addr));
554 } 554 }
555 } 555 }
556 } 556 }
557 entries_.Rewind(first_free_entry); 557 entries_.Rewind(first_free_entry);
558 ASSERT(static_cast<uint32_t>(entries_.length()) - 1 == 558 ASSERT(static_cast<uint32_t>(entries_.length()) - 1 ==
559 entries_map_.occupancy()); 559 entries_map_.occupancy());
560 } 560 }
561 561
562 562
563 SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { 563 SnapshotObjectId HeapObjectsMap::GenerateId(Heap* heap,
564 v8::RetainedObjectInfo* info) {
564 SnapshotObjectId id = static_cast<SnapshotObjectId>(info->GetHash()); 565 SnapshotObjectId id = static_cast<SnapshotObjectId>(info->GetHash());
565 const char* label = info->GetLabel(); 566 const char* label = info->GetLabel();
566 id ^= StringHasher::HashSequentialString(label, 567 id ^= StringHasher::HashSequentialString(label,
567 static_cast<int>(strlen(label)), 568 static_cast<int>(strlen(label)),
568 HEAP->HashSeed()); 569 heap->HashSeed());
569 intptr_t element_count = info->GetElementCount(); 570 intptr_t element_count = info->GetElementCount();
570 if (element_count != -1) 571 if (element_count != -1)
571 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), 572 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count),
572 v8::internal::kZeroHashSeed); 573 v8::internal::kZeroHashSeed);
573 return id << 1; 574 return id << 1;
574 } 575 }
575 576
576 577
577 size_t HeapObjectsMap::GetUsedMemorySize() const { 578 size_t HeapObjectsMap::GetUsedMemorySize() const {
578 return 579 return
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 617
617 618
618 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { 619 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) {
619 snapshots_.RemoveElement(snapshot); 620 snapshots_.RemoveElement(snapshot);
620 } 621 }
621 622
622 623
623 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById( 624 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById(
624 SnapshotObjectId id) { 625 SnapshotObjectId id) {
625 // First perform a full GC in order to avoid dead objects. 626 // First perform a full GC in order to avoid dead objects.
626 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, 627 heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
627 "HeapSnapshotsCollection::FindHeapObjectById"); 628 "HeapSnapshotsCollection::FindHeapObjectById");
628 DisallowHeapAllocation no_allocation; 629 DisallowHeapAllocation no_allocation;
629 HeapObject* object = NULL; 630 HeapObject* object = NULL;
630 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); 631 HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable);
631 // Make sure that object with the given id is still reachable. 632 // Make sure that object with the given id is still reachable.
632 for (HeapObject* obj = iterator.next(); 633 for (HeapObject* obj = iterator.next();
633 obj != NULL; 634 obj != NULL;
634 obj = iterator.next()) { 635 obj = iterator.next()) {
635 if (ids_.FindEntry(obj->address()) == id) { 636 if (ids_.FindEntry(obj->address()) == id) {
636 ASSERT(object == NULL); 637 ASSERT(object == NULL);
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 v8::RetainedObjectInfo* info = reinterpret_cast<v8::RetainedObjectInfo*>(ptr); 1926 v8::RetainedObjectInfo* info = reinterpret_cast<v8::RetainedObjectInfo*>(ptr);
1926 intptr_t elements = info->GetElementCount(); 1927 intptr_t elements = info->GetElementCount();
1927 intptr_t size = info->GetSizeInBytes(); 1928 intptr_t size = info->GetSizeInBytes();
1928 const char* name = elements != -1 1929 const char* name = elements != -1
1929 ? collection_->names()->GetFormatted( 1930 ? collection_->names()->GetFormatted(
1930 "%s / %" V8_PTR_PREFIX "d entries", info->GetLabel(), elements) 1931 "%s / %" V8_PTR_PREFIX "d entries", info->GetLabel(), elements)
1931 : collection_->names()->GetCopy(info->GetLabel()); 1932 : collection_->names()->GetCopy(info->GetLabel());
1932 return snapshot_->AddEntry( 1933 return snapshot_->AddEntry(
1933 entries_type_, 1934 entries_type_,
1934 name, 1935 name,
1935 HeapObjectsMap::GenerateId(info), 1936 HeapObjectsMap::GenerateId(collection_->heap(), info),
1936 size != -1 ? static_cast<int>(size) : 0); 1937 size != -1 ? static_cast<int>(size) : 0);
1937 } 1938 }
1938 1939
1939 1940
1940 NativeObjectsExplorer::NativeObjectsExplorer( 1941 NativeObjectsExplorer::NativeObjectsExplorer(
1941 HeapSnapshot* snapshot, 1942 HeapSnapshot* snapshot,
1942 SnapshottingProgressReportingInterface* progress) 1943 SnapshottingProgressReportingInterface* progress)
1943 : isolate_(snapshot->collection()->heap()->isolate()), 1944 : isolate_(snapshot->collection()->heap()->isolate()),
1944 snapshot_(snapshot), 1945 snapshot_(snapshot),
1945 collection_(snapshot_->collection()), 1946 collection_(snapshot_->collection()),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 const char* label_; 2102 const char* label_;
2102 }; 2103 };
2103 2104
2104 2105
2105 NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo( 2106 NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo(
2106 const char* label) { 2107 const char* label) {
2107 const char* label_copy = collection_->names()->GetCopy(label); 2108 const char* label_copy = collection_->names()->GetCopy(label);
2108 uint32_t hash = StringHasher::HashSequentialString( 2109 uint32_t hash = StringHasher::HashSequentialString(
2109 label_copy, 2110 label_copy,
2110 static_cast<int>(strlen(label_copy)), 2111 static_cast<int>(strlen(label_copy)),
2111 HEAP->HashSeed()); 2112 isolate_->heap()->HashSeed());
2112 HashMap::Entry* entry = native_groups_.Lookup(const_cast<char*>(label_copy), 2113 HashMap::Entry* entry = native_groups_.Lookup(const_cast<char*>(label_copy),
2113 hash, true); 2114 hash, true);
2114 if (entry->value == NULL) { 2115 if (entry->value == NULL) {
2115 entry->value = new NativeGroupRetainedObjectInfo(label); 2116 entry->value = new NativeGroupRetainedObjectInfo(label);
2116 } 2117 }
2117 return static_cast<NativeGroupRetainedObjectInfo*>(entry->value); 2118 return static_cast<NativeGroupRetainedObjectInfo*>(entry->value);
2118 } 2119 }
2119 2120
2120 2121
2121 void NativeObjectsExplorer::SetNativeRootReference( 2122 void NativeObjectsExplorer::SetNativeRootReference(
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 2719
2719 2720
2720 void HeapSnapshotJSONSerializer::SortHashMap( 2721 void HeapSnapshotJSONSerializer::SortHashMap(
2721 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2722 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2722 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2723 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2723 sorted_entries->Add(p); 2724 sorted_entries->Add(p);
2724 sorted_entries->Sort(SortUsingEntryValue); 2725 sorted_entries->Sort(SortUsingEntryValue);
2725 } 2726 }
2726 2727
2727 } } // namespace v8::internal 2728 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698