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

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

Issue 1712893002: Preallocate sample buffer to avoid resizes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | no next file » | 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode( 177 v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode(
178 AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node, 178 AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node,
179 const std::map<int, Script*>& scripts) { 179 const std::map<int, Script*>& scripts) {
180 Local<v8::String> script_name = 180 Local<v8::String> script_name =
181 ToApiHandle<v8::String>(isolate_->factory()->InternalizeUtf8String("")); 181 ToApiHandle<v8::String>(isolate_->factory()->InternalizeUtf8String(""));
182 int line = v8::AllocationProfile::kNoLineNumberInfo; 182 int line = v8::AllocationProfile::kNoLineNumberInfo;
183 int column = v8::AllocationProfile::kNoColumnNumberInfo; 183 int column = v8::AllocationProfile::kNoColumnNumberInfo;
184 std::vector<v8::AllocationProfile::Allocation> allocations; 184 std::vector<v8::AllocationProfile::Allocation> allocations;
185 allocations.reserve(node->allocations_.size());
185 if (node->script_id_ != v8::UnboundScript::kNoScriptId) { 186 if (node->script_id_ != v8::UnboundScript::kNoScriptId) {
186 // Cannot use std::map<T>::at because it is not available on android. 187 // Cannot use std::map<T>::at because it is not available on android.
187 auto non_const_scripts = const_cast<std::map<int, Script*>&>(scripts); 188 auto non_const_scripts = const_cast<std::map<int, Script*>&>(scripts);
188 Script* script = non_const_scripts[node->script_id_]; 189 Script* script = non_const_scripts[node->script_id_];
189 if (script->name()->IsName()) { 190 if (script->name()->IsName()) {
190 Name* name = Name::cast(script->name()); 191 Name* name = Name::cast(script->name());
191 script_name = ToApiHandle<v8::String>( 192 script_name = ToApiHandle<v8::String>(
192 isolate_->factory()->InternalizeUtf8String(names_->GetName(name))); 193 isolate_->factory()->InternalizeUtf8String(names_->GetName(name)));
193 } 194 }
194 Handle<Script> script_handle(script); 195 Handle<Script> script_handle(script);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 auto profile = new v8::internal::AllocationProfile(); 229 auto profile = new v8::internal::AllocationProfile();
229 230
230 TranslateAllocationNode(profile, &profile_root_, scripts); 231 TranslateAllocationNode(profile, &profile_root_, scripts);
231 232
232 return profile; 233 return profile;
233 } 234 }
234 235
235 236
236 } // namespace internal 237 } // namespace internal
237 } // namespace v8 238 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698