Ignore:
Timestamp:
Oct 2, 2015, 1:40:47 PM (10 years ago)
Author:
[email protected]
Message:

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):

  • 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.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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r190350 r190520  
    2929#include "HandleSet.h"
    3030#include "HandleStack.h"
     31#include "HeapObserver.h"
    3132#include "HeapOperation.h"
    3233#include "JITStubRoutineSet.h"
     
    5051namespace JSC {
    5152
     53class CodeBlock;
    5254class CopiedSpace;
    53 class CodeBlock;
     55class EdenGCActivityCallback;
    5456class ExecutableBase;
    55 class EdenGCActivityCallback;
    5657class FullGCActivityCallback;
    5758class GCActivityCallback;
    5859class GCAwareJITStubRoutine;
    59 class GlobalCodeBlock;
    6060class Heap;
    6161class HeapRootVisitor;
     
    6464class JITStubRoutine;
    6565class JSCell;
    66 class VM;
    6766class JSStack;
    6867class JSValue;
    69 class LiveObjectIterator;
    7068class LLIntOffsetsExtractor;
    7169class MarkedArgumentBuffer;
    72 class WeakGCHandlePool;
    73 class SlotVisitor;
     70class VM;
    7471
    7572namespace DFG {
     
    133130    JS_EXPORT_PRIVATE IncrementalSweeper* sweeper();
    134131    JS_EXPORT_PRIVATE void setIncrementalSweeper(std::unique_ptr<IncrementalSweeper>);
     132
     133    void addObserver(HeapObserver* observer) { m_observers.append(observer); }
     134    void removeObserver(HeapObserver* observer) { m_observers.removeFirst(observer); }
    135135
    136136    // true if collection is in progress
     
    412412    std::unique_ptr<IncrementalSweeper> m_sweeper;
    413413    Vector<MarkedBlock*> m_blockSnapshot;
    414    
     414
     415    Vector<HeapObserver*> m_observers;
     416
    415417    unsigned m_deferralDepth;
    416418    Vector<DFG::Worklist*> m_suspendedCompilerWorklists;
Note: See TracChangeset for help on using the changeset viewer.