Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1473)

Side by Side Diff: runtime/vm/malloc_hooks_tcmalloc.cc

Issue 2966593002: Updated native memory allocation profiling to use its own sample buffer instead of sharing a sample… (Closed)
Patch Set: Updated native memory allocation profiling to use its own sample buffer instead of sharing a sample… Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/malloc_hooks_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/malloc_hooks_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698