Commit 18a6149f authored by pan.deng@intel.com's avatar pan.deng@intel.com

Add source line info for JS Profiler ticks to debug protocol.

Contributed by Denis Pravdin <denis.pravdin@intel.com>

Review URL: https://codereview.chromium.org/719853003

git-svn-id: svn://svn.chromium.org/blink/trunk@185428 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ad628a46
......@@ -64,6 +64,26 @@ double ScriptProfile::endTime() const
return static_cast<double>(m_profile->GetEndTime()) / 1000000;
}
static RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > buildInspectorObjectForPositionTicks(const v8::CpuProfileNode* node)
{
RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > array = TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>::create();
unsigned lineCount = node->GetHitLineCount();
if (!lineCount)
return array;
Vector<v8::CpuProfileNode::LineTick> entries(lineCount);
if (node->GetLineTicks(&entries[0], lineCount)) {
for (unsigned i = 0; i < lineCount; i++) {
RefPtr<TypeBuilder::Profiler::PositionTickInfo> line = TypeBuilder::Profiler::PositionTickInfo::create()
.setLine(entries[i].line)
.setTicks(entries[i].hit_count);
array->addItem(line);
}
}
return array;
}
static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor(const v8::CpuProfileNode* node)
{
v8::HandleScope handleScope(v8::Isolate::GetCurrent());
......@@ -75,6 +95,8 @@ static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor
children->addItem(buildInspectorObjectFor(child));
}
RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > positionTicks = buildInspectorObjectForPositionTicks(node);
RefPtr<TypeBuilder::Profiler::CPUProfileNode> result = TypeBuilder::Profiler::CPUProfileNode::create()
.setFunctionName(toCoreString(node->GetFunctionName()))
.setScriptId(String::number(node->GetScriptId()))
......@@ -84,6 +106,7 @@ static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor
.setHitCount(node->GetHitCount())
.setCallUID(node->GetCallUid())
.setChildren(children.release())
.setPositionTicks(positionTicks.release())
.setDeoptReason(node->GetBailoutReason())
.setId(node->GetNodeId());
return result.release();
......
......@@ -3647,7 +3647,8 @@
{ "name": "callUID", "type": "number", "description": "Call UID." },
{ "name": "children", "type": "array", "items": { "$ref": "CPUProfileNode" }, "description": "Child nodes." },
{ "name": "deoptReason", "type": "string", "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."},
{ "name": "id", "type": "integer", "description": "Unique id of the node." }
{ "name": "id", "type": "integer", "description": "Unique id of the node." },
{ "name": "positionTicks", "type": "array", "items": { "$ref": "PositionTickInfo" }, "description": "An array of source position ticks." }
]
},
{
......@@ -3661,6 +3662,15 @@
{ "name": "samples", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Ids of samples top nodes." },
{ "name": "timestamps", "optional": true, "type": "array", "items": { "type": "number" }, "description": "Timestamps of the samples in microseconds." }
]
},
{
"id": "PositionTickInfo",
"type": "object",
"description": "Specifies a number of samples attributed to a certain source position.",
"properties": [
{ "name": "line", "type": "integer", "description": "Source line number (1-based)." },
{ "name": "ticks", "type": "integer", "description": "Number of samples attributed to the source line." }
]
}
],
"commands": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment