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

Side by Side Diff: third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Fix rebase damage Created 3 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 "platform/heap/BlinkGCMemoryDumpProvider.h" 5 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 8
9 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 9 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
10 #include "base/trace_event/heap_profiler_allocation_register.h" 10 #include "base/trace_event/heap_profiler_allocation_register.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 MemoryDumpLevelOfDetail level_of_detail = args.level_of_detail; 60 MemoryDumpLevelOfDetail level_of_detail = args.level_of_detail;
61 // In the case of a detailed dump perform a mark-only GC pass to collect 61 // In the case of a detailed dump perform a mark-only GC pass to collect
62 // more detailed stats. 62 // more detailed stats.
63 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) 63 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED)
64 ThreadState::Current()->CollectGarbage(BlinkGC::kNoHeapPointersOnStack, 64 ThreadState::Current()->CollectGarbage(BlinkGC::kNoHeapPointersOnStack,
65 BlinkGC::kTakeSnapshot, 65 BlinkGC::kTakeSnapshot,
66 BlinkGC::kForcedGC); 66 BlinkGC::kForcedGC);
67 DumpMemoryTotals(memory_dump); 67 DumpMemoryTotals(memory_dump);
68 68
69 if (is_heap_profiling_enabled_) { 69 if (is_heap_profiling_enabled_) {
70 // Overhead should always be reported, regardless of light vs. heavy. 70 MutexLocker locker(allocation_register_mutex_);
71 base::trace_event::TraceEventMemoryOverhead overhead; 71 memory_dump->DumpHeapUsage(*allocation_register_, "blink_gc");
72 std::unordered_map<base::trace_event::AllocationContext,
73 base::trace_event::AllocationMetrics>
74 metrics_by_context;
75 {
76 MutexLocker locker(allocation_register_mutex_);
77 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
78 for (const auto& alloc_size : *allocation_register_) {
79 base::trace_event::AllocationMetrics& metrics =
80 metrics_by_context[alloc_size.context];
81 metrics.size += alloc_size.size;
82 metrics.count++;
83 }
84 }
85 allocation_register_->EstimateTraceMemoryOverhead(&overhead);
86 }
87 memory_dump->DumpHeapUsage(metrics_by_context, overhead, "blink_gc");
88 } 72 }
89 73
90 // Merge all dumps collected by ThreadHeap::collectGarbage. 74 // Merge all dumps collected by ThreadHeap::collectGarbage.
91 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) 75 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED)
92 memory_dump->TakeAllDumpsFrom(current_process_memory_dump_.get()); 76 memory_dump->TakeAllDumpsFrom(current_process_memory_dump_.get());
93 return true; 77 return true;
94 } 78 }
95 79
96 void BlinkGCMemoryDumpProvider::OnHeapProfilingEnabled(bool enabled) { 80 void BlinkGCMemoryDumpProvider::OnHeapProfilingEnabled(bool enabled) {
97 if (enabled) { 81 if (enabled) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 allocation_register_->Insert(address, size, context); 125 allocation_register_->Insert(address, size, context);
142 } 126 }
143 127
144 void BlinkGCMemoryDumpProvider::Remove(Address address) { 128 void BlinkGCMemoryDumpProvider::Remove(Address address) {
145 MutexLocker locker(allocation_register_mutex_); 129 MutexLocker locker(allocation_register_mutex_);
146 if (allocation_register_) 130 if (allocation_register_)
147 allocation_register_->Remove(address); 131 allocation_register_->Remove(address);
148 } 132 }
149 133
150 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698