Web Inspector: Include Garbage Collection Event in Timeline
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Oct 2015 02:15:56 +0000 (02:15 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Oct 2015 02:15:56 +0000 (02:15 +0000)
commit7e4ff27f3514adf488e8c54d973459255e466947
tree691fdd0bbf008e43af0bf44b7c17853eced5085e
parenteb05a5112809607b88aee1a9aa3f71f35f2b7aab
Web Inspector: Include Garbage Collection Event in Timeline
https://bugs.webkit.org/show_bug.cgi?id=142510

Reviewed by Geoffrey Garen and Brian Burg.

Source/JavaScriptCore:

* CMakeLists.txt:
* DerivedSources.make:
* JavaScriptCore.xcodeproj/project.pbxproj:
Include new files in the build.

* heap/HeapObserver.h:
(JSC::HeapObserver::~HeapObserver):
* heap/Heap.cpp:
(JSC::Heap::willStartCollection):
(JSC::Heap::didFinishCollection):
* heap/Heap.h:
(JSC::Heap::addObserver):
(JSC::Heap::removeObserver):
Allow observers on heap to add hooks for starting / ending garbage collection.

* inspector/InspectorEnvironment.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::vm):
* inspector/JSGlobalObjectInspectorController.h:
Access the VM through the InspectorEnvironment as it won't change.

* inspector/agents/InspectorHeapAgent.cpp: Added.
(Inspector::InspectorHeapAgent::InspectorHeapAgent):
(Inspector::InspectorHeapAgent::~InspectorHeapAgent):
(Inspector::InspectorHeapAgent::didCreateFrontendAndBackend):
(Inspector::InspectorHeapAgent::willDestroyFrontendAndBackend):
(Inspector::InspectorHeapAgent::enable):
(Inspector::InspectorHeapAgent::disable):
(Inspector::InspectorHeapAgent::gc):
(Inspector::protocolTypeForHeapOperation):
(Inspector::InspectorHeapAgent::willGarbageCollect):
(Inspector::InspectorHeapAgent::didGarbageCollect):
* inspector/agents/InspectorHeapAgent.h: Added.
* inspector/protocol/Heap.json: Added.
New domain and agent to handle tasks related to the JavaScriptCore heap.

Source/WebCore:

Tests: inspector/heap/garbageCollected.html
       inspector/heap/gc.html

* ForwardingHeaders/heap/HeapObserver.h: Added.
* ForwardingHeaders/inspector/agents/InspectorHeapAgent.h: Added.
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
Forwarding headers.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::vm):
* inspector/InspectorController.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::vm):
* inspector/WorkerInspectorController.h:
Implement InspectorEnvironment::vm and create a Heap agent for the
Page inspector controller.

Source/WebInspectorUI:

* UserInterface/Base/Utilities.js:
(Array.prototype.partition):
Helper to partition an Array into two arrays.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Base/Main.js:
(WebInspector.loaded):
* UserInterface/Test.html:
* UserInterface/Test/Test.js:
(WebInspector.loaded):
* UserInterface/Protocol/HeapObserver.js: Added.
(WebInspector.HeapObserver.prototype.garbageCollected):
(WebInspector.HeapObserver):
Create the new observer and manager.

* UserInterface/Models/GarbageCollection.js: Added.
(WebInspector.GarbageCollection):
(WebInspector.GarbageCollection.fromPayload):
(WebInspector.GarbageCollection.prototype.get type):
(WebInspector.GarbageCollection.prototype.get startTime):
(WebInspector.GarbageCollection.prototype.get endTime):
(WebInspector.GarbageCollection.prototype.get duration):
Model object for Heap.GarbageCollection.

* UserInterface/Controllers/HeapManager.js: Added.
(WebInspector.HeapManager):
(WebInspector.HeapManager.prototype.garbageCollected):
Dispatch events with the GC object.

* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager):
(WebInspector.TimelineManager.prototype._garbageCollected):
Include new GC Timeline Events as Script events.

* UserInterface/Views/ScriptTimelineOverviewGraph.js:
(WebInspector.ScriptTimelineOverviewGraph.prototype.updateLayout):
For the Script overview, make two sets of bars, one for Scripts and one for GCs.
The GCs bar will be overlaid on top of the the Scripts bar. This is particularly
useful since a GC can happen during script execution.

* UserInterface/Images/TimelineRecordGarbageCollection.svg: Added.
* UserInterface/Main.html:
* UserInterface/Models/ScriptTimelineRecord.js:
(WebInspector.ScriptTimelineRecord.prototype.isGarbageCollection):
(WebInspector.ScriptTimelineRecord.EventType.displayName):
* UserInterface/Views/ScriptTimelineDataGridNode.js:
(WebInspector.ScriptTimelineDataGridNode.prototype.get data):
(WebInspector.ScriptTimelineDataGridNode.prototype.createCellContent):
(WebInspector.ScriptTimelineDataGridNode):
* UserInterface/Views/ScriptTimelineView.js:
(WebInspector.ScriptTimelineView.prototype._processPendingRecords):
* UserInterface/Views/SourceCodeTimelineTreeElement.js:
(WebInspector.SourceCodeTimelineTreeElement):
* UserInterface/Views/TimelineIcons.css:
(.garbage-collection-profile-record .icon):
* UserInterface/Views/TimelineRecordBar.css:
(.timeline-record-bar.timeline-record-type-script.script-timeline-record-garbage-collected > .segment):
UI for GC events.

* UserInterface/Views/TimelineRecordBar.js:
(WebInspector.TimelineRecordBar.createCombinedBars):
Simplify by storing start time into a variable.

* UserInterface/Views/TimelineRecordTreeElement.js:
(WebInspector.TimelineRecordTreeElement):
Icon for GC events.

LayoutTests:

* inspector/heap/garbageCollected-expected.txt: Added.
* inspector/heap/garbageCollected.html: Added.
* inspector/heap/gc-expected.txt: Added.
* inspector/heap/gc.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191159 268f45cc-cd09-0410-ab3c-d52691b4dbfc
49 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/heap/garbageCollected-expected.txt [new file with mode: 0644]
LayoutTests/inspector/heap/garbageCollected.html [new file with mode: 0644]
LayoutTests/inspector/heap/gc-expected.txt [new file with mode: 0644]
LayoutTests/inspector/heap/gc.html [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/HeapObserver.h [new file with mode: 0644]
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/inspector/InspectorEnvironment.h
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h
Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp [new file with mode: 0644]
Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/protocol/Heap.json [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/heap/HeapObserver.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/inspector/agents/InspectorHeapAgent.h [new file with mode: 0644]
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/inspector/WorkerInspectorController.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Base/Utilities.js
Source/WebInspectorUI/UserInterface/Controllers/HeapManager.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Images/TimelineRecordGarbageCollection.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Models/GarbageCollection.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Models/ScriptTimelineRecord.js
Source/WebInspectorUI/UserInterface/Protocol/HeapObserver.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Test.html
Source/WebInspectorUI/UserInterface/Test/Test.js
Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/ScriptTimelineOverviewGraph.js
Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js
Source/WebInspectorUI/UserInterface/Views/SourceCodeTimelineTreeElement.js
Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css
Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.css
Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js
Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js