Ignore:
Timestamp:
Jan 30, 2014, 5:34:54 PM (11 years ago)
Author:
[email protected]
Message:

Add column number and call timing support to LegacyProfiler.

https://bugs.webkit.org/show_bug.cgi?id=127764

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • profiler/CallIdentifier.h:

(JSC::CallIdentifier::CallIdentifier):
(JSC::CallIdentifier::functionName):
(JSC::CallIdentifier::url):
(JSC::CallIdentifier::lineNumber):
(JSC::CallIdentifier::columnNumber):
(JSC::CallIdentifier::operator==):
(JSC::CallIdentifier::operator!=):
(JSC::CallIdentifier::Hash::hash):
(WTF::HashTraits<JSC::CallIdentifier>::constructDeletedValue):
(WTF::HashTraits<JSC::CallIdentifier>::isDeletedValue):

  • profiler/LegacyProfiler.cpp:

(JSC::LegacyProfiler::willExecute):
(JSC::LegacyProfiler::didExecute):
(JSC::LegacyProfiler::exceptionUnwind):
(JSC::LegacyProfiler::createCallIdentifier):
(JSC::createCallIdentifierFromFunctionImp):

  • profiler/LegacyProfiler.h:
  • profiler/Profile.cpp:

(JSC::Profile::Profile):

  • profiler/Profile.h:

(JSC::Profile::uid):
(JSC::Profile::idleTime):
(JSC::Profile::setIdleTime):

  • profiler/ProfileGenerator.cpp:

(JSC::AddParentForConsoleStartFunctor::operator()):
(JSC::ProfileGenerator::addParentForConsoleStart):
(JSC::ProfileGenerator::willExecute):
(JSC::ProfileGenerator::didExecute):
(JSC::ProfileGenerator::stopProfiling):
(JSC::ProfileGenerator::removeProfileStart):
(JSC::ProfileGenerator::removeProfileEnd):

  • profiler/ProfileNode.cpp:

(JSC::ProfileNode::ProfileNode):
(JSC::ProfileNode::stopProfiling):
(JSC::ProfileNode::endAndRecordCall):
(JSC::ProfileNode::startTimer):
(JSC::ProfileNode::debugPrintData):

  • profiler/ProfileNode.h:

(JSC::ProfileNode::Call::Call):
(JSC::ProfileNode::Call::startTime):
(JSC::ProfileNode::Call::setStartTime):
(JSC::ProfileNode::Call::totalTime):
(JSC::ProfileNode::Call::setTotalTime):
(JSC::ProfileNode::id):
(JSC::ProfileNode::functionName):
(JSC::ProfileNode::url):
(JSC::ProfileNode::lineNumber):
(JSC::ProfileNode::columnNumber):
(JSC::ProfileNode::calls):
(JSC::ProfileNode::lastCall):
(JSC::ProfileNode::numberOfCalls):

Source/WebCore:

  • bindings/js/ScriptProfile.cpp:

(WebCore::ScriptProfile::idleTime):
(WebCore::buildInspectorObjectFor):
(WebCore::ScriptProfile::buildInspectorObject):

  • bindings/js/ScriptProfile.h:
  • inspector/InspectorHeapProfilerAgent.cpp:

(WebCore::InspectorHeapProfilerAgent::createSnapshotHeader):

  • inspector/InspectorProfilerAgent.cpp:

(WebCore::InspectorProfilerAgent::createSnapshotHeader):
(WebCore::InspectorProfilerAgent::getCPUProfile):

  • inspector/ScriptProfileNode.idl:
  • inspector/TimelineRecordFactory.cpp:

(WebCore::TimelineRecordFactory::appendProfile):

  • inspector/protocol/Profiler.json:

LayoutTests:

Update test and results to include column numbers.

  • fast/profiler/anonymous-event-handler-expected.txt:
  • fast/profiler/anonymous-function-called-from-different-contexts-expected.txt:
  • fast/profiler/anonymous-function-calls-built-in-functions-expected.txt:
  • fast/profiler/anonymous-function-calls-eval-expected.txt:
  • fast/profiler/anonymous-functions-with-display-names-expected.txt:
  • fast/profiler/apply-expected.txt:
  • fast/profiler/built-in-function-calls-anonymous-expected.txt:
  • fast/profiler/built-in-function-calls-user-defined-function-expected.txt:
  • fast/profiler/call-expected.txt:
  • fast/profiler/calling-the-function-that-started-the-profiler-from-another-scope-expected.txt:
  • fast/profiler/compare-multiple-profiles-expected.txt:
  • fast/profiler/constructor-expected.txt:
  • fast/profiler/dead-time-expected.txt:
  • fast/profiler/document-dot-write-expected.txt:
  • fast/profiler/event-handler-expected.txt:
  • fast/profiler/execution-context-and-eval-on-same-line-expected.txt:
  • fast/profiler/inline-event-handler-expected.txt:
  • fast/profiler/many-calls-in-the-same-scope-expected.txt:
  • fast/profiler/multiple-and-different-scoped-anonymous-function-calls-expected.txt:
  • fast/profiler/multiple-and-different-scoped-function-calls-expected.txt:
  • fast/profiler/multiple-anonymous-functions-called-from-the-same-function-expected.txt:
  • fast/profiler/multiple-frames-expected.txt:
  • fast/profiler/named-functions-with-display-names-expected.txt:
  • fast/profiler/nested-anonymous-functon-expected.txt:
  • fast/profiler/nested-start-and-stop-profiler-expected.txt:
  • fast/profiler/one-execution-context-expected.txt:
  • fast/profiler/profile-calls-in-included-file-expected.txt:
  • fast/profiler/profile-with-no-title-expected.txt:
  • fast/profiler/profiling-from-a-nested-location-but-stop-profiling-outside-the-nesting-expected.txt:
  • fast/profiler/profiling-from-a-nested-location-expected.txt:
  • fast/profiler/resources/profiler-test-JS-resources.js:

(printProfileNodeWithoutTime):

  • fast/profiler/simple-event-call-expected.txt:
  • fast/profiler/simple-no-level-change-expected.txt:
  • fast/profiler/start-and-stop-profiler-multiple-times-expected.txt:
  • fast/profiler/start-and-stop-profiling-in-the-same-function-expected.txt:
  • fast/profiler/stop-profiling-after-setTimeout-expected.txt:
  • fast/profiler/stop-then-function-call-expected.txt:
  • fast/profiler/two-execution-contexts-expected.txt:
  • fast/profiler/user-defined-function-calls-built-in-functions-expected.txt:
  • fast/profiler/window-dot-eval-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/ProfileNode.h

    r162796 r163140  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5555        }
    5656
     57        struct Call {
     58        public:
     59            Call(double startTime, double totalTime = NAN)
     60                : m_startTime(startTime)
     61                , m_totalTime(totalTime)
     62            {
     63            }
     64
     65            double startTime() const { return m_startTime; }
     66            void setStartTime(double time) { m_startTime = time; }
     67
     68            double totalTime() const { return m_totalTime; }
     69            void setTotalTime(double time) { m_totalTime = time; }
     70
     71        private:
     72            double m_startTime;
     73            double m_totalTime;
     74        };
     75
    5776        bool operator==(ProfileNode* node) { return m_callIdentifier == node->callIdentifier(); }
    5877
     
    6584        ExecState* callerCallFrame() const { return m_callerCallFrame; }
    6685        const CallIdentifier& callIdentifier() const { return m_callIdentifier; }
    67         unsigned long callUID() const { return m_callIdentifier.hash(); };
    68         const String& functionName() const { return m_callIdentifier.m_name; }
    69         const String& url() const { return m_callIdentifier.m_url; }
    70         unsigned lineNumber() const { return m_callIdentifier.m_lineNumber; }
     86        unsigned id() const { return m_callIdentifier.hash(); }
     87        const String& functionName() const { return m_callIdentifier.functionName(); }
     88        const String& url() const { return m_callIdentifier.url(); }
     89        unsigned lineNumber() const { return m_callIdentifier.lineNumber(); }
     90        unsigned columnNumber() const { return m_callIdentifier.columnNumber(); }
    7191
    7292        // Relationships
     
    81101
    82102        // Time members
    83         double startTime() const { return m_startTime; }
    84         void setStartTime(double startTime) { m_startTime = startTime; }
    85 
    86103        double totalTime() const { return m_totalTime; }
    87104        void setTotalTime(double time) { m_totalTime = time; }
     
    93110        double selfPercent() const { return (m_selfTime / (m_head ? m_head->totalTime() : totalTime())) * 100.0; }
    94111
    95         unsigned numberOfCalls() const { return m_numberOfCalls; }
     112        Vector<Call> calls() const { return m_calls; }
     113        Call& lastCall() { ASSERT(!m_calls.isEmpty()); return m_calls.last(); }
     114        size_t numberOfCalls() const { return m_calls.size(); }
    96115
    97116        // Children members
     
    104123
    105124        ProfileNode* traverseNextNodePostOrder() const;
    106 
    107         void endAndRecordCall();
    108125
    109126#ifndef NDEBUG
     
    121138        void startTimer();
    122139        void resetChildrensSiblings();
     140        void endAndRecordCall();
    123141
    124142        ExecState* m_callerCallFrame;
     
    128146        ProfileNode* m_nextSibling;
    129147
    130         double m_startTime;
    131148        double m_totalTime;
    132149        double m_selfTime;
    133         unsigned m_numberOfCalls;
    134150
     151        Vector<Call, 1> m_calls;
    135152        Vector<RefPtr<ProfileNode>> m_children;
    136153    };
Note: See TracChangeset for help on using the changeset viewer.