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

Side by Side Diff: src/profiler/sampling-heap-profiler.cc

Issue 1735733002: Fix iterator (std::vector) invalidation during sampling heap profile retrieval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add Reviewers Created 4 years, 10 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 | test/cctest/cctest.status » ('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 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 allocations.push_back(ScaleSample(alloc.first, alloc.second)); 216 allocations.push_back(ScaleSample(alloc.first, alloc.second));
217 } 217 }
218 } 218 }
219 219
220 profile->nodes().push_back(v8::AllocationProfile::Node( 220 profile->nodes().push_back(v8::AllocationProfile::Node(
221 {ToApiHandle<v8::String>( 221 {ToApiHandle<v8::String>(
222 isolate_->factory()->InternalizeUtf8String(node->name_)), 222 isolate_->factory()->InternalizeUtf8String(node->name_)),
223 script_name, node->script_id_, node->script_position_, line, column, 223 script_name, node->script_id_, node->script_position_, line, column,
224 std::vector<v8::AllocationProfile::Node*>(), allocations})); 224 std::vector<v8::AllocationProfile::Node*>(), allocations}));
225 v8::AllocationProfile::Node* current = &profile->nodes().back(); 225 v8::AllocationProfile::Node* current = &profile->nodes().back();
226 for (auto child : node->children_) { 226 size_t child_len = node->children_.size();
227 for (int i = 0; i < child_len; i++) {
alph 2016/02/25 00:49:16 I'd put a comment here about concurrent modificati
227 current->children.push_back( 228 current->children.push_back(
228 TranslateAllocationNode(profile, child, scripts)); 229 TranslateAllocationNode(profile, node->children_[i], scripts));
229 } 230 }
230 return current; 231 return current;
231 } 232 }
232 233
233 v8::AllocationProfile* SamplingHeapProfiler::GetAllocationProfile() { 234 v8::AllocationProfile* SamplingHeapProfiler::GetAllocationProfile() {
234 // To resolve positions to line/column numbers, we will need to look up 235 // To resolve positions to line/column numbers, we will need to look up
235 // scripts. Build a map to allow fast mapping from script id to script. 236 // scripts. Build a map to allow fast mapping from script id to script.
236 std::map<int, Script*> scripts; 237 std::map<int, Script*> scripts;
237 { 238 {
238 Script::Iterator iterator(isolate_); 239 Script::Iterator iterator(isolate_);
239 Script* script; 240 Script* script;
240 while ((script = iterator.Next())) { 241 while ((script = iterator.Next())) {
241 scripts[script->id()] = script; 242 scripts[script->id()] = script;
242 } 243 }
243 } 244 }
244 245
245 auto profile = new v8::internal::AllocationProfile(); 246 auto profile = new v8::internal::AllocationProfile();
246 247
247 TranslateAllocationNode(profile, &profile_root_, scripts); 248 TranslateAllocationNode(profile, &profile_root_, scripts);
248 249
249 return profile; 250 return profile;
250 } 251 }
251 252
252 253
253 } // namespace internal 254 } // namespace internal
254 } // namespace v8 255 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698