v8::Handle<v8::Value> V8ScriptProfileNode::childrenAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.ScriptProfileNode.childrenAccessorGetter");
    ScriptProfileNode* imp = V8ScriptProfileNode::toNative(info.Holder());
    const ProfileNodesList& children = imp->children();
    v8::Handle<v8::Array> result = v8::Array::New(children.size());
    int index = 0;
    ProfileNodesList::const_iterator end = children.end();
    for (ProfileNodesList::const_iterator iter = children.begin(); iter != end; ++iter)
        result->Set(v8::Integer::New(index++), toV8(iter->get()));
    return result;
}
示例#2
0
static PassRefPtr<Inspector::TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor(const JSC::ProfileNode* node)
{
    typedef Vector<RefPtr<JSC::ProfileNode>> ProfileNodesList;
    const ProfileNodesList& nodeChildren = node->children();
    ProfileNodesList::const_iterator end = nodeChildren.end();
    RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Profiler::CPUProfileNode>> children = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Profiler::CPUProfileNode>::create();
    for (ProfileNodesList::const_iterator iter = nodeChildren.begin(); iter != end; ++iter)
        children->addItem(buildInspectorObjectFor(iter->get()));

    RefPtr<Inspector::TypeBuilder::Profiler::CPUProfileNode> result = Inspector::TypeBuilder::Profiler::CPUProfileNode::create()
        .setFunctionName(node->functionName())
        .setUrl(node->url())
        .setLineNumber(node->lineNumber())
        .setTotalTime(node->totalTime())
        .setSelfTime(node->selfTime())
        .setNumberOfCalls(node->numberOfCalls())
        .setCallUID(node->callIdentifier().hash())
        .setChildren(children.release());
    return result.release();
}
static PassRefPtr<InspectorObject> buildInspectorObjectFor(const JSC::ProfileNode* node)
{
    RefPtr<InspectorObject> result = InspectorObject::create();

    result->setString("functionName", ustringToString(node->functionName()));
    result->setString("url", ustringToString(node->url()));
    result->setNumber("lineNumber", node->lineNumber());
    result->setNumber("totalTime", node->totalTime());
    result->setNumber("selfTime", node->selfTime());
    result->setNumber("numberOfCalls", node->numberOfCalls());
    result->setBoolean("visible", node->visible());
    result->setNumber("callUID", node->callIdentifier().hash());

    RefPtr<InspectorArray> childrenArray = InspectorArray::create();
    typedef Vector<RefPtr<JSC::ProfileNode> > ProfileNodesList;
    const ProfileNodesList& children = node->children();
    ProfileNodesList::const_iterator end = children.end();
    for (ProfileNodesList::const_iterator iter = children.begin(); iter != end; ++iter)
        childrenArray->pushObject(buildInspectorObjectFor(iter->get()));
    result->setArray("children", childrenArray);

    return result;
}