OLD | NEW |
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> |
| 8 |
7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 9 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
8 #include "base/trace_event/heap_profiler_allocation_register.h" | 10 #include "base/trace_event/heap_profiler_allocation_register.h" |
9 #include "base/trace_event/memory_allocator_dump.h" | 11 #include "base/trace_event/memory_allocator_dump.h" |
10 #include "base/trace_event/process_memory_dump.h" | 12 #include "base/trace_event/process_memory_dump.h" |
11 #include "base/trace_event/trace_event_memory_overhead.h" | 13 #include "base/trace_event/trace_event_memory_overhead.h" |
12 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
13 #include "platform/instrumentation/tracing/web_memory_allocator_dump.h" | 15 #include "platform/instrumentation/tracing/web_memory_allocator_dump.h" |
14 #include "platform/wtf/StdLibExtras.h" | 16 #include "platform/wtf/StdLibExtras.h" |
15 #include "platform/wtf/Threading.h" | 17 #include "platform/wtf/Threading.h" |
16 #include "public/platform/Platform.h" | 18 #include "public/platform/Platform.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // more detailed stats. | 62 // more detailed stats. |
61 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) | 63 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) |
62 ThreadState::Current()->CollectGarbage(BlinkGC::kNoHeapPointersOnStack, | 64 ThreadState::Current()->CollectGarbage(BlinkGC::kNoHeapPointersOnStack, |
63 BlinkGC::kTakeSnapshot, | 65 BlinkGC::kTakeSnapshot, |
64 BlinkGC::kForcedGC); | 66 BlinkGC::kForcedGC); |
65 DumpMemoryTotals(memory_dump); | 67 DumpMemoryTotals(memory_dump); |
66 | 68 |
67 if (is_heap_profiling_enabled_) { | 69 if (is_heap_profiling_enabled_) { |
68 // Overhead should always be reported, regardless of light vs. heavy. | 70 // Overhead should always be reported, regardless of light vs. heavy. |
69 base::trace_event::TraceEventMemoryOverhead overhead; | 71 base::trace_event::TraceEventMemoryOverhead overhead; |
70 base::hash_map<base::trace_event::AllocationContext, | 72 std::unordered_map<base::trace_event::AllocationContext, |
71 base::trace_event::AllocationMetrics> | 73 base::trace_event::AllocationMetrics> |
72 metrics_by_context; | 74 metrics_by_context; |
73 { | 75 { |
74 MutexLocker locker(allocation_register_mutex_); | 76 MutexLocker locker(allocation_register_mutex_); |
75 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { | 77 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { |
76 for (const auto& alloc_size : *allocation_register_) { | 78 for (const auto& alloc_size : *allocation_register_) { |
77 base::trace_event::AllocationMetrics& metrics = | 79 base::trace_event::AllocationMetrics& metrics = |
78 metrics_by_context[alloc_size.context]; | 80 metrics_by_context[alloc_size.context]; |
79 metrics.size += alloc_size.size; | 81 metrics.size += alloc_size.size; |
80 metrics.count++; | 82 metrics.count++; |
81 } | 83 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 allocation_register_->Insert(address, size, context); | 141 allocation_register_->Insert(address, size, context); |
140 } | 142 } |
141 | 143 |
142 void BlinkGCMemoryDumpProvider::Remove(Address address) { | 144 void BlinkGCMemoryDumpProvider::Remove(Address address) { |
143 MutexLocker locker(allocation_register_mutex_); | 145 MutexLocker locker(allocation_register_mutex_); |
144 if (allocation_register_) | 146 if (allocation_register_) |
145 allocation_register_->Remove(address); | 147 allocation_register_->Remove(address); |
146 } | 148 } |
147 | 149 |
148 } // namespace blink | 150 } // namespace blink |
OLD | NEW |