| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) | 7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) |
| 8 | 8 |
| 9 #include "vm/malloc_hooks.h" | 9 #include "vm/malloc_hooks.h" |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // the first OSThread in order to prevent deadlocks. | 136 // the first OSThread in order to prevent deadlocks. |
| 137 if (MallocHooksState::ProfilingEnabled() && | 137 if (MallocHooksState::ProfilingEnabled() && |
| 138 MallocHooksState::stack_trace_collection_enabled()) { | 138 MallocHooksState::stack_trace_collection_enabled()) { |
| 139 sample_ = Profiler::SampleNativeAllocation(kSkipCount, address, | 139 sample_ = Profiler::SampleNativeAllocation(kSkipCount, address, |
| 140 allocation_size); | 140 allocation_size); |
| 141 ASSERT((sample_ == NULL) || | 141 ASSERT((sample_ == NULL) || |
| 142 (sample_->native_allocation_address() == address_)); | 142 (sample_->native_allocation_address() == address_)); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 ~AllocationInfo() { |
| 147 if (sample_ != NULL) { |
| 148 Profiler::allocation_sample_buffer()->FreeAllocationSample(sample_); |
| 149 } |
| 150 } |
| 151 |
| 146 Sample* sample() const { return sample_; } | 152 Sample* sample() const { return sample_; } |
| 147 intptr_t allocation_size() const { return allocation_size_; } | 153 intptr_t allocation_size() const { return allocation_size_; } |
| 148 | 154 |
| 149 private: | 155 private: |
| 150 // Note: sample_ is not owned by AllocationInfo, but by the SampleBuffer | 156 // Note: sample_ is not owned by AllocationInfo, but by the SampleBuffer |
| 151 // created by the profiler. As such, this is only here to track if the sample | 157 // created by the profiler. As such, this is only here to track if the sample |
| 152 // is still associated with a native allocation, and its fields are never | 158 // is still associated with a native allocation, and its fields are never |
| 153 // accessed from this class. | 159 // accessed from this class. |
| 154 Sample* sample_; | 160 Sample* sample_; |
| 155 uword address_; | 161 uword address_; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 const bool result = MallocHooksState::address_map()->Remove(ptr); | 444 const bool result = MallocHooksState::address_map()->Remove(ptr); |
| 439 ASSERT(result); | 445 ASSERT(result); |
| 440 delete allocation_info; | 446 delete allocation_info; |
| 441 } | 447 } |
| 442 } | 448 } |
| 443 } | 449 } |
| 444 | 450 |
| 445 } // namespace dart | 451 } // namespace dart |
| 446 | 452 |
| 447 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) | 453 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) |
| OLD | NEW |