OLD | NEW |
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 time_intervals_.Clear(); | 469 time_intervals_.Clear(); |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 void HeapObjectsMap::UpdateHeapObjectsMap() { | 473 void HeapObjectsMap::UpdateHeapObjectsMap() { |
474 if (FLAG_heap_profiler_trace_objects) { | 474 if (FLAG_heap_profiler_trace_objects) { |
475 PrintF("Begin HeapObjectsMap::UpdateHeapObjectsMap. map has %d entries.\n", | 475 PrintF("Begin HeapObjectsMap::UpdateHeapObjectsMap. map has %d entries.\n", |
476 entries_map_.occupancy()); | 476 entries_map_.occupancy()); |
477 } | 477 } |
478 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 478 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
479 "HeapObjectsMap::UpdateHeapObjectsMap"); | 479 GarbageCollectionReason::kHeapProfiler); |
480 HeapIterator iterator(heap_); | 480 HeapIterator iterator(heap_); |
481 for (HeapObject* obj = iterator.next(); | 481 for (HeapObject* obj = iterator.next(); |
482 obj != NULL; | 482 obj != NULL; |
483 obj = iterator.next()) { | 483 obj = iterator.next()) { |
484 FindOrAddEntry(obj->address(), obj->Size()); | 484 FindOrAddEntry(obj->address(), obj->Size()); |
485 if (FLAG_heap_profiler_trace_objects) { | 485 if (FLAG_heap_profiler_trace_objects) { |
486 PrintF("Update object : %p %6d. Next address is %p\n", | 486 PrintF("Update object : %p %6d. Next address is %p\n", |
487 static_cast<void*>(obj->address()), obj->Size(), | 487 static_cast<void*>(obj->address()), obj->Size(), |
488 static_cast<void*>(obj->address() + obj->Size())); | 488 static_cast<void*>(obj->address() + obj->Size())); |
489 } | 489 } |
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 } | 2499 } |
2500 | 2500 |
2501 | 2501 |
2502 bool HeapSnapshotGenerator::GenerateSnapshot() { | 2502 bool HeapSnapshotGenerator::GenerateSnapshot() { |
2503 v8_heap_explorer_.TagGlobalObjects(); | 2503 v8_heap_explorer_.TagGlobalObjects(); |
2504 | 2504 |
2505 // TODO(1562) Profiler assumes that any object that is in the heap after | 2505 // TODO(1562) Profiler assumes that any object that is in the heap after |
2506 // full GC is reachable from the root when computing dominators. | 2506 // full GC is reachable from the root when computing dominators. |
2507 // This is not true for weakly reachable objects. | 2507 // This is not true for weakly reachable objects. |
2508 // As a temporary solution we call GC twice. | 2508 // As a temporary solution we call GC twice. |
2509 heap_->CollectAllGarbage( | 2509 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
2510 Heap::kMakeHeapIterableMask, | 2510 GarbageCollectionReason::kHeapProfiler); |
2511 "HeapSnapshotGenerator::GenerateSnapshot"); | 2511 heap_->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
2512 heap_->CollectAllGarbage( | 2512 GarbageCollectionReason::kHeapProfiler); |
2513 Heap::kMakeHeapIterableMask, | |
2514 "HeapSnapshotGenerator::GenerateSnapshot"); | |
2515 | 2513 |
2516 #ifdef VERIFY_HEAP | 2514 #ifdef VERIFY_HEAP |
2517 Heap* debug_heap = heap_; | 2515 Heap* debug_heap = heap_; |
2518 if (FLAG_verify_heap) { | 2516 if (FLAG_verify_heap) { |
2519 debug_heap->Verify(); | 2517 debug_heap->Verify(); |
2520 } | 2518 } |
2521 #endif | 2519 #endif |
2522 | 2520 |
2523 SetProgressTotal(2); // 2 passes. | 2521 SetProgressTotal(2); // 2 passes. |
2524 | 2522 |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3123 for (int i = 1; i < sorted_strings.length(); ++i) { | 3121 for (int i = 1; i < sorted_strings.length(); ++i) { |
3124 writer_->AddCharacter(','); | 3122 writer_->AddCharacter(','); |
3125 SerializeString(sorted_strings[i]); | 3123 SerializeString(sorted_strings[i]); |
3126 if (writer_->aborted()) return; | 3124 if (writer_->aborted()) return; |
3127 } | 3125 } |
3128 } | 3126 } |
3129 | 3127 |
3130 | 3128 |
3131 } // namespace internal | 3129 } // namespace internal |
3132 } // namespace v8 | 3130 } // namespace v8 |
OLD | NEW |