Web Inspector: Include Garbage Collection Event in Timeline
https://bugs.webkit.org/show_bug.cgi?id=142510
Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-10-02
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
- CMakeLists.txt:
- DerivedSources.make:
- JavaScriptCore.xcodeproj/project.pbxproj:
- heap/HeapObserver.h:
- heap/Heap.cpp:
(JSC::Heap::willStartCollection):
(JSC::Heap::didFinishCollection):
(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.parition):
Helper to partition an Array into two arrays.
- UserInterface/Main.html:
- Localizations/en.lproj/localizedStrings.js:
- UserInterface/Base/Main.js:
(WebInspector.loaded):
- UserInterface/Test.html:
- UserInterface/Test/Test.js:
(WebInspector.loaded):
- UserInterface/Protocol/HeapObserver.js:
(WebInspector.HeapObserver.prototype.garbageCollected):
(WebInspector.HeapObserver):
Create the new observer and manager.
- UserInterface/Models/GarbageCollection.js:
(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:
(WebInspector.HeapManager):
(WebInspector.HeapManager.prototype.garbageCollected):
Dispatch events with.
- 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 on top of the the Scripts bar. This is particularly useful
since a GC can happen during script execution.
- UserInterface/Views/ScriptTimelineDataGridNode.js:
(WebInspector.ScriptTimelineDataGridNode.prototype.get data):
(WebInspector.ScriptTimelineDataGridNode.prototype.createCellContent):
(WebInspector.ScriptTimelineDataGridNode):
Give a NaN call count to top level Script DataGridNodes.
In the UI, display the empty placeholder for NaN call counts.
- UserInterface/Images/TimelineRecordGarbageCollection.svg: Added.
- UserInterface/Models/ScriptTimelineRecord.js:
(WebInspector.ScriptTimelineRecord.prototype.isGarbageCollection):
(WebInspector.ScriptTimelineRecord.EventType.displayName):
- 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.