Changeset 171195 in webkit


Ignore:
Timestamp:
Jul 17, 2014 2:16:46 PM (10 years ago)
Author:
timothy@apple.com
Message:

Make console.profile record to the Timeline.

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

Reviewed by Joseph Pecoraro.

Source/WebCore:
Passes existing profiler tests in fast/profiler.

  • bindings/js/ScriptState.cpp:

(WebCore::domWindowFromExecState):
(WebCore::frameFromExecState):
(WebCore::scriptExecutionContextFromExecState):
(WebCore::mainWorldExecState):
(WebCore::execStateFromNode):

  • bindings/js/ScriptState.h:
  • inspector/InspectorController.cpp:

(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::profilerEnabled):
(WebCore::InspectorController::setProfilerEnabled):

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

(WebCore::InspectorInstrumentation::startProfilingImpl):
(WebCore::InspectorInstrumentation::stopProfilingImpl):

  • inspector/InspectorTimelineAgent.cpp:

(WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
(WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::stop):
(WebCore::startProfiling):
(WebCore::stopProfiling):
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::stopFromConsole):
(WebCore::InspectorTimelineAgent::didWriteHTML):
(WebCore::InspectorTimelineAgent::breakpointActionProbe):
(WebCore::toProtocol):
(WebCore::InspectorTimelineAgent::addRecordToTimeline):
(WebCore::InspectorTimelineAgent::didCompleteRecordEntry):
(WebCore::InspectorTimelineAgent::didCompleteCurrentRecord):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::sendEvent):
(WebCore::InspectorTimelineAgent::createRecordEntry):
(WebCore::InspectorTimelineAgent::pushCurrentRecord):

  • inspector/InspectorTimelineAgent.h:

(WebCore::InspectorTimelineAgent::TimelineRecordEntry::TimelineRecordEntry):
(WebCore::InspectorTimelineAgent::pushCurrentRecord):

  • inspector/InstrumentingAgents.cpp:

(WebCore::InstrumentingAgents::InstrumentingAgents):
(WebCore::InstrumentingAgents::reset):

  • inspector/InstrumentingAgents.h:

(WebCore::InstrumentingAgents::persistentInspectorTimelineAgent):
(WebCore::InstrumentingAgents::setPersistentInspectorTimelineAgent):

  • inspector/TimelineRecordFactory.cpp:

(WebCore::TimelineRecordFactory::createConsoleProfileData):

  • inspector/TimelineRecordFactory.h:
  • inspector/protocol/Timeline.json:
  • page/PageConsole.cpp:

(WebCore::PageConsole::profileEnd):

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Controllers/TimelineManager.js:

(WebInspector.TimelineManager.prototype.startCapturing):
(WebInspector.TimelineManager.prototype.stopCapturing):
(WebInspector.TimelineManager.prototype.capturingStarted):
(WebInspector.TimelineManager.prototype.capturingStopped):
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
(WebInspector.TimelineManager.prototype.eventRecorded):

  • UserInterface/Images/TimelineRecordConsoleProfile.svg: Added.
  • UserInterface/Models/ScriptTimelineRecord.js:
  • UserInterface/Protocol/TimelineObserver.js:

(WebInspector.TimelineObserver.prototype.eventRecorded):
(WebInspector.TimelineObserver.prototype.recordingStarted):
(WebInspector.TimelineObserver.prototype.recordingStopped):

  • UserInterface/Views/TimelineIcons.css:

(.console-profile-record .icon):

  • UserInterface/Views/TimelineRecordTreeElement.js:

(WebInspector.TimelineRecordTreeElement):

Source/WebKit/mac:

  • WebInspector/WebInspector.mm:

(-isProfilingJavaScript):
(-toggleProfilingJavaScript:):
(-startProfilingJavaScript:):
(-stopProfilingJavaScript:):
(-isJavaScriptProfilingEnabled):
(-setJavaScriptProfilingEnabled:):

Source/WebKit2:

  • WebProcess/WebPage/WebInspector.cpp:

(WebKit::WebInspector::setJavaScriptProfilingEnabled):
(WebKit::WebInspector::startJavaScriptProfiling):
(WebKit::WebInspector::stopJavaScriptProfiling):

LayoutTests:

  • fast/profiler/profile-with-no-title-expected.txt:
  • inspector-protocol/profiler/console-profile-expected.txt: Removed.
  • inspector-protocol/profiler/console-profile.html: Removed.
  • inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt: Removed.
  • inspector-protocol/profiler/console-profileEnd-parameterless.html: Removed.

Removed because console.profile does not go through the profiler protocol now.

Location:
trunk
Files:
1 added
1 deleted
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r171192 r171195  
     12014-07-17  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make console.profile record to the Timeline.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=134643
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * fast/profiler/profile-with-no-title-expected.txt:
     10
     11        * inspector-protocol/profiler/console-profile-expected.txt: Removed.
     12        * inspector-protocol/profiler/console-profile.html: Removed.
     13        * inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt: Removed.
     14        * inspector-protocol/profiler/console-profileEnd-parameterless.html: Removed.
     15        Removed because console.profile does not go through the profiler protocol now.
     16
    1172014-07-16  Roger Fong  <roger_fong@apple.com>
    218
  • trunk/LayoutTests/fast/profiler/profile-with-no-title-expected.txt

    r163140 r171195  
    33To run this test manually, load it in the browser then load the WebInspector and look at the profile. If there is a profile that is sufficient for this test.
    44
    5 Profile title: org.webkit.profiles.user-initiated.1
     5Profile title:
    66Thread_1 (no file) (line 0:0)
    77   startTest profile-with-no-title.html (line 11:1)
  • trunk/Source/WebCore/ChangeLog

    r171188 r171195  
     12014-07-17  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make console.profile record to the Timeline.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=134643
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Passes existing profiler tests in fast/profiler.
     10
     11        * bindings/js/ScriptState.cpp:
     12        (WebCore::domWindowFromExecState):
     13        (WebCore::frameFromExecState):
     14        (WebCore::scriptExecutionContextFromExecState):
     15        (WebCore::mainWorldExecState):
     16        (WebCore::execStateFromNode):
     17        * bindings/js/ScriptState.h:
     18        * inspector/InspectorController.cpp:
     19        (WebCore::InspectorController::InspectorController):
     20        (WebCore::InspectorController::profilerEnabled):
     21        (WebCore::InspectorController::setProfilerEnabled):
     22        * inspector/InspectorController.h:
     23        * inspector/InspectorInstrumentation.cpp:
     24        (WebCore::InspectorInstrumentation::startProfilingImpl):
     25        (WebCore::InspectorInstrumentation::stopProfilingImpl):
     26        * inspector/InspectorTimelineAgent.cpp:
     27        (WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
     28        (WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
     29        (WebCore::InspectorTimelineAgent::start):
     30        (WebCore::InspectorTimelineAgent::stop):
     31        (WebCore::startProfiling):
     32        (WebCore::stopProfiling):
     33        (WebCore::InspectorTimelineAgent::startFromConsole):
     34        (WebCore::InspectorTimelineAgent::stopFromConsole):
     35        (WebCore::InspectorTimelineAgent::didWriteHTML):
     36        (WebCore::InspectorTimelineAgent::breakpointActionProbe):
     37        (WebCore::toProtocol):
     38        (WebCore::InspectorTimelineAgent::addRecordToTimeline):
     39        (WebCore::InspectorTimelineAgent::didCompleteRecordEntry):
     40        (WebCore::InspectorTimelineAgent::didCompleteCurrentRecord):
     41        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
     42        (WebCore::InspectorTimelineAgent::sendEvent):
     43        (WebCore::InspectorTimelineAgent::createRecordEntry):
     44        (WebCore::InspectorTimelineAgent::pushCurrentRecord):
     45        * inspector/InspectorTimelineAgent.h:
     46        (WebCore::InspectorTimelineAgent::TimelineRecordEntry::TimelineRecordEntry):
     47        (WebCore::InspectorTimelineAgent::pushCurrentRecord):
     48        * inspector/InstrumentingAgents.cpp:
     49        (WebCore::InstrumentingAgents::InstrumentingAgents):
     50        (WebCore::InstrumentingAgents::reset):
     51        * inspector/InstrumentingAgents.h:
     52        (WebCore::InstrumentingAgents::persistentInspectorTimelineAgent):
     53        (WebCore::InstrumentingAgents::setPersistentInspectorTimelineAgent):
     54        * inspector/TimelineRecordFactory.cpp:
     55        (WebCore::TimelineRecordFactory::createConsoleProfileData):
     56        * inspector/TimelineRecordFactory.h:
     57        * inspector/protocol/Timeline.json:
     58        * page/PageConsole.cpp:
     59        (WebCore::PageConsole::profileEnd):
     60
    1612014-07-16  Sam Weinig  <sam@webkit.org>
    262
  • trunk/Source/WebCore/bindings/js/ScriptState.cpp

    r159679 r171195  
    5252    JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
    5353    if (!globalObject->inherits(JSDOMWindowBase::info()))
    54         return 0;
     54        return nullptr;
    5555    return &JSC::jsCast<JSDOMWindowBase*>(globalObject)->impl();
     56}
     57
     58Frame* frameFromExecState(JSC::ExecState* scriptState)
     59{
     60    ScriptExecutionContext* context = scriptExecutionContextFromExecState(scriptState);
     61    Document* document = context && context->isDocument() ? toDocument(context) : nullptr;
     62    return document ? document->frame() : nullptr;
    5663}
    5764
     
    6067    JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
    6168    if (!globalObject->inherits(JSDOMGlobalObject::info()))
    62         return 0;
     69        return nullptr;
    6370    return JSC::jsCast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext();
    6471}
     
    6774{
    6875    if (!frame)
    69         return 0;
     76        return nullptr;
    7077    JSDOMWindowShell* shell = frame->script().windowShell(mainThreadNormalWorld());
    7178    return shell->window()->globalExec();
     
    7582{
    7683    if (!node)
    77         return 0;
     84        return nullptr;
    7885    Frame* frame = node->document().frame();
    7986    if (!frame)
    80         return 0;
     87        return nullptr;
    8188    if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
    82         return 0;
     89        return nullptr;
    8390    return frame->script().globalObject(world)->globalExec();
    8491}
  • trunk/Source/WebCore/bindings/js/ScriptState.h

    r160457 r171195  
    5353
    5454DOMWindow* domWindowFromExecState(JSC::ExecState*);
     55Frame* frameFromExecState(JSC::ExecState*);
    5556ScriptExecutionContext* scriptExecutionContextFromExecState(JSC::ExecState*);
    5657
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r170774 r171195  
    135135
    136136    auto timelineAgentPtr = std::make_unique<InspectorTimelineAgent>(m_instrumentingAgents.get(), pageAgent, InspectorTimelineAgent::PageInspector, inspectorClient);
    137     InspectorTimelineAgent* timelineAgent = timelineAgentPtr.get();
     137    m_timelineAgent = timelineAgentPtr.get();
    138138    m_agents.append(WTF::move(timelineAgentPtr));
    139139
     
    176176
    177177    runtimeAgent->setScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
    178     timelineAgent->setPageScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
     178    m_timelineAgent->setPageScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
    179179    m_profilerAgent->setScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
    180180}
     
    381381bool InspectorController::profilerEnabled() const
    382382{
    383     return m_profilerAgent->enabled();
     383    return m_instrumentingAgents->inspectorTimelineAgent();
    384384}
    385385
    386386void InspectorController::setProfilerEnabled(bool enable)
    387387{
    388     ErrorString error;
    389     if (enable)
    390         m_profilerAgent->enable(&error);
    391     else
    392         m_profilerAgent->disable(&error);
     388    if (enable) {
     389        m_instrumentingAgents->setPersistentInspectorTimelineAgent(m_timelineAgent);
     390        m_timelineAgent->start();
     391    } else {
     392        m_instrumentingAgents->setPersistentInspectorTimelineAgent(nullptr);
     393        m_timelineAgent->stop();
     394    }
    393395}
    394396
  • trunk/Source/WebCore/inspector/InspectorController.h

    r170406 r171195  
    6363class InspectorPageAgent;
    6464class InspectorResourceAgent;
     65class InspectorTimelineAgent;
    6566class InstrumentingAgents;
    6667class Node;
     
    145146    InspectorDOMDebuggerAgent* m_domDebuggerAgent;
    146147    Inspector::InspectorProfilerAgent* m_profilerAgent;
     148    InspectorTimelineAgent* m_timelineAgent;
    147149
    148150    RefPtr<Inspector::InspectorBackendDispatcher> m_inspectorBackendDispatcher;
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r168306 r171195  
    946946void InspectorInstrumentation::startProfilingImpl(InstrumentingAgents* instrumentingAgents, JSC::ExecState* exec, const String& title)
    947947{
    948     if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
    949         profilerAgent->startProfiling(title, exec);
     948    if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->persistentInspectorTimelineAgent())
     949        timelineAgent->startFromConsole(exec, title);
    950950}
    951951
    952952PassRefPtr<JSC::Profile> InspectorInstrumentation::stopProfilingImpl(InstrumentingAgents* instrumentingAgents, JSC::ExecState* exec, const String& title)
    953953{
    954     if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent())
    955         return profilerAgent->stopProfiling(title, exec);
     954    if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->persistentInspectorTimelineAgent())
     955        return timelineAgent->stopFromConsole(exec, title);
    956956    return nullptr;
    957957}
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r167530 r171195  
    7575    m_frontendDispatcher = std::make_unique<InspectorTimelineFrontendDispatcher>(frontendChannel);
    7676    m_backendDispatcher = InspectorTimelineBackendDispatcher::create(backendDispatcher, this);
     77
     78    m_instrumentingAgents->setPersistentInspectorTimelineAgent(this);
    7779}
    7880
     
    8284    m_backendDispatcher.clear();
    8385
     86    m_instrumentingAgents->setPersistentInspectorTimelineAgent(nullptr);
     87
    8488    ErrorString error;
    8589    stop(&error);
     
    8892void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth)
    8993{
    90     if (!m_frontendDispatcher)
    91         return;
    92 
    9394    if (maxCallStackDepth && *maxCallStackDepth > 0)
    9495        m_maxCallStackDepth = *maxCallStackDepth;
     
    104105
    105106    m_enabled = true;
     107
     108    if (m_frontendDispatcher)
     109        m_frontendDispatcher->recordingStarted();
    106110}
    107111
     
    111115        return;
    112116
    113     m_weakFactory.revokeAll();
    114117    m_instrumentingAgents->setInspectorTimelineAgent(nullptr);
    115118
     
    120123
    121124    m_enabled = false;
     125
     126    if (m_frontendDispatcher)
     127        m_frontendDispatcher->recordingStopped();
    122128}
    123129
     
    130136}
    131137
     138static inline void startProfiling(JSC::ExecState* exec, const String& title)
     139{
     140    JSC::LegacyProfiler::profiler()->startProfiling(exec, title);
     141}
     142
     143static inline PassRefPtr<JSC::Profile> stopProfiling(JSC::ExecState* exec, const String& title)
     144{
     145    return JSC::LegacyProfiler::profiler()->stopProfiling(exec, title);
     146}
     147
    132148static inline void startProfiling(Frame* frame, const String& title)
    133149{
    134     JSC::LegacyProfiler::profiler()->startProfiling(toJSDOMWindow(frame, debuggerWorld())->globalExec(), title);
     150    startProfiling(toJSDOMWindow(frame, debuggerWorld())->globalExec(), title);
    135151}
    136152
    137153static inline PassRefPtr<JSC::Profile> stopProfiling(Frame* frame, const String& title)
    138154{
    139     return JSC::LegacyProfiler::profiler()->stopProfiling(toJSDOMWindow(frame, debuggerWorld())->globalExec(), title);
     155    return stopProfiling(toJSDOMWindow(frame, debuggerWorld())->globalExec(), title);
     156}
     157
     158void InspectorTimelineAgent::startFromConsole(JSC::ExecState* exec, const String &title)
     159{
     160    // Only allow recording of a profile if it is anonymous (empty title) or does not match
     161    // the title of an already recording profile.
     162    if (!title.isEmpty()) {
     163        for (const TimelineRecordEntry& record : m_pendingConsoleProfileRecords) {
     164            String recordTitle;
     165            record.data->getString(ASCIILiteral("title"), &recordTitle);
     166            if (recordTitle == title)
     167                return;
     168        }
     169    }
     170
     171    if (m_pendingConsoleProfileRecords.isEmpty())
     172        start();
     173
     174    startProfiling(exec, title);
     175
     176    m_pendingConsoleProfileRecords.append(createRecordEntry(TimelineRecordFactory::createConsoleProfileData(title), TimelineRecordType::ConsoleProfile, true, frameFromExecState(exec)));
     177}
     178
     179PassRefPtr<JSC::Profile> InspectorTimelineAgent::stopFromConsole(JSC::ExecState* exec, const String& title)
     180{
     181    // Stop profiles in reverse order. If the title is empty, then stop the last profile.
     182    // Otherwise, match the title of the profile to stop.
     183    for (ptrdiff_t i = m_pendingConsoleProfileRecords.size() - 1; i >= 0; --i) {
     184        const TimelineRecordEntry& record = m_pendingConsoleProfileRecords[i];
     185
     186        String recordTitle;
     187        record.data->getString(ASCIILiteral("title"), &recordTitle);
     188
     189        if (title.isEmpty() || recordTitle == title) {
     190            RefPtr<JSC::Profile> profile = stopProfiling(exec, title);
     191            if (profile)
     192                TimelineRecordFactory::appendProfile(record.data.get(), profile);
     193
     194            didCompleteRecordEntry(record);
     195
     196            m_pendingConsoleProfileRecords.remove(i);
     197
     198            if (m_pendingConsoleProfileRecords.isEmpty())
     199                stop();
     200
     201            return profile.release();
     202        }
     203    }
     204
     205    return nullptr;
    140206}
    141207
     
    265331{
    266332    if (!m_recordStack.isEmpty()) {
    267         TimelineRecordEntry entry = m_recordStack.last();
     333        const TimelineRecordEntry& entry = m_recordStack.last();
    268334        entry.data->setNumber("endLine", endLine);
    269335        didCompleteCurrentRecord(TimelineRecordType::ParseHTML);
     
    458524    ASSERT(exec);
    459525
    460     ScriptExecutionContext* context = scriptExecutionContextFromExecState(exec);
    461     Document* document = (context && context->isDocument()) ? toDocument(context) : nullptr;
    462     Frame* frame = document ? document->frame() : nullptr;
    463     appendRecord(TimelineRecordFactory::createProbeSampleData(action, hitCount), TimelineRecordType::ProbeSample, false, frame);
     526    appendRecord(TimelineRecordFactory::createProbeSampleData(action, hitCount), TimelineRecordType::ProbeSample, false, frameFromExecState(exec));
    464527}
    465528
     
    529592    case TimelineRecordType::ProbeSample:
    530593        return Inspector::TypeBuilder::Timeline::EventType::ProbeSample;
     594    case TimelineRecordType::ConsoleProfile:
     595        return Inspector::TypeBuilder::Timeline::EventType::ConsoleProfile;
    531596
    532597    case TimelineRecordType::RequestAnimationFrame:
     
    559624        sendEvent(record.release());
    560625    else {
    561         TimelineRecordEntry parent = m_recordStack.last();
     626        const TimelineRecordEntry& parent = m_recordStack.last();
    562627        parent.children->pushObject(record.release());
    563628    }
     
    574639}
    575640
     641void InspectorTimelineAgent::didCompleteRecordEntry(const TimelineRecordEntry& entry)
     642{
     643    entry.record->setObject(ASCIILiteral("data"), entry.data);
     644    entry.record->setArray(ASCIILiteral("children"), entry.children);
     645    entry.record->setNumber(ASCIILiteral("endTime"), timestamp());
     646    addRecordToTimeline(entry.record, entry.type);
     647}
     648
    576649void InspectorTimelineAgent::didCompleteCurrentRecord(TimelineRecordType type)
    577650{
     
    581654        TimelineRecordEntry entry = m_recordStack.last();
    582655        m_recordStack.removeLast();
    583         ASSERT(entry.type == type);
    584         entry.record->setObject("data", entry.data);
    585         entry.record->setArray("children", entry.children);
    586         entry.record->setNumber("endTime", timestamp());
    587         addRecordToTimeline(entry.record, type);
     656        ASSERT_UNUSED(type, entry.type == type);
     657        didCompleteRecordEntry(entry);
    588658    }
    589659}
     
    597667    , m_inspectorType(type)
    598668    , m_client(client)
    599     , m_weakFactory(this)
    600669    , m_enabled(false)
    601670    , m_recordingProfile(false)
     
    613682void InspectorTimelineAgent::sendEvent(PassRefPtr<InspectorObject> event)
    614683{
     684    if (!m_frontendDispatcher)
     685        return;
     686
    615687    // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
    616688    RefPtr<Inspector::TypeBuilder::Timeline::TimelineEvent> recordChecked = Inspector::TypeBuilder::Timeline::TimelineEvent::runtimeCast(event);
     
    618690}
    619691
    620 void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, TimelineRecordType type, bool captureCallStack, Frame* frame)
     692InspectorTimelineAgent::TimelineRecordEntry InspectorTimelineAgent::createRecordEntry(PassRefPtr<InspectorObject> data, TimelineRecordType type, bool captureCallStack, Frame* frame)
    621693{
    622694    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(timestamp(), captureCallStack ? m_maxCallStackDepth : 0);
    623695    setFrameIdentifier(record.get(), frame);
    624     m_recordStack.append(TimelineRecordEntry(record.release(), data, InspectorArray::create(), type));
     696    return TimelineRecordEntry(record.release(), data, InspectorArray::create(), type);
     697}
     698
     699void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, TimelineRecordType type, bool captureCallStack, Frame* frame)
     700{
     701    pushCurrentRecord(createRecordEntry(data, type, captureCallStack, frame));
    625702}
    626703
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.h

    r167811 r171195  
    4444#include <wtf/WeakPtr.h>
    4545
     46namespace JSC {
     47class Profile;
     48}
     49
    4650namespace WebCore {
    4751
     
    98102    FunctionCall,
    99103    ProbeSample,
     104    ConsoleProfile,
    100105
    101106    RequestAnimationFrame,
     
    137142    virtual void willDestroyFrontendAndBackend(Inspector::InspectorDisconnectReason) override;
    138143
    139     virtual void start(ErrorString*, const int* maxCallStackDepth) override;
    140     virtual void stop(ErrorString*) override;
     144    virtual void start(ErrorString* = nullptr, const int* maxCallStackDepth = nullptr) override;
     145    virtual void stop(ErrorString* = nullptr) override;
    141146
    142147    int id() const { return m_id; }
     
    147152
    148153    // Methods called from WebCore.
     154    void startFromConsole(JSC::ExecState*, const String &title);
     155    PassRefPtr<JSC::Profile> stopFromConsole(JSC::ExecState*, const String& title);
     156
    149157    void willCallFunction(const String& scriptName, int scriptLine, Frame*);
    150158    void didCallFunction(Frame*);
     
    225233
    226234    struct TimelineRecordEntry {
     235        TimelineRecordEntry()
     236            : type(TimelineRecordType::EventDispatch) { }
    227237        TimelineRecordEntry(PassRefPtr<Inspector::InspectorObject> record, PassRefPtr<Inspector::InspectorObject> data, PassRefPtr<Inspector::InspectorArray> children, TimelineRecordType type)
    228238            : record(record), data(data), children(children), type(type)
    229239        {
    230240        }
     241
    231242        RefPtr<Inspector::InspectorObject> record;
    232243        RefPtr<Inspector::InspectorObject> data;
     
    238249    void appendRecord(PassRefPtr<Inspector::InspectorObject> data, TimelineRecordType, bool captureCallStack, Frame*);
    239250    void pushCurrentRecord(PassRefPtr<Inspector::InspectorObject>, TimelineRecordType, bool captureCallStack, Frame*);
     251    void pushCurrentRecord(const TimelineRecordEntry& record) { m_recordStack.append(record); }
     252
     253    TimelineRecordEntry createRecordEntry(PassRefPtr<Inspector::InspectorObject> data, TimelineRecordType, bool captureCallStack, Frame*);
    240254
    241255    void setFrameIdentifier(Inspector::InspectorObject* record, Frame*);
    242256
     257    void didCompleteRecordEntry(const TimelineRecordEntry&);
    243258    void didCompleteCurrentRecord(TimelineRecordType);
    244259
     
    265280    InspectorType m_inspectorType;
    266281    InspectorClient* m_client;
    267     WeakPtrFactory<InspectorTimelineAgent> m_weakFactory;
     282
     283    Vector<TimelineRecordEntry> m_pendingConsoleProfileRecords;
    268284
    269285    bool m_enabled;
  • trunk/Source/WebCore/inspector/InstrumentingAgents.cpp

    r164986 r171195  
    5757    , m_workerRuntimeAgent(nullptr)
    5858    , m_inspectorTimelineAgent(nullptr)
     59    , m_persistentInspectorTimelineAgent(nullptr)
    5960    , m_inspectorDOMStorageAgent(nullptr)
    6061#if ENABLE(WEB_REPLAY)
     
    8586    m_workerRuntimeAgent = nullptr;
    8687    m_inspectorTimelineAgent = nullptr;
     88    m_persistentInspectorTimelineAgent = nullptr;
    8789    m_inspectorDOMStorageAgent = nullptr;
    8890#if ENABLE(WEB_REPLAY)
  • trunk/Source/WebCore/inspector/InstrumentingAgents.h

    r167530 r171195  
    106106    void setInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_inspectorTimelineAgent = agent; }
    107107
     108    InspectorTimelineAgent* persistentInspectorTimelineAgent() const { return m_persistentInspectorTimelineAgent; }
     109    void setPersistentInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_persistentInspectorTimelineAgent = agent; }
     110
    108111    InspectorDOMStorageAgent* inspectorDOMStorageAgent() const { return m_inspectorDOMStorageAgent; }
    109112    void setInspectorDOMStorageAgent(InspectorDOMStorageAgent* agent) { m_inspectorDOMStorageAgent = agent; }
     
    155158    WorkerRuntimeAgent* m_workerRuntimeAgent;
    156159    InspectorTimelineAgent* m_inspectorTimelineAgent;
     160    InspectorTimelineAgent* m_persistentInspectorTimelineAgent;
    157161    InspectorDOMStorageAgent* m_inspectorDOMStorageAgent;
    158162#if ENABLE(WEB_REPLAY)
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp

    r167595 r171195  
    9191}
    9292
     93PassRefPtr<InspectorObject> TimelineRecordFactory::createConsoleProfileData(const String& title)
     94{
     95    RefPtr<InspectorObject> data = InspectorObject::create();
     96    data->setString("title", title);
     97    return data.release();
     98}
     99
    93100PassRefPtr<InspectorObject> TimelineRecordFactory::createProbeSampleData(const ScriptBreakpointAction& action, int hitCount)
    94101{
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.h

    r167530 r171195  
    6262
    6363        static PassRefPtr<Inspector::InspectorObject> createFunctionCallData(const String& scriptName, int scriptLine);
     64        static PassRefPtr<Inspector::InspectorObject> createConsoleProfileData(const String& title);
    6465
    6566        static PassRefPtr<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, int hitCount);
  • trunk/Source/WebCore/inspector/protocol/Timeline.json

    r166846 r171195  
    66            "id": "EventType",
    77            "type": "string",
    8             "enum": ["EventDispatch", "ScheduleStyleRecalculation", "RecalculateStyles", "InvalidateLayout", "Layout", "Paint", "ScrollLayer", "ResizeImage", "ParseHTML", "TimerInstall", "TimerRemove", "TimerFire", "EvaluateScript", "MarkLoad", "MarkDOMContent", "TimeStamp", "Time", "TimeEnd", "ScheduleResourceRequest", "ResourceSendRequest", "ResourceReceiveResponse", "ResourceReceivedData", "ResourceFinish", "XHRReadyStateChange", "XHRLoad", "FunctionCall", "ProbeSample", "GCEvent", "RequestAnimationFrame", "CancelAnimationFrame", "FireAnimationFrame", "WebSocketCreate", "WebSocketSendHandshakeRequest", "WebSocketReceiveHandshakeResponse", "WebSocketDestroy"],
     8            "enum": ["EventDispatch", "ScheduleStyleRecalculation", "RecalculateStyles", "InvalidateLayout", "Layout", "Paint", "ScrollLayer", "ResizeImage", "ParseHTML", "TimerInstall", "TimerRemove", "TimerFire", "EvaluateScript", "MarkLoad", "MarkDOMContent", "TimeStamp", "Time", "TimeEnd", "ScheduleResourceRequest", "ResourceSendRequest", "ResourceReceiveResponse", "ResourceReceivedData", "ResourceFinish", "XHRReadyStateChange", "XHRLoad", "FunctionCall", "ProbeSample", "ConsoleProfile", "GCEvent", "RequestAnimationFrame", "CancelAnimationFrame", "FireAnimationFrame", "WebSocketCreate", "WebSocketSendHandshakeRequest", "WebSocketReceiveHandshakeResponse", "WebSocketDestroy"],
    99            "description": "Timeline record type."
    1010        },
     
    4040            ],
    4141            "description": "Fired for every instrumentation event while timeline is started."
     42        },
     43        {
     44            "name": "recordingStarted",
     45            "description": "Fired when recording has started."
     46        },
     47        {
     48            "name": "recordingStopped",
     49            "description": "Fired when recording has stopped."
    4250        }
    4351    ]
  • trunk/Source/WebCore/page/PageConsole.cpp

    r167530 r171195  
    171171void PageConsole::profileEnd(JSC::ExecState* exec, const String& title)
    172172{
    173     RefPtr<JSC::Profile> profile = InspectorInstrumentation::stopProfiling(&m_page, exec, title);
    174     if (profile)
     173    if (RefPtr<JSC::Profile> profile = InspectorInstrumentation::stopProfiling(&m_page, exec, title))
    175174        m_profiles.append(profile.release());
    176175}
  • trunk/Source/WebInspectorUI/ChangeLog

    r171172 r171195  
     12014-07-17  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make console.profile record to the Timeline.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=134643
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * Localizations/en.lproj/localizedStrings.js:
     10        * UserInterface/Controllers/TimelineManager.js:
     11        (WebInspector.TimelineManager.prototype.startCapturing):
     12        (WebInspector.TimelineManager.prototype.stopCapturing):
     13        (WebInspector.TimelineManager.prototype.capturingStarted):
     14        (WebInspector.TimelineManager.prototype.capturingStopped):
     15        (WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
     16        (WebInspector.TimelineManager.prototype.eventRecorded):
     17        * UserInterface/Images/TimelineRecordConsoleProfile.svg: Added.
     18        * UserInterface/Models/ScriptTimelineRecord.js:
     19        * UserInterface/Protocol/TimelineObserver.js:
     20        (WebInspector.TimelineObserver.prototype.eventRecorded):
     21        (WebInspector.TimelineObserver.prototype.recordingStarted):
     22        (WebInspector.TimelineObserver.prototype.recordingStopped):
     23        * UserInterface/Views/TimelineIcons.css:
     24        (.console-profile-record .icon):
     25        * UserInterface/Views/TimelineRecordTreeElement.js:
     26        (WebInspector.TimelineRecordTreeElement):
     27
    1282014-07-16  Saam Barati  <sbarati@apple.com>
    229
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r170138 r171195  
    102102localizedStrings["Conditional expression"] = "Conditional expression";
    103103localizedStrings["Console"] = "Console";
     104localizedStrings["Console Profile Recorded"] = "Console Profile Recorded";
    104105localizedStrings["Console errors, click to show the Console"] = "Console errors, click to show the Console";
    105106localizedStrings["Console logs, click to show the Console"] = "Console logs, click to show the Console";
     
    153154localizedStrings["Element establishes a stacking context"] = "Element establishes a stacking context";
    154155localizedStrings["Element has CSS blending applied and composited descendants"] = "Element has CSS blending applied and composited descendants";
    155 localizedStrings["Element is a stacking context and has composited descendants with CSS blending applied"] = "Element is a stacking context and has composited descendants with CSS blending applied";
    156156localizedStrings["Element has CSS filters applied"] = "Element has CSS filters applied";
    157157localizedStrings["Element has CSS filters applied and composited descendants"] = "Element has CSS filters applied and composited descendants";
     
    172172localizedStrings["Element is <video>"] = "Element is <video>";
    173173localizedStrings["Element is a plug-in"] = "Element is a plug-in";
     174localizedStrings["Element is a stacking context and has composited descendants with CSS blending applied"] = "Element is a stacking context and has composited descendants with CSS blending applied";
    174175localizedStrings["Element is animated"] = "Element is animated";
    175176localizedStrings["Element is masked and composited descendants"] = "Element is masked and composited descendants";
     
    217218localizedStrings["HTTP"] = "HTTP";
    218219localizedStrings["Height"] = "Height";
     220localizedStrings["Hide Replay Controls"] = "Hide Replay Controls";
    219221localizedStrings["Hide compositing borders"] = "Hide compositing borders";
    220222localizedStrings["Hide console (%s)"] = "Hide console (%s)";
    221 localizedStrings["Hide Replay Controls"] = "Hide Replay Controls";
    222223localizedStrings["Hide shadow DOM nodes"] = "Hide shadow DOM nodes";
    223224localizedStrings["Hide the %s details sidebar"] = "Hide the %s details sidebar";
     
    345346localizedStrings["Reflection"] = "Reflection";
    346347localizedStrings["Refresh"] = "Refresh";
     348localizedStrings["Region Flow"] = "Region Flow";
    347349localizedStrings["Region announced in its entirety."] = "Region announced in its entirety.";
    348 localizedStrings["Region Flow"] = "Region Flow";
    349350localizedStrings["Reload page (%s)\nReload ignoring cache (%s)"] = "Reload page (%s)\nReload ignoring cache (%s)";
    350351localizedStrings["Removals"] = "Removals";
     
    388389localizedStrings["Show All"] = "Show All";
    389390localizedStrings["Show All Nodes (%d More)"] = "Show All Nodes (%d More)";
     391localizedStrings["Show Replay Controls"] = "Show Replay Controls";
    390392localizedStrings["Show compositing borders"] = "Show compositing borders";
    391393localizedStrings["Show console (%s)"] = "Show console (%s)";
    392394localizedStrings["Show full-height console"] = "Show full-height console";
    393395localizedStrings["Show function definition"] = "Show function definition";
    394 localizedStrings["Show Replay Controls"] = "Show Replay Controls";
    395396localizedStrings["Show shadow DOM nodes"] = "Show shadow DOM nodes";
    396397localizedStrings["Show split console"] = "Show split console";
     
    408409localizedStrings["Spelling"] = "Spelling";
    409410localizedStrings["Start JavaScript profiling."] = "Start JavaScript profiling.";
     411localizedStrings["Start Playback"] = "Start Playback";
    410412localizedStrings["Start Recording"] = "Start Recording";
    411 localizedStrings["Start Playback"] = "Start Playback";
    412413localizedStrings["Start Time"] = "Start Time";
    413414localizedStrings["Status"] = "Status";
     
    463464localizedStrings["originally %s"] = "originally %s";
    464465localizedStrings["undefined × %d"] = "undefined × %d";
     466localizedStrings["“%s” Profile Recorded"] = "“%s” Profile Recorded";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js

    r169754 r171195  
    6262    startCapturing: function()
    6363    {
     64        TimelineAgent.start();
     65    },
     66
     67    stopCapturing: function()
     68    {
     69        TimelineAgent.stop();
     70    },
     71
     72    capturingStarted: function()
     73    {
    6474        if (this._isCapturing)
    6575            return;
     
    6777        this._isCapturing = true;
    6878
    69         TimelineAgent.start();
    70 
    7179        this.dispatchEventToListeners(WebInspector.TimelineManager.Event.CapturingStarted);
    7280    },
    7381
    74     stopCapturing: function()
     82    capturingStopped: function()
    7583    {
    7684        if (!this._isCapturing)
     
    8694            delete this._deadTimeTimeout;
    8795        }
    88 
    89         TimelineAgent.stop();
    9096
    9197        this._isCapturing = false;
     
    230236                break;
    231237
     238            case TimelineAgent.EventType.ConsoleProfile:
     239                var profile = this._profileFromPayload(recordPayload.data.profile);
     240                console.assert(profile);
     241                this._addRecord(new WebInspector.ScriptTimelineRecord(WebInspector.ScriptTimelineRecord.EventType.ConsoleProfileRecorded, startTime, endTime, callFrames, sourceCodeLocation, recordPayload.data.title, profile));
     242                break;
     243
    232244            case TimelineAgent.EventType.FunctionCall:
    233245                // FunctionCall always happens as a child of another record, and since the FunctionCall record
  • trunk/Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js

    r168678 r171195  
    4747    AnimationFrameFired: "script-timeline-record-animation-frame-fired",
    4848    AnimationFrameRequested: "script-timeline-record-animation-frame-requested",
    49     AnimationFrameCanceled: "script-timeline-record-animation-frame-canceled"
     49    AnimationFrameCanceled: "script-timeline-record-animation-frame-canceled",
     50    ConsoleProfileRecorded: "script-timeline-record-console-profile-recorded"
    5051};
    5152
     
    217218    case WebInspector.ScriptTimelineRecord.EventType.ProbeSampleRecorded:
    218219        return WebInspector.UIString("Probe Sample Recorded");
     220    case WebInspector.ScriptTimelineRecord.EventType.ConsoleProfileRecorded:
     221        if (details && (details instanceof String || typeof details === "string"))
     222            return WebInspector.UIString("“%s” Profile Recorded").format(details);
     223        return WebInspector.UIString("Console Profile Recorded");
    219224    case WebInspector.ScriptTimelineRecord.EventType.TimerFired:
    220225        if (details && includeTimerIdentifierInMainTitle)
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js

    r164543 r171195  
    3737    {
    3838        WebInspector.timelineManager.eventRecorded(record);
     39    },
     40
     41    recordingStarted: function()
     42    {
     43        WebInspector.timelineManager.capturingStarted();
     44    },
     45
     46    recordingStopped: function()
     47    {
     48        WebInspector.timelineManager.capturingStopped();
    3949    }
    4050};
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css

    r167509 r171195  
    8080}
    8181
     82.console-profile-record .icon {
     83    content: url(../Images/TimelineRecordConsoleProfile.svg);
     84}
     85
    8286.timer-record .icon {
    8387    content: url(../Images/TimelineRecordTimer.svg);
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js

    r167509 r171195  
    8181            iconStyleClass = WebInspector.TimelineRecordTreeElement.ProbeRecordIconStyleClass;
    8282            break;
     83        case WebInspector.ScriptTimelineRecord.EventType.ConsoleProfileRecorded:
     84            iconStyleClass = WebInspector.TimelineRecordTreeElement.ConsoleProfileIconStyleClass;
     85            break;
    8386        case WebInspector.ScriptTimelineRecord.EventType.TimerFired:
    8487        case WebInspector.ScriptTimelineRecord.EventType.TimerInstalled:
     
    117120WebInspector.TimelineRecordTreeElement.AnimationRecordIconStyleClass = "animation-record";
    118121WebInspector.TimelineRecordTreeElement.ProbeRecordIconStyleClass = "probe-record";
     122WebInspector.TimelineRecordTreeElement.ConsoleProfileIconStyleClass = "console-profile-record";
    119123
    120124WebInspector.TimelineRecordTreeElement.prototype = {
  • trunk/Source/WebKit/mac/ChangeLog

    r171164 r171195  
     12014-07-17  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make console.profile record to the Timeline.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=134643
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * WebInspector/WebInspector.mm:
     10        (-[WebInspector isProfilingJavaScript]):
     11        (-[WebInspector toggleProfilingJavaScript:]):
     12        (-[WebInspector startProfilingJavaScript:]):
     13        (-[WebInspector stopProfilingJavaScript:]):
     14        (-[WebInspector isJavaScriptProfilingEnabled]):
     15        (-[WebInspector setJavaScriptProfilingEnabled:]):
     16
    1172014-07-16  David Kilzer  <ddkilzer@apple.com>
    218
  • trunk/Source/WebKit/mac/WebInspector/WebInspector.mm

    r170710 r171195  
    110110- (BOOL)isProfilingJavaScript
    111111{
    112     return _frontend && [_frontend isProfilingJavaScript];
     112    // No longer supported.
     113    return NO;
    113114}
    114115
    115116- (void)toggleProfilingJavaScript:(id)sender
    116117{
    117     [self showWindow];
    118 
    119     if ([self isProfilingJavaScript])
    120         [_frontend stopProfilingJavaScript];
    121     else
    122         [_frontend startProfilingJavaScript];
     118    // No longer supported.
    123119}
    124120
    125121- (void)startProfilingJavaScript:(id)sender
    126122{
    127     if (_frontend)
    128         [_frontend startProfilingJavaScript];
     123    // No longer supported.
    129124}
    130125
    131126- (void)stopProfilingJavaScript:(id)sender
    132127{
    133     if (_frontend)
    134         [_frontend stopProfilingJavaScript];
     128    // No longer supported.
    135129}
    136130
    137131- (BOOL)isJavaScriptProfilingEnabled
    138132{
    139     if (Page* page = core(_webView))
    140         return page->inspectorController().profilerEnabled();
     133    // No longer supported.
    141134    return NO;
    142135}
     
    144137- (void)setJavaScriptProfilingEnabled:(BOOL)enabled
    145138{
    146     Page* page = core(_webView);
    147     if (!page)
    148         return;
    149 
    150     page->inspectorController().setProfilerEnabled(enabled);
     139    // No longer supported.
    151140}
    152141
  • trunk/Source/WebKit2/ChangeLog

    r171194 r171195  
     12014-07-17  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make console.profile record to the Timeline.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=134643
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * WebProcess/WebPage/WebInspector.cpp:
     10        (WebKit::WebInspector::setJavaScriptProfilingEnabled):
     11        (WebKit::WebInspector::startJavaScriptProfiling):
     12        (WebKit::WebInspector::stopJavaScriptProfiling):
     13
    1142014-07-17  Brady Eidson  <beidson@apple.com>
    215
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r170774 r171195  
    278278void WebInspector::setJavaScriptProfilingEnabled(bool enabled)
    279279{
    280     m_page->corePage()->inspectorController().show();
    281     if (!m_frontendClient)
    282         return;
    283 
    284     m_page->corePage()->inspectorController().setProfilerEnabled(enabled);
     280    // No longer supported.
    285281}
    286282
    287283void WebInspector::startJavaScriptProfiling()
    288284{
    289     m_page->corePage()->inspectorController().show();
    290     if (m_frontendClient)
    291         m_frontendClient->startProfilingJavaScript();
     285    // No longer supported.
    292286}
    293287
    294288void WebInspector::stopJavaScriptProfiling()
    295289{
    296     m_page->corePage()->inspectorController().show();
    297     if (m_frontendClient)
    298         m_frontendClient->stopProfilingJavaScript();
     290    // No longer supported.
    299291}
    300292
Note: See TracChangeset for help on using the changeset viewer.