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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 193 |
194 v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode( | 194 v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode( |
195 AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node, | 195 AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node, |
196 const std::map<int, Script*>& scripts) { | 196 const std::map<int, Script*>& scripts) { |
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 scripts.count(node->script_id_)) { | |
ofrobots
2016/03/30 22:35:35
Why use map::count? map::find would be more intuit
mattloring
2016/03/30 23:55:09
Done.
| |
204 // Cannot use std::map<T>::at because it is not available on android. | 205 // 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); | 206 auto non_const_scripts = const_cast<std::map<int, Script*>&>(scripts); |
206 Script* script = non_const_scripts[node->script_id_]; | 207 Script* script = non_const_scripts[node->script_id_]; |
207 if (script->name()->IsName()) { | 208 if (script->name()->IsName()) { |
208 Name* name = Name::cast(script->name()); | 209 Name* name = Name::cast(script->name()); |
209 script_name = ToApiHandle<v8::String>( | 210 script_name = ToApiHandle<v8::String>( |
210 isolate_->factory()->InternalizeUtf8String(names_->GetName(name))); | 211 isolate_->factory()->InternalizeUtf8String(names_->GetName(name))); |
211 } | 212 } |
212 Handle<Script> script_handle(script); | 213 Handle<Script> script_handle(script); |
213 | 214 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 auto profile = new v8::internal::AllocationProfile(); | 253 auto profile = new v8::internal::AllocationProfile(); |
253 | 254 |
254 TranslateAllocationNode(profile, &profile_root_, scripts); | 255 TranslateAllocationNode(profile, &profile_root_, scripts); |
255 | 256 |
256 return profile; | 257 return profile; |
257 } | 258 } |
258 | 259 |
259 | 260 |
260 } // namespace internal | 261 } // namespace internal |
261 } // namespace v8 | 262 } // namespace v8 |
OLD | NEW |