Changeset 163139 in webkit


Ignore:
Timestamp:
Jan 30, 2014 5:34:31 PM (10 years ago)
Author:
timothy@apple.com
Message:

Include profile with FunctionCall and EvaluateScript Timeline records.

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

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

  • inspector/InjectedScriptBase.cpp:

(Inspector::InjectedScriptBase::callFunctionWithEvalEnabled):

  • inspector/InspectorEnvironment.h:
  • inspector/JSGlobalObjectInspectorController.h:

Source/WebCore:

  • bindings/js/JSCallbackData.cpp:

(WebCore::JSCallbackData::invokeCallback):

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):

  • bindings/js/JSMutationCallback.cpp:

(WebCore::JSMutationCallback::call):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::executeFunctionInContext):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::evaluateInWorld):

  • inspector/InspectorController.cpp:

(WebCore::InspectorController::didCallInjectedScriptFunction):

  • inspector/InspectorController.h:
  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didCallFunctionImpl):
(WebCore::InspectorInstrumentation::didEvaluateScriptImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::didCallFunction):
(WebCore::InspectorInstrumentation::didEvaluateScript):

  • inspector/InspectorTimelineAgent.cpp:

(WebCore::InspectorTimelineAgent::willCallFunction):
(WebCore::InspectorTimelineAgent::didCallFunction):
(WebCore::InspectorTimelineAgent::willEvaluateScript):
(WebCore::InspectorTimelineAgent::didEvaluateScript):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):

  • inspector/InspectorTimelineAgent.h:
  • inspector/TimelineRecordFactory.cpp:

(WebCore::TimelineRecordFactory::appendProfile):

  • inspector/TimelineRecordFactory.h:
  • inspector/WorkerInspectorController.cpp:

(WebCore::WorkerInspectorController::didCallInjectedScriptFunction):

  • inspector/WorkerInspectorController.h:
Location:
trunk/Source
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r163119 r163139  
     12014-01-26  Timothy Hatcher  <timothy@apple.com>
     2
     3        Include profile with FunctionCall and EvaluateScript Timeline records.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=127663
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * inspector/InjectedScriptBase.cpp:
     10        (Inspector::InjectedScriptBase::callFunctionWithEvalEnabled):
     11        * inspector/InspectorEnvironment.h:
     12        * inspector/JSGlobalObjectInspectorController.h:
     13
    1142014-01-29  Filip Pizlo  <fpizlo@apple.com>
    215
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp

    r161563 r163139  
    9595
    9696    if (m_environment)
    97         m_environment->didCallInjectedScriptFunction();
     97        m_environment->didCallInjectedScriptFunction(m_injectedScriptObject.scriptState());
    9898
    9999    return resultValue;
  • trunk/Source/JavaScriptCore/inspector/InspectorEnvironment.h

    r161563 r163139  
    4646    virtual InspectorEvaluateHandler evaluateHandler() const = 0;
    4747    virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String& scriptName, int scriptLine) = 0;
    48     virtual void didCallInjectedScriptFunction() = 0;
     48    virtual void didCallInjectedScriptFunction(JSC::ExecState*) = 0;
    4949};
    5050
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h

    r162676 r163139  
    6262    virtual InspectorEvaluateHandler evaluateHandler() const override;
    6363    virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String&, int) override { }
    64     virtual void didCallInjectedScriptFunction() override { }
     64    virtual void didCallInjectedScriptFunction(JSC::ExecState*) override { }
    6565
    6666private:
  • trunk/Source/WebCore/ChangeLog

    r163135 r163139  
     12014-01-26  Timothy Hatcher  <timothy@apple.com>
     2
     3        Include profile with FunctionCall and EvaluateScript Timeline records.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=127663
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * bindings/js/JSCallbackData.cpp:
     10        (WebCore::JSCallbackData::invokeCallback):
     11        * bindings/js/JSEventListener.cpp:
     12        (WebCore::JSEventListener::handleEvent):
     13        * bindings/js/JSMutationCallback.cpp:
     14        (WebCore::JSMutationCallback::call):
     15        * bindings/js/ScheduledAction.cpp:
     16        (WebCore::ScheduledAction::executeFunctionInContext):
     17        * bindings/js/ScriptController.cpp:
     18        (WebCore::ScriptController::evaluateInWorld):
     19        * inspector/InspectorController.cpp:
     20        (WebCore::InspectorController::didCallInjectedScriptFunction):
     21        * inspector/InspectorController.h:
     22        * inspector/InspectorInstrumentation.cpp:
     23        (WebCore::InspectorInstrumentation::didCallFunctionImpl):
     24        (WebCore::InspectorInstrumentation::didEvaluateScriptImpl):
     25        * inspector/InspectorInstrumentation.h:
     26        (WebCore::InspectorInstrumentation::didCallFunction):
     27        (WebCore::InspectorInstrumentation::didEvaluateScript):
     28        * inspector/InspectorTimelineAgent.cpp:
     29        (WebCore::InspectorTimelineAgent::willCallFunction):
     30        (WebCore::InspectorTimelineAgent::didCallFunction):
     31        (WebCore::InspectorTimelineAgent::willEvaluateScript):
     32        (WebCore::InspectorTimelineAgent::didEvaluateScript):
     33        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
     34        * inspector/InspectorTimelineAgent.h:
     35        * inspector/TimelineRecordFactory.cpp:
     36        (WebCore::TimelineRecordFactory::appendProfile):
     37        * inspector/TimelineRecordFactory.h:
     38        * inspector/WorkerInspectorController.cpp:
     39        (WebCore::WorkerInspectorController::didCallInjectedScriptFunction):
     40        * inspector/WorkerInspectorController.h:
     41
    1422014-01-30  Joseph Pecoraro  <pecoraro@apple.com>
    243
  • trunk/Source/WebCore/bindings/js/JSCallbackData.cpp

    r155217 r163139  
    7878        : JSC::call(exec, function, callType, callData, thisValue, args);
    7979
    80     InspectorInstrumentation::didCallFunction(cookie);
     80    InspectorInstrumentation::didCallFunction(cookie, context);
    8181
    8282    if (exec->hadException()) {
  • trunk/Source/WebCore/bindings/js/JSEventListener.cpp

    r159679 r163139  
    134134            : JSC::call(exec, handleEventFunction, callType, callData, thisValue, args);
    135135
    136         InspectorInstrumentation::didCallFunction(cookie);
     136        InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
    137137
    138138        globalObject->setCurrentEvent(savedEvent);
  • trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp

    r157653 r163139  
    9090    JSMainThreadExecState::call(exec, callback, callType, callData, jsObserver, args);
    9191
    92     InspectorInstrumentation::didCallFunction(cookie);
     92    InspectorInstrumentation::didCallFunction(cookie, context);
    9393
    9494    if (exec->hadException())
  • trunk/Source/WebCore/bindings/js/ScheduledAction.cpp

    r160457 r163139  
    107107        JSC::call(exec, m_function.get(), callType, callData, thisValue, args);
    108108
    109     InspectorInstrumentation::didCallFunction(cookie);
     109    InspectorInstrumentation::didCallFunction(cookie, context);
    110110
    111111    if (exec->hadException())
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r163135 r163139  
    147147    JSValue returnValue = JSMainThreadExecState::evaluate(exec, jsSourceCode, shell, &evaluationException);
    148148
    149     InspectorInstrumentation::didEvaluateScript(cookie);
     149    InspectorInstrumentation::didEvaluateScript(cookie, &m_frame);
    150150
    151151    if (evaluationException) {
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r163079 r163139  
    470470}
    471471
    472 void InspectorController::didCallInjectedScriptFunction()
     472void InspectorController::didCallInjectedScriptFunction(JSC::ExecState* scriptState)
    473473{
    474474    ASSERT(!m_injectedScriptInstrumentationCookies.isEmpty());
     475    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(scriptState);
    475476    InspectorInstrumentationCookie cookie = m_injectedScriptInstrumentationCookies.takeLast();
    476     InspectorInstrumentation::didCallFunction(cookie);
     477    InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
    477478}
    478479
  • trunk/Source/WebCore/inspector/InspectorController.h

    r163024 r163139  
    140140    virtual Inspector::InspectorEvaluateHandler evaluateHandler() const override;
    141141    virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String& scriptName, int scriptLine) override;
    142     virtual void didCallInjectedScriptFunction() override;
     142    virtual void didCallInjectedScriptFunction(JSC::ExecState*) override;
    143143
    144144private:
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r163079 r163139  
    317317}
    318318
    319 void InspectorInstrumentation::didCallFunctionImpl(const InspectorInstrumentationCookie& cookie)
     319void InspectorInstrumentation::didCallFunctionImpl(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
    320320{
    321321    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    322         timelineAgent->didCallFunction();
     322        timelineAgent->didCallFunction(frameForScriptExecutionContext(context));
    323323}
    324324
     
    395395}
    396396
    397 void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentationCookie& cookie)
     397void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentationCookie& cookie, Frame* frame)
    398398{
    399399    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    400         timelineAgent->didEvaluateScript();
     400        timelineAgent->didEvaluateScript(frame);
    401401}
    402402
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r163079 r163139  
    130130
    131131    static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
    132     static void didCallFunction(const InspectorInstrumentationCookie&);
     132    static void didCallFunction(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
    133133    static InspectorInstrumentationCookie willDispatchXHRReadyStateChangeEvent(ScriptExecutionContext*, XMLHttpRequest*);
    134134    static void didDispatchXHRReadyStateChangeEvent(const InspectorInstrumentationCookie&);
     
    140140    static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
    141141    static InspectorInstrumentationCookie willEvaluateScript(Frame*, const String& url, int lineNumber);
    142     static void didEvaluateScript(const InspectorInstrumentationCookie&);
     142    static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame*);
    143143    static void scriptsEnabled(Page*, bool isEnabled);
    144144    static void didCreateIsolatedContext(Frame*, JSC::ExecState*, SecurityOrigin*);
     
    314314
    315315    static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents*, const String& scriptName, int scriptLine, ScriptExecutionContext*);
    316     static void didCallFunctionImpl(const InspectorInstrumentationCookie&);
     316    static void didCallFunctionImpl(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
    317317    static InspectorInstrumentationCookie willDispatchXHRReadyStateChangeEventImpl(InstrumentingAgents*, XMLHttpRequest*, ScriptExecutionContext*);
    318318    static void didDispatchXHRReadyStateChangeEventImpl(const InspectorInstrumentationCookie&);
     
    324324    static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
    325325    static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents*, const String& url, int lineNumber, Frame*);
    326     static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&);
     326    static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame*);
    327327    static void scriptsEnabledImpl(InstrumentingAgents*, bool isEnabled);
    328328    static void didCreateIsolatedContextImpl(InstrumentingAgents*, Frame*, JSC::ExecState*, SecurityOrigin*);
     
    824824
    825825
    826 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie)
     826inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
    827827{
    828828#if ENABLE(INSPECTOR)
    829829    FAST_RETURN_IF_NO_FRONTENDS(void());
    830830    if (cookie.isValid())
    831         didCallFunctionImpl(cookie);
     831        didCallFunctionImpl(cookie, context);
    832832#else
    833833    UNUSED_PARAM(cookie);
     834    UNUSED_PARAM(context);
    834835#endif
    835836}
     
    947948}
    948949
    949 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie)
     950inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie, Frame* frame)
    950951{
    951952#if ENABLE(INSPECTOR)
    952953    FAST_RETURN_IF_NO_FRONTENDS(void());
    953954    if (cookie.isValid())
    954         didEvaluateScriptImpl(cookie);
     955        didEvaluateScriptImpl(cookie, frame);
    955956#else
    956957    UNUSED_PARAM(cookie);
     958    UNUSED_PARAM(frame);
    957959#endif
    958960}
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r162676 r163139  
    5252#include "ResourceRequest.h"
    5353#include "ResourceResponse.h"
     54#include "ScriptProfiler.h"
    5455#include "TimelineRecordFactory.h"
    5556#include <wtf/CurrentTime.h>
     
    138139{
    139140    pushCurrentRecord(TimelineRecordFactory::createFunctionCallData(scriptName, scriptLine), TimelineRecordType::FunctionCall, true, frame);
    140 }
    141 
    142 void InspectorTimelineAgent::didCallFunction()
    143 {
     141
     142    if (frame && !m_recordingProfile) {
     143        m_recordingProfile = true;
     144        ScriptProfiler::start(toJSDOMWindow(frame, debuggerWorld())->globalExec(), ASCIILiteral("Timeline FunctionCall"));
     145    }
     146}
     147
     148void InspectorTimelineAgent::didCallFunction(Frame* frame)
     149{
     150    if (frame && m_recordingProfile) {
     151        if (m_recordStack.isEmpty())
     152            return;
     153
     154        TimelineRecordEntry& entry = m_recordStack.last();
     155        ASSERT(entry.type == TimelineRecordType::FunctionCall);
     156
     157        RefPtr<ScriptProfile> profile = ScriptProfiler::stop(toJSDOMWindow(frame, debuggerWorld())->globalExec(), ASCIILiteral("Timeline FunctionCall"));
     158        TimelineRecordFactory::appendProfile(entry.data.get(), profile.release());
     159
     160        m_recordingProfile = false;
     161    }
     162
    144163    didCompleteCurrentRecord(TimelineRecordType::FunctionCall);
    145164}
     
    300319{
    301320    pushCurrentRecord(TimelineRecordFactory::createEvaluateScriptData(url, lineNumber), TimelineRecordType::EvaluateScript, true, frame);
    302 }
    303 
    304 void InspectorTimelineAgent::didEvaluateScript()
    305 {
     321
     322    if (frame && !m_recordingProfile) {
     323        m_recordingProfile = true;
     324        ScriptProfiler::start(toJSDOMWindow(frame, debuggerWorld())->globalExec(), ASCIILiteral("Timeline EvaluateScript"));
     325    }
     326}
     327
     328void InspectorTimelineAgent::didEvaluateScript(Frame* frame)
     329{
     330    if (frame && m_recordingProfile) {
     331        if (m_recordStack.isEmpty())
     332            return;
     333
     334        TimelineRecordEntry& entry = m_recordStack.last();
     335        ASSERT(entry.type == TimelineRecordType::EvaluateScript);
     336
     337        RefPtr<ScriptProfile> profile = ScriptProfiler::stop(toJSDOMWindow(frame, debuggerWorld())->globalExec(), ASCIILiteral("Timeline EvaluateScript"));
     338        TimelineRecordFactory::appendProfile(entry.data.get(), profile.release());
     339
     340        m_recordingProfile = false;
     341    }
     342
    306343    didCompleteCurrentRecord(TimelineRecordType::EvaluateScript);
    307344}
     
    593630    , m_enabled(false)
    594631    , m_includeDOMCounters(false)
     632    , m_recordingProfile(false)
    595633{
    596634}
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.h

    r162676 r163139  
    146146    // Methods called from WebCore.
    147147    void willCallFunction(const String& scriptName, int scriptLine, Frame*);
    148     void didCallFunction();
     148    void didCallFunction(Frame*);
    149149
    150150    void willDispatchEvent(const Event&, Frame*);
     
    185185
    186186    void willEvaluateScript(const String&, int, Frame*);
    187     void didEvaluateScript();
     187    void didEvaluateScript(Frame*);
    188188
    189189    void didTimeStamp(Frame*, const String&);
     
    269269    bool m_enabled;
    270270    bool m_includeDOMCounters;
     271    bool m_recordingProfile;
    271272};
    272273
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp

    r160457 r163139  
    4343#include "ScriptCallStack.h"
    4444#include "ScriptCallStackFactory.h"
     45#include "ScriptProfile.h"
    4546#include <inspector/InspectorValues.h>
    4647#include <wtf/CurrentTime.h>
     
    252253}
    253254
     255void TimelineRecordFactory::appendProfile(InspectorObject* data, PassRefPtr<ScriptProfile> profile)
     256{
     257    data->setValue("profile", profile->buildInspectorObjectForHead());
     258}
     259
    254260} // namespace WebCore
    255261
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.h

    r160457 r163139  
    4343    class ResourceRequest;
    4444    class ResourceResponse;
     45    class ScriptProfile;
    4546
    4647    class TimelineRecordFactory {
     
    9394        static void appendLayoutRoot(Inspector::InspectorObject* data, const FloatQuad&);
    9495
     96        static void appendProfile(Inspector::InspectorObject*, PassRefPtr<ScriptProfile>);
     97
    9598#if ENABLE(WEB_SOCKETS)
    9699        static inline PassRefPtr<Inspector::InspectorObject> createWebSocketCreateData(unsigned long identifier, const URL& url, const String& protocol)
  • trunk/Source/WebCore/inspector/WorkerInspectorController.cpp

    r163024 r163139  
    167167}
    168168
    169 void WorkerInspectorController::didCallInjectedScriptFunction()
     169void WorkerInspectorController::didCallInjectedScriptFunction(JSC::ExecState* scriptState)
    170170{
    171171    ASSERT(!m_injectedScriptInstrumentationCookies.isEmpty());
     172    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(scriptState);
    172173    InspectorInstrumentationCookie cookie = m_injectedScriptInstrumentationCookies.takeLast();
    173     InspectorInstrumentation::didCallFunction(cookie);
     174    InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
    174175}
    175176
  • trunk/Source/WebCore/inspector/WorkerInspectorController.h

    r163024 r163139  
    7373    virtual Inspector::InspectorEvaluateHandler evaluateHandler() const override;
    7474    virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String& scriptName, int scriptLine) override;
    75     virtual void didCallInjectedScriptFunction() override;
     75    virtual void didCallInjectedScriptFunction(JSC::ExecState*) override;
    7676
    7777private:
Note: See TracChangeset for help on using the changeset viewer.