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 "base/trace_event/malloc_dump_provider.h" | 5 #include "base/trace_event/malloc_dump_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
10 #include "base/allocator/allocator_shim.h" | 10 #include "base/allocator/allocator_shim.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // CurrentId() can be a slow operation (crbug.com/497226). This apparently | 222 // CurrentId() can be a slow operation (crbug.com/497226). This apparently |
223 // redundant condition short circuits the CurrentID() calls when unnecessary. | 223 // redundant condition short circuits the CurrentID() calls when unnecessary. |
224 if (tid_dumping_heap_ != kInvalidThreadId && | 224 if (tid_dumping_heap_ != kInvalidThreadId && |
225 tid_dumping_heap_ == PlatformThread::CurrentId()) | 225 tid_dumping_heap_ == PlatformThread::CurrentId()) |
226 return; | 226 return; |
227 | 227 |
228 // AllocationContextTracker will return nullptr when called re-reentrantly. | 228 // AllocationContextTracker will return nullptr when called re-reentrantly. |
229 // This is the case of GetInstanceForCurrentThread() being called for the | 229 // This is the case of GetInstanceForCurrentThread() being called for the |
230 // first time, which causes a new() inside the tracker which re-enters the | 230 // first time, which causes a new() inside the tracker which re-enters the |
231 // heap profiler, in which case we just want to early out. | 231 // heap profiler, in which case we just want to early out. |
232 auto tracker = AllocationContextTracker::GetInstanceForCurrentThread(); | 232 auto* tracker = AllocationContextTracker::GetInstanceForCurrentThread(); |
233 if (!tracker) | 233 if (!tracker) |
234 return; | 234 return; |
235 AllocationContext context = tracker->GetContextSnapshot(); | 235 AllocationContext context = tracker->GetContextSnapshot(); |
236 | 236 |
237 AutoLock lock(allocation_register_lock_); | 237 AutoLock lock(allocation_register_lock_); |
238 if (!allocation_register_) | 238 if (!allocation_register_) |
239 return; | 239 return; |
240 | 240 |
241 allocation_register_->Insert(address, size, context); | 241 allocation_register_->Insert(address, size, context); |
242 } | 242 } |
243 | 243 |
244 void MallocDumpProvider::RemoveAllocation(void* address) { | 244 void MallocDumpProvider::RemoveAllocation(void* address) { |
245 // No re-entrancy is expected here as none of the calls below should | 245 // No re-entrancy is expected here as none of the calls below should |
246 // cause a free()-s (|allocation_register_| does its own heap management). | 246 // cause a free()-s (|allocation_register_| does its own heap management). |
247 if (tid_dumping_heap_ != kInvalidThreadId && | 247 if (tid_dumping_heap_ != kInvalidThreadId && |
248 tid_dumping_heap_ == PlatformThread::CurrentId()) | 248 tid_dumping_heap_ == PlatformThread::CurrentId()) |
249 return; | 249 return; |
250 AutoLock lock(allocation_register_lock_); | 250 AutoLock lock(allocation_register_lock_); |
251 if (!allocation_register_) | 251 if (!allocation_register_) |
252 return; | 252 return; |
253 allocation_register_->Remove(address); | 253 allocation_register_->Remove(address); |
254 } | 254 } |
255 | 255 |
256 } // namespace trace_event | 256 } // namespace trace_event |
257 } // namespace base | 257 } // namespace base |
OLD | NEW |