| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 heap()->CreateFillerObjectAt(soon_object, static_cast<int>(size), | 102 heap()->CreateFillerObjectAt(soon_object, static_cast<int>(size), |
| 103 ClearRecordedSlots::kNo); | 103 ClearRecordedSlots::kNo); |
| 104 | 104 |
| 105 Local<v8::Value> loc = v8::Utils::ToLocal(obj); | 105 Local<v8::Value> loc = v8::Utils::ToLocal(obj); |
| 106 | 106 |
| 107 AllocationNode* node = AddStack(); | 107 AllocationNode* node = AddStack(); |
| 108 node->allocations_[size]++; | 108 node->allocations_[size]++; |
| 109 Sample* sample = new Sample(size, node, loc, this); | 109 Sample* sample = new Sample(size, node, loc, this); |
| 110 samples_.insert(sample); | 110 samples_.insert(sample); |
| 111 sample->global.SetWeak(sample, OnWeakCallback, WeakCallbackType::kParameter); | 111 sample->global.SetWeak(sample, OnWeakCallback, WeakCallbackType::kParameter); |
| 112 sample->global.MarkIndependent(); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void SamplingHeapProfiler::OnWeakCallback( | 115 void SamplingHeapProfiler::OnWeakCallback( |
| 115 const WeakCallbackInfo<Sample>& data) { | 116 const WeakCallbackInfo<Sample>& data) { |
| 116 Sample* sample = data.GetParameter(); | 117 Sample* sample = data.GetParameter(); |
| 117 AllocationNode* node = sample->owner; | 118 AllocationNode* node = sample->owner; |
| 118 DCHECK(node->allocations_[sample->size] > 0); | 119 DCHECK(node->allocations_[sample->size] > 0); |
| 119 node->allocations_[sample->size]--; | 120 node->allocations_[sample->size]--; |
| 120 if (node->allocations_[sample->size] == 0) { | 121 if (node->allocations_[sample->size] == 0) { |
| 121 node->allocations_.erase(sample->size); | 122 node->allocations_.erase(sample->size); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 267 } |
| 267 } | 268 } |
| 268 auto profile = new v8::internal::AllocationProfile(); | 269 auto profile = new v8::internal::AllocationProfile(); |
| 269 TranslateAllocationNode(profile, &profile_root_, scripts); | 270 TranslateAllocationNode(profile, &profile_root_, scripts); |
| 270 return profile; | 271 return profile; |
| 271 } | 272 } |
| 272 | 273 |
| 273 | 274 |
| 274 } // namespace internal | 275 } // namespace internal |
| 275 } // namespace v8 | 276 } // namespace v8 |
| OLD | NEW |