Chromium Code Reviews| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 tid_dumping_heap_ == PlatformThread::CurrentId()) | 229 tid_dumping_heap_ == PlatformThread::CurrentId()) |
| 230 return; | 230 return; |
| 231 | 231 |
| 232 // AllocationContextTracker will return nullptr when called re-reentrantly. | 232 // AllocationContextTracker will return nullptr when called re-reentrantly. |
| 233 // This is the case of GetInstanceForCurrentThread() being called for the | 233 // This is the case of GetInstanceForCurrentThread() being called for the |
| 234 // first time, which causes a new() inside the tracker which re-enters the | 234 // first time, which causes a new() inside the tracker which re-enters the |
| 235 // heap profiler, in which case we just want to early out. | 235 // heap profiler, in which case we just want to early out. |
| 236 auto tracker = AllocationContextTracker::GetInstanceForCurrentThread(); | 236 auto tracker = AllocationContextTracker::GetInstanceForCurrentThread(); |
| 237 if (!tracker) | 237 if (!tracker) |
| 238 return; | 238 return; |
| 239 AllocationContext context = tracker->GetContextSnapshot(); | |
| 240 | 239 |
| 241 AutoLock lock(allocation_register_lock_); | 240 AutoLock lock(allocation_register_lock_); |
| 242 if (!allocation_register_) | 241 if (!allocation_register_) |
| 243 return; | 242 return; |
| 244 | 243 |
| 244 AllocationContext context = tracker->GetContextSnapshot(); | |
|
Primiano Tucci (use gerrit)
2016/04/07 15:51:57
why moving this?
The point of this being before th
| |
| 245 allocation_register_->Insert(address, size, context); | 245 allocation_register_->Insert(address, size, context); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void MallocDumpProvider::RemoveAllocation(void* address) { | 248 void MallocDumpProvider::RemoveAllocation(void* address) { |
| 249 // No re-entrancy is expected here as none of the calls below should | 249 // No re-entrancy is expected here as none of the calls below should |
| 250 // cause a free()-s (|allocation_register_| does its own heap management). | 250 // cause a free()-s (|allocation_register_| does its own heap management). |
| 251 if (tid_dumping_heap_ != kInvalidThreadId && | 251 if (tid_dumping_heap_ != kInvalidThreadId && |
| 252 tid_dumping_heap_ == PlatformThread::CurrentId()) | 252 tid_dumping_heap_ == PlatformThread::CurrentId()) |
| 253 return; | 253 return; |
| 254 AutoLock lock(allocation_register_lock_); | 254 AutoLock lock(allocation_register_lock_); |
| 255 if (!allocation_register_) | 255 if (!allocation_register_) |
| 256 return; | 256 return; |
| 257 allocation_register_->Remove(address); | 257 allocation_register_->Remove(address); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace trace_event | 260 } // namespace trace_event |
| 261 } // namespace base | 261 } // namespace base |
| OLD | NEW |