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

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

Issue 1826953003: Make sampling heap profiler work for short living scripts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 Local<v8::String> script_name = 197 Local<v8::String> script_name =
198 ToApiHandle<v8::String>(isolate_->factory()->InternalizeUtf8String("")); 198 ToApiHandle<v8::String>(isolate_->factory()->InternalizeUtf8String(""));
199 int line = v8::AllocationProfile::kNoLineNumberInfo; 199 int line = v8::AllocationProfile::kNoLineNumberInfo;
200 int column = v8::AllocationProfile::kNoColumnNumberInfo; 200 int column = v8::AllocationProfile::kNoColumnNumberInfo;
201 std::vector<v8::AllocationProfile::Allocation> allocations; 201 std::vector<v8::AllocationProfile::Allocation> allocations;
202 allocations.reserve(node->allocations_.size()); 202 allocations.reserve(node->allocations_.size());
203 if (node->script_id_ != v8::UnboundScript::kNoScriptId) { 203 if (node->script_id_ != v8::UnboundScript::kNoScriptId) {
204 // Cannot use std::map<T>::at because it is not available on android. 204 // Cannot use std::map<T>::at because it is not available on android.
205 auto non_const_scripts = const_cast<std::map<int, Script*>&>(scripts); 205 auto non_const_scripts = const_cast<std::map<int, Script*>&>(scripts);
206 Script* script = non_const_scripts[node->script_id_]; 206 Script* script = non_const_scripts[node->script_id_];
207 if (script->name()->IsName()) { 207 if (script) {
208 Name* name = Name::cast(script->name()); 208 if (script->name()->IsName()) {
209 script_name = ToApiHandle<v8::String>( 209 Name* name = Name::cast(script->name());
Michael Achenbach 2016/03/24 09:18:25 Experimental code-coverage reports this block as n
210 isolate_->factory()->InternalizeUtf8String(names_->GetName(name))); 210 script_name = ToApiHandle<v8::String>(
211 isolate_->factory()->InternalizeUtf8String(names_->GetName(name)));
212 }
213 Handle<Script> script_handle(script);
214 line = 1 + Script::GetLineNumber(script_handle, node->script_position_);
215 column =
216 1 + Script::GetColumnNumber(script_handle, node->script_position_);
211 } 217 }
212 Handle<Script> script_handle(script);
213
214 line = 1 + Script::GetLineNumber(script_handle, node->script_position_);
215 column = 1 + Script::GetColumnNumber(script_handle, node->script_position_);
216 for (auto alloc : node->allocations_) { 218 for (auto alloc : node->allocations_) {
217 allocations.push_back(ScaleSample(alloc.first, alloc.second)); 219 allocations.push_back(ScaleSample(alloc.first, alloc.second));
218 } 220 }
219 } 221 }
220 222
221 profile->nodes().push_back(v8::AllocationProfile::Node( 223 profile->nodes().push_back(v8::AllocationProfile::Node(
222 {ToApiHandle<v8::String>( 224 {ToApiHandle<v8::String>(
223 isolate_->factory()->InternalizeUtf8String(node->name_)), 225 isolate_->factory()->InternalizeUtf8String(node->name_)),
224 script_name, node->script_id_, node->script_position_, line, column, 226 script_name, node->script_id_, node->script_position_, line, column,
225 std::vector<v8::AllocationProfile::Node*>(), allocations})); 227 std::vector<v8::AllocationProfile::Node*>(), allocations}));
(...skipping 26 matching lines...) Expand all
252 auto profile = new v8::internal::AllocationProfile(); 254 auto profile = new v8::internal::AllocationProfile();
253 255
254 TranslateAllocationNode(profile, &profile_root_, scripts); 256 TranslateAllocationNode(profile, &profile_root_, scripts);
255 257
256 return profile; 258 return profile;
257 } 259 }
258 260
259 261
260 } // namespace internal 262 } // namespace internal
261 } // namespace v8 263 } // 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