Web Inspector: Migrate Page Timeline recording to ScriptProfiler
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2016 23:34:43 +0000 (23:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2016 23:34:43 +0000 (23:34 +0000)
commitb6f20ce024141e6e785b20fecb4d1250d2049736
tree2811bdbc8fb07f3a43badf8fa96160eadf387605
parent7805f71ac10844a32ae1352b4904f069b77d0c97
Web Inspector: Migrate Page Timeline recording to ScriptProfiler
https://bugs.webkit.org/show_bug.cgi?id=152727

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-01-11
Reviewed by Brian Burg.

Source/WebCore:

Test: inspector/script-profiler/event-type-Other.html

This now shares the JavaScript profiling code between JSContext and Page
inspection. It also moves forward splitting the Page's Timeline domain
into smaller components that can be turned on/off individually.

* bindings/js/JSCallbackData.cpp:
(WebCore::JSCallbackData::invokeCallback):
* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::profiledCall):
(WebCore::JSMainThreadExecState::profiledEvaluate):
* bindings/js/JSMutationCallback.cpp:
(WebCore::JSMutationCallback::call):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::executeFunctionInContext):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject evaluateWebScript:]):
Identify entry points into JSC that we want to profile for the frontend.
These were nearly all already classified for the Timeline. We added missing
support for ErrorHandlers (window.onerror handler functions).

* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didCallFunction):
(WebCore::InspectorTimelineAgent::didEvaluateScript):
(WebCore::startProfiling): Deleted.
(WebCore::stopProfiling): Deleted.
(WebCore::InspectorTimelineAgent::willCallFunction): Deleted.
(WebCore::InspectorTimelineAgent::willEvaluateScript): Deleted.
* inspector/InspectorTimelineAgent.h:
TimelineAgent no longer needs to start/stop the Legacy Profiler
since ScriptProfiler will automatically do that for us. Delete
all code associated with that. There is still an open question
regarding `console.profile` and `console.profileEnd` that
starts/stops the profiler.

Source/WebInspectorUI:

* UserInterface/Images/TimelineRecordAPI.svg: Added.
* UserInterface/Images/gtk/TimelineRecordAPI.svg: Added.
New [S] image for API initiated script evaluations.
Display matches the existing [S] Script Evaluated.
Colors match the gray [N] Native image colors.

* UserInterface/Models/ScriptInstrument.js:
(WebInspector.ScriptInstrument.prototype.startInstrumentation):
(WebInspector.ScriptInstrument.prototype.stopInstrumentation):
(WebInspector.ScriptInstrument):
Use ScriptProfiler, if available, in Web debuggables.

* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager):
(WebInspector.TimelineManager.prototype.capturingStarted):
(WebInspector.TimelineManager.prototype._processRecord):
(WebInspector.TimelineManager.prototype._scriptProfilerTypeToScriptTimelineRecordType):
(WebInspector.TimelineManager.prototype.scriptProfilerTrackingUpdated):
(WebInspector.TimelineManager.prototype.scriptProfilerTrackingCompleted):
(WebInspector.TimelineManager.prototype._mergeScriptProfileRecords.let.nextRecord):
(WebInspector.TimelineManager.prototype._mergeScriptProfileRecords.let.recordContainsRecord):
(WebInspector.TimelineManager.prototype._mergeScriptProfileRecords):
When running a timeline on a web debuggable the frontend receives both
Timeline event records and ScriptProfiler events. Timeline (Web) records
are high level web events like "Script Evaluated", "Event Dispatched",
"Timer Fired". The timestamps for these records should always be wrapping
a ScriptProfiler event and its associated profile data. So, at the end
of a recording we merge ScriptProfiler profile data into the original
Timeline (Web) record.

* UserInterface/Models/ScriptTimelineRecord.js:
(WebInspector.ScriptTimelineRecord.prototype.get profilePayload):
(WebInspector.ScriptTimelineRecord.prototype.set profilePayload):
(WebInspector.ScriptTimelineRecord.prototype.setProfilePayload): Deleted.
Replace method with getter/setter.

(WebInspector.ScriptTimelineRecord.EventType.displayName):
Add a new event type for API records, but share display name with Script Evaluated.

* UserInterface/Views/NavigationSidebarPanel.js:
Fix typo.

* UserInterface/Views/ScriptTimelineView.css:
(.timeline-view.script > .data-grid .eventType-column): Deleted.
There is no "eventType" column in the ScriptTimelineView datagrid, so remove styles.

* UserInterface/Views/TimelineIcons.css:
(.api-record .icon):
* UserInterface/Views/TimelineRecordTreeElement.js:
(WebInspector.TimelineRecordTreeElement):
For API Script Evaluation records use the new icon.

LayoutTests:

* inspector/script-profiler/event-type-Other-expected.txt: Added.
* inspector/script-profiler/event-type-Other.html: Added.
Add a test that Web script evaluations create "Other" ScriptProfiler events.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/script-profiler/event-type-Other-expected.txt [new file with mode: 0644]
LayoutTests/inspector/script-profiler/event-type-Other.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCallbackData.cpp
Source/WebCore/bindings/js/JSErrorHandler.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JSMainThreadExecState.h
Source/WebCore/bindings/js/JSMutationCallback.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/objc/WebScriptObject.mm
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Images/TimelineRecordAPI.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Images/gtk/TimelineRecordAPI.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Models/ScriptInstrument.js
Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js
Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.css
Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css
Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js