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

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

Issue 2020363002: Revert of [heap] Do not invoke GC to make heap iterable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | src/runtime/runtime-debug.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/heap-snapshot-generator.h" 5 #include "src/profiler/heap-snapshot-generator.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/objects-body-descriptors.h" 10 #include "src/objects-body-descriptors.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 void HeapObjectsMap::StopHeapObjectsTracking() { 471 void HeapObjectsMap::StopHeapObjectsTracking() {
472 time_intervals_.Clear(); 472 time_intervals_.Clear();
473 } 473 }
474 474
475 475
476 void HeapObjectsMap::UpdateHeapObjectsMap() { 476 void HeapObjectsMap::UpdateHeapObjectsMap() {
477 if (FLAG_heap_profiler_trace_objects) { 477 if (FLAG_heap_profiler_trace_objects) {
478 PrintF("Begin HeapObjectsMap::UpdateHeapObjectsMap. map has %d entries.\n", 478 PrintF("Begin HeapObjectsMap::UpdateHeapObjectsMap. map has %d entries.\n",
479 entries_map_.occupancy()); 479 entries_map_.occupancy());
480 } 480 }
481 heap_->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, 481 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask,
482 "HeapObjectsMap::UpdateHeapObjectsMap"); 482 "HeapObjectsMap::UpdateHeapObjectsMap");
483 HeapIterator iterator(heap_); 483 HeapIterator iterator(heap_);
484 for (HeapObject* obj = iterator.next(); 484 for (HeapObject* obj = iterator.next();
485 obj != NULL; 485 obj != NULL;
486 obj = iterator.next()) { 486 obj = iterator.next()) {
487 FindOrAddEntry(obj->address(), obj->Size()); 487 FindOrAddEntry(obj->address(), obj->Size());
488 if (FLAG_heap_profiler_trace_objects) { 488 if (FLAG_heap_profiler_trace_objects) {
489 PrintF("Update object : %p %6d. Next address is %p\n", 489 PrintF("Update object : %p %6d. Next address is %p\n",
490 obj->address(), 490 obj->address(),
491 obj->Size(), 491 obj->Size(),
492 obj->address() + obj->Size()); 492 obj->address() + obj->Size());
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 RootsReferencesExtractor extractor(heap_); 1777 RootsReferencesExtractor extractor(heap_);
1778 heap_->IterateRoots(&extractor, VISIT_ONLY_STRONG); 1778 heap_->IterateRoots(&extractor, VISIT_ONLY_STRONG);
1779 extractor.SetCollectingAllReferences(); 1779 extractor.SetCollectingAllReferences();
1780 heap_->IterateRoots(&extractor, VISIT_ALL); 1780 heap_->IterateRoots(&extractor, VISIT_ALL);
1781 extractor.FillReferences(this); 1781 extractor.FillReferences(this);
1782 1782
1783 // We have to do two passes as sometimes FixedArrays are used 1783 // We have to do two passes as sometimes FixedArrays are used
1784 // to weakly hold their items, and it's impossible to distinguish 1784 // to weakly hold their items, and it's impossible to distinguish
1785 // between these cases without processing the array owner first. 1785 // between these cases without processing the array owner first.
1786 bool interrupted = 1786 bool interrupted =
1787 IterateAndExtractSinglePass<&V8HeapExplorer::ExtractReferencesPass1>( 1787 IterateAndExtractSinglePass<&V8HeapExplorer::ExtractReferencesPass1>() ||
1788 HeapObjectsFiltering::kFilterUnreachable) || 1788 IterateAndExtractSinglePass<&V8HeapExplorer::ExtractReferencesPass2>();
1789 IterateAndExtractSinglePass<&V8HeapExplorer::ExtractReferencesPass2>(
1790 HeapObjectsFiltering::kNoFiltering);
1791 1789
1792 if (interrupted) { 1790 if (interrupted) {
1793 filler_ = NULL; 1791 filler_ = NULL;
1794 return false; 1792 return false;
1795 } 1793 }
1796 1794
1797 filler_ = NULL; 1795 filler_ = NULL;
1798 return progress_->ProgressReport(true); 1796 return progress_->ProgressReport(true);
1799 } 1797 }
1800 1798
1801 template <V8HeapExplorer::ExtractReferencesMethod extractor> 1799
1802 bool V8HeapExplorer::IterateAndExtractSinglePass( 1800 template<V8HeapExplorer::ExtractReferencesMethod extractor>
1803 HeapObjectsFiltering filtering) { 1801 bool V8HeapExplorer::IterateAndExtractSinglePass() {
1804 // Now iterate the whole heap. 1802 // Now iterate the whole heap.
1805 bool interrupted = false; 1803 bool interrupted = false;
1806 HeapIterator iterator(heap_, filtering); 1804 HeapIterator iterator(heap_, HeapIterator::kFilterUnreachable);
1807 // Heap iteration with filtering must be finished in any case. 1805 // Heap iteration with filtering must be finished in any case.
1808 for (HeapObject* obj = iterator.next(); 1806 for (HeapObject* obj = iterator.next();
1809 obj != NULL; 1807 obj != NULL;
1810 obj = iterator.next(), progress_->ProgressStep()) { 1808 obj = iterator.next(), progress_->ProgressStep()) {
1811 if (interrupted) continue; 1809 if (interrupted) continue;
1812 1810
1813 size_t max_pointer = obj->Size() / kPointerSize; 1811 size_t max_pointer = obj->Size() / kPointerSize;
1814 if (max_pointer > marks_.size()) { 1812 if (max_pointer > marks_.size()) {
1815 // Clear the current bits. 1813 // Clear the current bits.
1816 std::vector<bool>().swap(marks_); 1814 std::vector<bool>().swap(marks_);
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 } 2498 }
2501 2499
2502 2500
2503 bool HeapSnapshotGenerator::GenerateSnapshot() { 2501 bool HeapSnapshotGenerator::GenerateSnapshot() {
2504 v8_heap_explorer_.TagGlobalObjects(); 2502 v8_heap_explorer_.TagGlobalObjects();
2505 2503
2506 // TODO(1562) Profiler assumes that any object that is in the heap after 2504 // TODO(1562) Profiler assumes that any object that is in the heap after
2507 // full GC is reachable from the root when computing dominators. 2505 // full GC is reachable from the root when computing dominators.
2508 // This is not true for weakly reachable objects. 2506 // This is not true for weakly reachable objects.
2509 // As a temporary solution we call GC twice. 2507 // As a temporary solution we call GC twice.
2510 heap_->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, 2508 heap_->CollectAllGarbage(
2511 "HeapSnapshotGenerator::GenerateSnapshot"); 2509 Heap::kMakeHeapIterableMask,
2512 heap_->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, 2510 "HeapSnapshotGenerator::GenerateSnapshot");
2513 "HeapSnapshotGenerator::GenerateSnapshot"); 2511 heap_->CollectAllGarbage(
2512 Heap::kMakeHeapIterableMask,
2513 "HeapSnapshotGenerator::GenerateSnapshot");
2514 2514
2515 #ifdef VERIFY_HEAP 2515 #ifdef VERIFY_HEAP
2516 Heap* debug_heap = heap_; 2516 Heap* debug_heap = heap_;
2517 if (FLAG_verify_heap) { 2517 if (FLAG_verify_heap) {
2518 debug_heap->Verify(); 2518 debug_heap->Verify();
2519 } 2519 }
2520 #endif 2520 #endif
2521 2521
2522 SetProgressTotal(2); // 2 passes. 2522 SetProgressTotal(2); // 2 passes.
2523 2523
(...skipping 28 matching lines...) Expand all
2552 return 2552 return
2553 control_->ReportProgressValue(progress_counter_, progress_total_) == 2553 control_->ReportProgressValue(progress_counter_, progress_total_) ==
2554 v8::ActivityControl::kContinue; 2554 v8::ActivityControl::kContinue;
2555 } 2555 }
2556 return true; 2556 return true;
2557 } 2557 }
2558 2558
2559 2559
2560 void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) { 2560 void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) {
2561 if (control_ == NULL) return; 2561 if (control_ == NULL) return;
2562 HeapIterator iterator(heap_, HeapObjectsFiltering::kFilterUnreachable); 2562 HeapIterator iterator(heap_, HeapIterator::kFilterUnreachable);
2563 progress_total_ = iterations_count * ( 2563 progress_total_ = iterations_count * (
2564 v8_heap_explorer_.EstimateObjectsCount(&iterator) + 2564 v8_heap_explorer_.EstimateObjectsCount(&iterator) +
2565 dom_explorer_.EstimateObjectsCount()); 2565 dom_explorer_.EstimateObjectsCount());
2566 progress_counter_ = 0; 2566 progress_counter_ = 0;
2567 } 2567 }
2568 2568
2569 2569
2570 bool HeapSnapshotGenerator::FillReferences() { 2570 bool HeapSnapshotGenerator::FillReferences() {
2571 SnapshotFiller filler(snapshot_, &entries_); 2571 SnapshotFiller filler(snapshot_, &entries_);
2572 return v8_heap_explorer_.IterateAndExtractReferences(&filler) 2572 return v8_heap_explorer_.IterateAndExtractReferences(&filler)
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 for (int i = 1; i < sorted_strings.length(); ++i) { 3123 for (int i = 1; i < sorted_strings.length(); ++i) {
3124 writer_->AddCharacter(','); 3124 writer_->AddCharacter(',');
3125 SerializeString(sorted_strings[i]); 3125 SerializeString(sorted_strings[i]);
3126 if (writer_->aborted()) return; 3126 if (writer_->aborted()) return;
3127 } 3127 }
3128 } 3128 }
3129 3129
3130 3130
3131 } // namespace internal 3131 } // namespace internal
3132 } // namespace v8 3132 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/heap-snapshot-generator.h ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698