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 "base/trace_event/heap_profiler_allocation_context_tracker.h" | 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
8 #include "base/trace_event/heap_profiler_allocation_register.h" | 8 #include "base/trace_event/heap_profiler_allocation_register.h" |
9 #include "base/trace_event/trace_event_memory_overhead.h" | 9 #include "base/trace_event/trace_event_memory_overhead.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); | 74 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); |
75 } | 75 } |
76 memoryDump->dumpHeapUsage(bytesByContext, overhead, "blink_gc"); | 76 memoryDump->dumpHeapUsage(bytesByContext, overhead, "blink_gc"); |
77 } | 77 } |
78 | 78 |
79 // Merge all dumps collected by Heap::collectGarbage. | 79 // Merge all dumps collected by Heap::collectGarbage. |
80 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); | 80 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); |
81 return true; | 81 return true; |
82 } | 82 } |
83 | 83 |
84 void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled) | 84 void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled() |
85 { | 85 { |
86 if (enabled) { | 86 ASSERT(!m_isHeapProfilingEnabled); |
87 { | 87 { |
88 MutexLocker locker(m_allocationRegisterMutex); | 88 MutexLocker locker(m_allocationRegisterMutex); |
89 if (!m_allocationRegister) | 89 if (!m_allocationRegister) |
90 m_allocationRegister = adoptPtr(new base::trace_event::Allocatio
nRegister()); | 90 m_allocationRegister = adoptPtr(new base::trace_event::AllocationReg
ister()); |
91 } | |
92 HeapAllocHooks::setAllocationHook(reportAllocation); | |
93 HeapAllocHooks::setFreeHook(reportFree); | |
94 } else { | |
95 HeapAllocHooks::setAllocationHook(nullptr); | |
96 HeapAllocHooks::setFreeHook(nullptr); | |
97 } | 91 } |
98 m_isHeapProfilingEnabled = enabled; | 92 HeapAllocHooks::setAllocationHook(reportAllocation); |
| 93 HeapAllocHooks::setFreeHook(reportFree); |
| 94 m_isHeapProfilingEnabled = true; |
99 } | 95 } |
100 | 96 |
101 WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForC
urrentGC(const String& absoluteName) | 97 WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForC
urrentGC(const String& absoluteName) |
102 { | 98 { |
103 return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName); | 99 return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName); |
104 } | 100 } |
105 | 101 |
106 void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC() | 102 void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC() |
107 { | 103 { |
108 m_currentProcessMemoryDump->clear(); | 104 m_currentProcessMemoryDump->clear(); |
(...skipping 16 matching lines...) Expand all Loading... |
125 } | 121 } |
126 | 122 |
127 void BlinkGCMemoryDumpProvider::remove(Address address) | 123 void BlinkGCMemoryDumpProvider::remove(Address address) |
128 { | 124 { |
129 MutexLocker locker(m_allocationRegisterMutex); | 125 MutexLocker locker(m_allocationRegisterMutex); |
130 if (m_allocationRegister) | 126 if (m_allocationRegister) |
131 m_allocationRegister->Remove(address); | 127 m_allocationRegister->Remove(address); |
132 } | 128 } |
133 | 129 |
134 } // namespace blink | 130 } // namespace blink |
OLD | NEW |