OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 "src/profiler/sampling-heap-profiler.h" | 5 #include "src/profiler/sampling-heap-profiler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <memory> | 8 #include <memory> |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 92 matching lines...) Loading... | |
103 // are taking the sample. | 103 // are taking the sample. |
104 heap()->CreateFillerObjectAt(soon_object, static_cast<int>(size), | 104 heap()->CreateFillerObjectAt(soon_object, static_cast<int>(size), |
105 ClearRecordedSlots::kNo); | 105 ClearRecordedSlots::kNo); |
106 | 106 |
107 Local<v8::Value> loc = v8::Utils::ToLocal(obj); | 107 Local<v8::Value> loc = v8::Utils::ToLocal(obj); |
108 | 108 |
109 AllocationNode* node = AddStack(); | 109 AllocationNode* node = AddStack(); |
110 node->allocations_[size]++; | 110 node->allocations_[size]++; |
111 Sample* sample = new Sample(size, node, loc, this); | 111 Sample* sample = new Sample(size, node, loc, this); |
112 samples_.insert(sample); | 112 samples_.insert(sample); |
113 sample->global.SetWeak(sample, OnWeakCallback, WeakCallbackType::kParameter); | 113 sample->global.SetWeak(sample, OnWeakCallback, WeakCallbackType::kParameter); |
Michael Lippautz
2016/05/10 08:32:58
Left over? Rebase needed?
Hannes Payer (out of office)
2016/05/10 09:04:45
Strange. Done.
| |
114 sample->global.MarkIndependent(); | |
115 } | 114 } |
116 | 115 |
117 void SamplingHeapProfiler::OnWeakCallback( | 116 void SamplingHeapProfiler::OnWeakCallback( |
118 const WeakCallbackInfo<Sample>& data) { | 117 const WeakCallbackInfo<Sample>& data) { |
119 Sample* sample = data.GetParameter(); | 118 Sample* sample = data.GetParameter(); |
120 AllocationNode* node = sample->owner; | 119 AllocationNode* node = sample->owner; |
121 DCHECK(node->allocations_[sample->size] > 0); | 120 DCHECK(node->allocations_[sample->size] > 0); |
122 node->allocations_[sample->size]--; | 121 node->allocations_[sample->size]--; |
123 if (node->allocations_[sample->size] == 0) { | 122 if (node->allocations_[sample->size] == 0) { |
124 node->allocations_.erase(sample->size); | 123 node->allocations_.erase(sample->size); |
(...skipping 148 matching lines...) Loading... | |
273 } | 272 } |
274 } | 273 } |
275 auto profile = new v8::internal::AllocationProfile(); | 274 auto profile = new v8::internal::AllocationProfile(); |
276 TranslateAllocationNode(profile, &profile_root_, scripts); | 275 TranslateAllocationNode(profile, &profile_root_, scripts); |
277 return profile; | 276 return profile; |
278 } | 277 } |
279 | 278 |
280 | 279 |
281 } // namespace internal | 280 } // namespace internal |
282 } // namespace v8 | 281 } // namespace v8 |
OLD | NEW |