OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 "platform/v8_inspector/V8ProfilerAgentImpl.h" | 5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" |
6 | 6 |
7 #include "platform/v8_inspector/Atomics.h" | 7 #include "platform/v8_inspector/Atomics.h" |
8 #include "platform/v8_inspector/V8InspectorImpl.h" | 8 #include "platform/v8_inspector/V8InspectorImpl.h" |
9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
10 #include "platform/v8_inspector/V8StackTraceImpl.h" | 10 #include "platform/v8_inspector/V8StackTraceImpl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 return array; | 46 return array; |
47 } | 47 } |
48 | 48 |
49 std::unique_ptr<protocol::Profiler::CPUProfileNode> buildInspectorObjectFor(v8::
Isolate* isolate, const v8::CpuProfileNode* node) | 49 std::unique_ptr<protocol::Profiler::CPUProfileNode> buildInspectorObjectFor(v8::
Isolate* isolate, const v8::CpuProfileNode* node) |
50 { | 50 { |
51 v8::HandleScope handleScope(isolate); | 51 v8::HandleScope handleScope(isolate); |
52 | 52 |
53 std::unique_ptr<protocol::Array<int>> children = protocol::Array<int>::creat
e(); | |
54 const int childrenCount = node->GetChildrenCount(); | |
55 for (int i = 0; i < childrenCount; i++) | |
56 children->addItem(node->GetChild(i)->GetNodeId()); | |
57 | |
58 std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> posit
ionTicks = buildInspectorObjectForPositionTicks(node); | 53 std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> posit
ionTicks = buildInspectorObjectForPositionTicks(node); |
59 | |
60 std::unique_ptr<protocol::Runtime::CallFrame> callFrame = protocol::Runtime:
:CallFrame::create() | 54 std::unique_ptr<protocol::Runtime::CallFrame> callFrame = protocol::Runtime:
:CallFrame::create() |
61 .setFunctionName(toProtocolString(node->GetFunctionName())) | 55 .setFunctionName(toProtocolString(node->GetFunctionName())) |
62 .setScriptId(String16::fromInteger(node->GetScriptId())) | 56 .setScriptId(String16::fromInteger(node->GetScriptId())) |
63 .setUrl(toProtocolString(node->GetScriptResourceName())) | 57 .setUrl(toProtocolString(node->GetScriptResourceName())) |
64 .setLineNumber(node->GetLineNumber() - 1) | 58 .setLineNumber(node->GetLineNumber() - 1) |
65 .setColumnNumber(node->GetColumnNumber() - 1) | 59 .setColumnNumber(node->GetColumnNumber() - 1) |
66 .build(); | 60 .build(); |
67 std::unique_ptr<protocol::Profiler::CPUProfileNode> result = protocol::Profi
ler::CPUProfileNode::create() | 61 std::unique_ptr<protocol::Profiler::CPUProfileNode> result = protocol::Profi
ler::CPUProfileNode::create() |
68 .setCallFrame(std::move(callFrame)) | 62 .setCallFrame(std::move(callFrame)) |
69 .setHitCount(node->GetHitCount()) | 63 .setHitCount(node->GetHitCount()) |
70 .setChildren(std::move(children)) | |
71 .setPositionTicks(std::move(positionTicks)) | 64 .setPositionTicks(std::move(positionTicks)) |
72 .setDeoptReason(node->GetBailoutReason()) | 65 .setDeoptReason(node->GetBailoutReason()) |
73 .setId(node->GetNodeId()).build(); | 66 .setId(node->GetNodeId()).build(); |
| 67 |
| 68 const int childrenCount = node->GetChildrenCount(); |
| 69 if (childrenCount) { |
| 70 std::unique_ptr<protocol::Array<int>> children = protocol::Array<int>::c
reate(); |
| 71 for (int i = 0; i < childrenCount; i++) |
| 72 children->addItem(node->GetChild(i)->GetNodeId()); |
| 73 result->setChildren(std::move(children)); |
| 74 } |
74 return result; | 75 return result; |
75 } | 76 } |
76 | 77 |
77 std::unique_ptr<protocol::Array<int>> buildInspectorObjectForSamples(v8::CpuProf
ile* v8profile) | 78 std::unique_ptr<protocol::Array<int>> buildInspectorObjectForSamples(v8::CpuProf
ile* v8profile) |
78 { | 79 { |
79 std::unique_ptr<protocol::Array<int>> array = protocol::Array<int>::create()
; | 80 std::unique_ptr<protocol::Array<int>> array = protocol::Array<int>::create()
; |
80 int count = v8profile->GetSamplesCount(); | 81 int count = v8profile->GetSamplesCount(); |
81 for (int i = 0; i < count; i++) | 82 for (int i = 0; i < count; i++) |
82 array->addItem(v8profile->GetSample(i)->GetNodeId()); | 83 array->addItem(v8profile->GetSample(i)->GetNodeId()); |
83 return array; | 84 return array; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 v8::CpuProfiler* V8ProfilerAgentImpl::profiler() | 321 v8::CpuProfiler* V8ProfilerAgentImpl::profiler() |
321 { | 322 { |
322 #if ENSURE_V8_VERSION(5, 4) | 323 #if ENSURE_V8_VERSION(5, 4) |
323 return m_profiler; | 324 return m_profiler; |
324 #else | 325 #else |
325 return m_isolate->GetCpuProfiler(); | 326 return m_isolate->GetCpuProfiler(); |
326 #endif | 327 #endif |
327 } | 328 } |
328 | 329 |
329 } // namespace v8_inspector | 330 } // namespace v8_inspector |
OLD | NEW |