Changeset 57150 in webkit


Ignore:
Timestamp:
Apr 6, 2010 7:44:25 AM (14 years ago)
Author:
loislo@chromium.org
Message:

2010-04-06 Ilya Tikhonovsky <loislo@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: The JS code can be not optimal from memory usage point of view.
As example it can generate a lot of temp objects and GC will spend significant time to collect these objects.
GC event will show us these moments. Also each event can show us how much memory is in use.
https://bugs.webkit.org/show_bug.cgi?id=37025

  • WebCore.gypi:
  • WebCore.pro:
  • inspector/InspectorTimelineAgent.cpp: (WebCore::InspectorTimelineAgent::InspectorTimelineAgent): (WebCore::InspectorTimelineAgent::pushGCEventRecords): (WebCore::InspectorTimelineAgent::didGC): (WebCore::InspectorTimelineAgent::~InspectorTimelineAgent): (WebCore::InspectorTimelineAgent::didInstallTimer): (WebCore::InspectorTimelineAgent::didRemoveTimer): (WebCore::InspectorTimelineAgent::willSendResourceRequest): (WebCore::InspectorTimelineAgent::didFinishLoadingResource): (WebCore::InspectorTimelineAgent::didMarkTimeline): (WebCore::InspectorTimelineAgent::addRecordToTimeline): (WebCore::InspectorTimelineAgent::setHeapSizeStatistic): (WebCore::InspectorTimelineAgent::didCompleteCurrentRecord): (WebCore::InspectorTimelineAgent::pushCurrentRecord):
  • inspector/InspectorTimelineAgent.h: (WebCore::): (WebCore::InspectorTimelineAgent::instanceCount): (WebCore::InspectorTimelineAgent::TimelineRecordEntry::TimelineRecordEntry): (WebCore::InspectorTimelineAgent::GCEvent::GCEvent):
  • inspector/TimelineRecordFactory.cpp: (WebCore::TimelineRecordFactory::createGCEventData):
  • inspector/TimelineRecordFactory.h:
  • inspector/front-end/Popover.js: (WebInspector.PopoverHelper.prototype._mouseHover):
  • inspector/front-end/TimelineAgent.js:
  • inspector/front-end/TimelinePanel.js: (WebInspector.TimelinePanel.prototype.get _recordStyles): (WebInspector.TimelinePanel.FormattedRecord): (WebInspector.TimelinePanel.FormattedRecord.prototype._generatePopupContent): (WebInspector.TimelinePanel.FormattedRecord.prototype._getRecordDetails):
Location:
trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57147 r57150  
     12010-04-06  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: The JS code can be not optimal from memory usage point of view.
     6        As example it can generate a lot of temp objects and GC will spend significant time to collect these objects.
     7        GCRun event will show us these moments. Also each event can show us how much memory is in use.
     8        https://bugs.webkit.org/show_bug.cgi?id=37025
     9
     10        * inspector/timeline-enum-stability-expected.txt:
     11        * inspector/timeline-event-dispatch-expected.txt:
     12        * inspector/timeline-layout-expected.txt:
     13        * inspector/timeline-mark-timeline-expected.txt:
     14        * inspector/timeline-network-resource-expected.txt:
     15        * inspector/timeline-paint-expected.txt:
     16        * inspector/timeline-parse-html-expected.txt:
     17        * inspector/timeline-recalculate-styles-expected.txt:
     18        * inspector/timeline-script-tag-1-expected.txt:
     19        * inspector/timeline-script-tag-2-expected.txt:
     20        * inspector/timeline-test.js:
     21        * platform/chromium-win/inspector/timeline-event-dispatch-expected.txt:
     22        * platform/chromium-win/inspector/timeline-mark-timeline-expected.txt:
     23        * platform/chromium-win/inspector/timeline-network-resource-expected.txt:
     24        * platform/chromium-win/inspector/timeline-paint-expected.txt:
     25        * platform/chromium-win/inspector/timeline-parse-html-expected.txt:
     26
     272010-04-06  Yury Semikhatsky  <yurys@chromium.org>
     28
     29        Unreviewed. Update Chromium test expectations.
     30
     31        https://bugs.webkit.org/show_bug.cgi?id=36375
     32
     33        * platform/chromium-win/fast/workers/worker-script-error-expected.txt:
     34
    1352010-04-06  Yury Semikhatsky  <yurys@chromium.org>
    236
  • trunk/LayoutTests/inspector/timeline-enum-stability-expected.txt

    r56108 r57150  
    2020WebInspector.TimelineAgent.RecordType.FunctionCall : 15
    2121WebInspector.TimelineAgent.RecordType.ResourceReceiveData : 16
     22WebInspector.TimelineAgent.RecordType.GCEvent : 17
    2223
  • trunk/LayoutTests/inspector/timeline-event-dispatch-expected.txt

    r51604 r57150  
    1010+ endTime : * DEFINED *
    1111+ type : 0
     12+ usedHeapSize : * DEFINED *
     13+ totalHeapSize : * DEFINED *
    1214
  • trunk/LayoutTests/inspector/timeline-layout-expected.txt

    r53488 r57150  
    88+ endTime : * DEFINED *
    99+ type : 1
     10+ usedHeapSize : * DEFINED *
     11+ totalHeapSize : * DEFINED *
    1012Test data
  • trunk/LayoutTests/inspector/timeline-mark-timeline-expected.txt

    r50839 r57150  
    77+ }
    88+ type : 11
     9+ usedHeapSize : * DEFINED *
     10+ totalHeapSize : * DEFINED *
    911
  • trunk/LayoutTests/inspector/timeline-network-resource-expected.txt

    r56111 r57150  
    1111+ }
    1212+ type : 12
     13+ usedHeapSize : * DEFINED *
     14+ totalHeapSize : * DEFINED *
    1315
    1416ResourceReceiveResponse Properties:
     
    2426+ endTime : * DEFINED *
    2527+ type : 13
     28+ usedHeapSize : * DEFINED *
     29+ totalHeapSize : * DEFINED *
    2630
    2731ResourceFinish Properties:
     
    3337+ }
    3438+ type : 14
     39+ usedHeapSize : * DEFINED *
     40+ totalHeapSize : * DEFINED *
    3541Script resource loaded
  • trunk/LayoutTests/inspector/timeline-paint-expected.txt

    r51196 r57150  
    1212+ endTime : * DEFINED *
    1313+ type : 3
     14+ usedHeapSize : * DEFINED *
     15+ totalHeapSize : * DEFINED *
    1416
  • trunk/LayoutTests/inspector/timeline-parse-html-expected.txt

    r53488 r57150  
    1111+ endTime : * DEFINED *
    1212+ type : 4
     13+ usedHeapSize : * DEFINED *
     14+ totalHeapSize : * DEFINED *
    1315Test data
  • trunk/LayoutTests/inspector/timeline-recalculate-styles-expected.txt

    r53488 r57150  
    88+ endTime : * DEFINED *
    99+ type : 2
     10+ usedHeapSize : * DEFINED *
     11+ totalHeapSize : * DEFINED *
    1012Test data
  • trunk/LayoutTests/inspector/timeline-script-tag-1-expected.txt

    r51072 r57150  
    1313+ endTime : * DEFINED *
    1414+ type : 10
     15+ usedHeapSize : * DEFINED *
     16+ totalHeapSize : * DEFINED *
    1517
  • trunk/LayoutTests/inspector/timeline-script-tag-2-expected.txt

    r51072 r57150  
    1010+ endTime : * DEFINED *
    1111+ type : 10
     12+ usedHeapSize : * DEFINED *
     13+ totalHeapSize : * DEFINED *
    1214
  • trunk/LayoutTests/inspector/timeline-test.js

    r56110 r57150  
    1212    callerScriptLine: 1,
    1313    url : 1,
     14    usedHeapSize: 1,
     15    totalHeapSize: 1,
    1416    mimeType : 1
    1517};
  • trunk/LayoutTests/platform/chromium-win/inspector/timeline-event-dispatch-expected.txt

    r56271 r57150  
    1212+ endTime : * DEFINED *
    1313+ type : 0
     14+ usedHeapSize : * DEFINED *
     15+ totalHeapSize : * DEFINED *
    1416
  • trunk/LayoutTests/platform/chromium-win/inspector/timeline-mark-timeline-expected.txt

    r56271 r57150  
    99+ }
    1010+ type : 11
     11+ usedHeapSize : * DEFINED *
     12+ totalHeapSize : * DEFINED *
    1113
  • trunk/LayoutTests/platform/chromium-win/inspector/timeline-network-resource-expected.txt

    r56271 r57150  
    1313+ }
    1414+ type : 12
     15+ usedHeapSize : * DEFINED *
     16+ totalHeapSize : * DEFINED *
    1517
    1618ResourceReceiveResponse Properties:
     
    2628+ endTime : * DEFINED *
    2729+ type : 13
     30+ usedHeapSize : * DEFINED *
     31+ totalHeapSize : * DEFINED *
    2832
    2933ResourceFinish Properties:
     
    3539+ }
    3640+ type : 14
     41+ usedHeapSize : * DEFINED *
     42+ totalHeapSize : * DEFINED *
    3743Script resource loaded
  • trunk/LayoutTests/platform/chromium-win/inspector/timeline-paint-expected.txt

    r56271 r57150  
    1414+ endTime : * DEFINED *
    1515+ type : 3
     16+ usedHeapSize : * DEFINED *
     17+ totalHeapSize : * DEFINED *
    1618
  • trunk/LayoutTests/platform/chromium-win/inspector/timeline-parse-html-expected.txt

    r56271 r57150  
    1313+ endTime : * DEFINED *
    1414+ type : 4
     15+ usedHeapSize : * DEFINED *
     16+ totalHeapSize : * DEFINED *
    1517Test data
  • trunk/WebCore/ChangeLog

    r57148 r57150  
     12010-04-06  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: The JS code can be not optimal from memory usage point of view.
     6        As example it can generate a lot of temp objects and GC will spend significant time to collect these objects.
     7        GC event will show us these moments. Also each event can show us how much memory is in use.
     8        https://bugs.webkit.org/show_bug.cgi?id=37025
     9
     10        * WebCore.gypi:
     11        * WebCore.pro:
     12        * inspector/InspectorTimelineAgent.cpp:
     13        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
     14        (WebCore::InspectorTimelineAgent::pushGCEventRecords):
     15        (WebCore::InspectorTimelineAgent::didGC):
     16        (WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
     17        (WebCore::InspectorTimelineAgent::didInstallTimer):
     18        (WebCore::InspectorTimelineAgent::didRemoveTimer):
     19        (WebCore::InspectorTimelineAgent::willSendResourceRequest):
     20        (WebCore::InspectorTimelineAgent::didFinishLoadingResource):
     21        (WebCore::InspectorTimelineAgent::didMarkTimeline):
     22        (WebCore::InspectorTimelineAgent::addRecordToTimeline):
     23        (WebCore::InspectorTimelineAgent::setHeapSizeStatistic):
     24        (WebCore::InspectorTimelineAgent::didCompleteCurrentRecord):
     25        (WebCore::InspectorTimelineAgent::pushCurrentRecord):
     26        * inspector/InspectorTimelineAgent.h:
     27        (WebCore::):
     28        (WebCore::InspectorTimelineAgent::instanceCount):
     29        (WebCore::InspectorTimelineAgent::TimelineRecordEntry::TimelineRecordEntry):
     30        (WebCore::InspectorTimelineAgent::GCEvent::GCEvent):
     31        * inspector/TimelineRecordFactory.cpp:
     32        (WebCore::TimelineRecordFactory::createGCEventData):
     33        * inspector/TimelineRecordFactory.h:
     34        * inspector/front-end/Popover.js:
     35        (WebInspector.PopoverHelper.prototype._mouseHover):
     36        * inspector/front-end/TimelineAgent.js:
     37        * inspector/front-end/TimelinePanel.js:
     38        (WebInspector.TimelinePanel.prototype.get _recordStyles):
     39        (WebInspector.TimelinePanel.FormattedRecord):
     40        (WebInspector.TimelinePanel.FormattedRecord.prototype._generatePopupContent):
     41        (WebInspector.TimelinePanel.FormattedRecord.prototype._getRecordDetails):
     42
    1432010-04-05  Antonio Gomes  <tonikitoo@webkit.org>
    244
  • trunk/WebCore/WebCore.gypi

    r57134 r57150  
    823823            'bindings/v8/ScriptFunctionCall.cpp',
    824824            'bindings/v8/ScriptFunctionCall.h',
     825            'bindings/v8/ScriptGCEvent.cpp',
     826            'bindings/v8/ScriptGCEvent.h',
    825827            'bindings/v8/ScriptInstance.cpp',
    826828            'bindings/v8/ScriptInstance.h',
     
    16511653            'inspector/ScriptBreakpoint.h',
    16521654            'inspector/ScriptDebugListener.h',
     1655            'inspector/ScriptGCEventListener.h',
    16531656            'inspector/TimelineRecordFactory.cpp',
    16541657            'inspector/TimelineRecordFactory.h',
  • trunk/WebCore/WebCore.pro

    r57134 r57150  
    10841084    bindings/js/ScriptEventListener.h \
    10851085    bindings/js/ScriptFunctionCall.h \
     1086    bindings/js/ScriptGCEvent.h \
    10861087    bindings/js/ScriptObject.h \
    10871088    bindings/js/ScriptSourceCode.h \
     
    14301431    inspector/InspectorTimelineAgent.h \
    14311432    inspector/JavaScriptCallFrame.h \
     1433    inspector/ScriptGCEventListener.h \
    14321434    inspector/TimelineRecordFactory.h \
    14331435    loader/appcache/ApplicationCacheGroup.h \
  • trunk/WebCore/inspector/InspectorTimelineAgent.cpp

    r56108 r57150  
    5151{
    5252    ++s_instanceCount;
     53    ScriptGCEvent::addEventListener(this);
    5354    ASSERT(m_frontend);
     55}
     56
     57void InspectorTimelineAgent::pushGCEventRecords()
     58{
     59    for (GCEvents::iterator i = m_gcEvents.begin(); i != m_gcEvents.end(); ++i) {
     60        ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, i->startTime);
     61        record.set("data", TimelineRecordFactory::createGCEventData(m_frontend, i->collectedBytes));
     62        record.set("endTime", i->endTime);
     63        addRecordToTimeline(record, GCEventTimelineRecordType);
     64    }
     65    m_gcEvents.clear();
     66}
     67
     68void InspectorTimelineAgent::didGC(double startTime, double endTime, size_t collectedBytesCount)
     69{
     70    m_gcEvents.append(GCEvent(startTime, endTime, collectedBytesCount));
    5471}
    5572
     
    5875    ASSERT(s_instanceCount);
    5976    --s_instanceCount;
     77    ScriptGCEvent::removeEventListener(this);
    6078}
    6179
     
    127145void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot)
    128146{
    129     ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, currentTimeInMilliseconds());
     147    ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, WTF::currentTimeMS());
    130148    record.set("data", TimelineRecordFactory::createTimerInstallData(m_frontend, timerId, timeout, singleShot));
    131149    addRecordToTimeline(record, TimerInstallTimelineRecordType);
     
    134152void InspectorTimelineAgent::didRemoveTimer(int timerId)
    135153{
    136     ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, currentTimeInMilliseconds());
     154    ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, WTF::currentTimeMS());
    137155    record.set("data", TimelineRecordFactory::createGenericTimerData(m_frontend, timerId));
    138156    addRecordToTimeline(record, TimerRemoveTimelineRecordType);
     
    182200    const ResourceRequest& request)
    183201{
    184     ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, currentTimeInMilliseconds());
     202    pushGCEventRecords();
     203    ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, WTF::currentTimeMS());
    185204    record.set("data", TimelineRecordFactory::createResourceSendRequestData(m_frontend, identifier, isMainResource, request));
    186205    record.set("type", ResourceSendRequestTimelineRecordType);
     206    setHeapSizeStatistic(record);
    187207    m_frontend->addRecordToTimeline(record);
    188208}
     
    210230void InspectorTimelineAgent::didFinishLoadingResource(unsigned long identifier, bool didFail)
    211231{
    212     ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, currentTimeInMilliseconds());
     232    pushGCEventRecords();
     233    ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, WTF::currentTimeMS());
    213234    record.set("data", TimelineRecordFactory::createResourceFinishData(m_frontend, identifier, didFail));
    214235    record.set("type", ResourceFinishTimelineRecordType);
     236    setHeapSizeStatistic(record);
    215237    m_frontend->addRecordToTimeline(record);
    216238}
     
    218240void InspectorTimelineAgent::didMarkTimeline(const String& message)
    219241{
    220     ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, currentTimeInMilliseconds());
     242    ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, WTF::currentTimeMS());
    221243    record.set("data", TimelineRecordFactory::createMarkTimelineData(m_frontend, message));
    222244    addRecordToTimeline(record, MarkTimelineRecordType);
     
    236258
    237259void InspectorTimelineAgent::addRecordToTimeline(ScriptObject record, TimelineRecordType type)
    238 {
     260
     261    if (type != GCEventTimelineRecordType)
     262        pushGCEventRecords();
    239263    record.set("type", type);
     264    setHeapSizeStatistic(record);
    240265    if (m_recordStack.isEmpty())
    241266        m_frontend->addRecordToTimeline(record);
     
    244269        parent.children.set(parent.children.length(), record);
    245270    }
     271}
     272
     273void InspectorTimelineAgent::setHeapSizeStatistic(ScriptObject record)
     274{
     275    size_t usedHeapSize = 0;
     276    size_t totalHeapSize = 0;
     277    ScriptGCEvent::getHeapSize(usedHeapSize, totalHeapSize);
     278    record.set("usedHeapSize", usedHeapSize);
     279    record.set("totalHeapSize", totalHeapSize);
    246280}
    247281
     
    256290        entry.record.set("data", entry.data);
    257291        entry.record.set("children", entry.children);
    258         entry.record.set("endTime", currentTimeInMilliseconds());
     292        entry.record.set("endTime", WTF::currentTimeMS());
    259293        addRecordToTimeline(entry.record, type);
    260294    }
    261295}
    262296
    263 double InspectorTimelineAgent::currentTimeInMilliseconds()
    264 {
    265     return currentTime() * 1000.0;
    266 }
    267 
    268297void InspectorTimelineAgent::pushCurrentRecord(ScriptObject data, TimelineRecordType type)
    269298{
    270     ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, currentTimeInMilliseconds());
     299    pushGCEventRecords();
     300    ScriptObject record = TimelineRecordFactory::createGenericRecord(m_frontend, WTF::currentTimeMS());
    271301    m_recordStack.append(TimelineRecordEntry(record, data, m_frontend->newScriptArray(), type));
    272302}
  • trunk/WebCore/inspector/InspectorTimelineAgent.h

    r56108 r57150  
    3636#include "Document.h"
    3737#include "ScriptExecutionContext.h"
     38#include "ScriptGCEvent.h"
     39#include "ScriptGCEventListener.h"
    3840#include "ScriptObject.h"
    3941#include "ScriptArray.h"
     
    4143
    4244namespace WebCore {
    43     class Event;
    44     class InspectorFrontend;
    45     class IntRect;
    46     class ResourceRequest;
    47     class ResourceResponse;
     45class Event;
     46class InspectorFrontend;
     47class IntRect;
     48class ResourceRequest;
     49class ResourceResponse;
    4850
    49     // Must be kept in sync with TimelineAgent.js
    50     enum TimelineRecordType {
    51         EventDispatchTimelineRecordType = 0,
    52         LayoutTimelineRecordType = 1,
    53         RecalculateStylesTimelineRecordType = 2,
    54         PaintTimelineRecordType = 3,
    55         ParseHTMLTimelineRecordType = 4,
    56         TimerInstallTimelineRecordType = 5,
    57         TimerRemoveTimelineRecordType = 6,
    58         TimerFireTimelineRecordType = 7,
    59         XHRReadyStateChangeRecordType = 8,
    60         XHRLoadRecordType = 9,
    61         EvaluateScriptTimelineRecordType = 10,
    62         MarkTimelineRecordType = 11,
    63         ResourceSendRequestTimelineRecordType = 12,
    64         ResourceReceiveResponseTimelineRecordType = 13,
    65         ResourceFinishTimelineRecordType = 14,
    66         FunctionCallTimelineRecordType = 15,
    67         ReceiveResourceDataTimelineRecordType = 16,
     51// Must be kept in sync with TimelineAgent.js
     52enum TimelineRecordType {
     53    EventDispatchTimelineRecordType = 0,
     54    LayoutTimelineRecordType = 1,
     55    RecalculateStylesTimelineRecordType = 2,
     56    PaintTimelineRecordType = 3,
     57    ParseHTMLTimelineRecordType = 4,
     58    TimerInstallTimelineRecordType = 5,
     59    TimerRemoveTimelineRecordType = 6,
     60    TimerFireTimelineRecordType = 7,
     61    XHRReadyStateChangeRecordType = 8,
     62    XHRLoadRecordType = 9,
     63    EvaluateScriptTimelineRecordType = 10,
     64    MarkTimelineRecordType = 11,
     65    ResourceSendRequestTimelineRecordType = 12,
     66    ResourceReceiveResponseTimelineRecordType = 13,
     67    ResourceFinishTimelineRecordType = 14,
     68    FunctionCallTimelineRecordType = 15,
     69    ReceiveResourceDataTimelineRecordType = 16,
     70    GCEventTimelineRecordType = 17,
     71};
     72
     73class InspectorTimelineAgent : ScriptGCEventListener, public Noncopyable {
     74public:
     75    InspectorTimelineAgent(InspectorFrontend* frontend);
     76    ~InspectorTimelineAgent();
     77
     78    void reset();
     79    void resetFrontendProxyObject(InspectorFrontend*);
     80
     81    // Methods called from WebCore.
     82    void willCallFunction(const String& scriptName, int scriptLine);
     83    void didCallFunction();
     84
     85    void willDispatchEvent(const Event&);
     86    void didDispatchEvent();
     87
     88    void willLayout();
     89    void didLayout();
     90
     91    void willRecalculateStyle();
     92    void didRecalculateStyle();
     93
     94    void willPaint(const IntRect&);
     95    void didPaint();
     96
     97    void willWriteHTML(unsigned int length, unsigned int startLine);
     98    void didWriteHTML(unsigned int endLine);
     99       
     100    void didInstallTimer(int timerId, int timeout, bool singleShot);
     101    void didRemoveTimer(int timerId);
     102    void willFireTimer(int timerId);
     103    void didFireTimer();
     104
     105    void willChangeXHRReadyState(const String&, int);
     106    void didChangeXHRReadyState();
     107    void willLoadXHR(const String&);
     108    void didLoadXHR();
     109
     110    void willEvaluateScript(const String&, int);
     111    void didEvaluateScript();
     112
     113    void didMarkTimeline(const String&);
     114
     115    void willSendResourceRequest(unsigned long, bool isMainResource, const ResourceRequest&);
     116    void willReceiveResourceResponse(unsigned long, const ResourceResponse&);
     117    void didReceiveResourceResponse();
     118    void didFinishLoadingResource(unsigned long, bool didFail);
     119    void willReceiveResourceData(unsigned long identifier);
     120    void didReceiveResourceData();
     121       
     122    virtual void didGC(double, double, size_t);
     123
     124    static int instanceCount() { return s_instanceCount; }
     125    static InspectorTimelineAgent* retrieve(ScriptExecutionContext*);
     126
     127private:
     128    struct TimelineRecordEntry {
     129        TimelineRecordEntry(ScriptObject record, ScriptObject data, ScriptArray children, TimelineRecordType type)
     130            : record(record), data(data), children(children), type(type)
     131        {
     132        }
     133        ScriptObject record;
     134        ScriptObject data;
     135        ScriptArray children;
     136        TimelineRecordType type;
    68137    };
     138       
     139    void pushCurrentRecord(ScriptObject, TimelineRecordType);
     140    void setHeapSizeStatistic(ScriptObject record);
     141       
     142    void didCompleteCurrentRecord(TimelineRecordType);
    69143
    70     class InspectorTimelineAgent : public Noncopyable {
    71     public:
    72         InspectorTimelineAgent(InspectorFrontend* frontend);
    73         ~InspectorTimelineAgent();
     144    void addRecordToTimeline(ScriptObject, TimelineRecordType);
    74145
    75         void reset();
    76         void resetFrontendProxyObject(InspectorFrontend*);
     146    void pushGCEventRecords();
    77147
    78         // Methods called from WebCore.
    79         void willCallFunction(const String& scriptName, int scriptLine);
    80         void didCallFunction();
     148    InspectorFrontend* m_frontend;
    81149
    82         void willDispatchEvent(const Event&);
    83         void didDispatchEvent();
    84 
    85         void willLayout();
    86         void didLayout();
    87 
    88         void willRecalculateStyle();
    89         void didRecalculateStyle();
    90 
    91         void willPaint(const IntRect&);
    92         void didPaint();
    93 
    94         void willWriteHTML(unsigned int length, unsigned int startLine);
    95         void didWriteHTML(unsigned int endLine);
    96        
    97         void didInstallTimer(int timerId, int timeout, bool singleShot);
    98         void didRemoveTimer(int timerId);
    99         void willFireTimer(int timerId);
    100         void didFireTimer();
    101 
    102         void willChangeXHRReadyState(const String&, int);
    103         void didChangeXHRReadyState();
    104         void willLoadXHR(const String&);
    105         void didLoadXHR();
    106 
    107         void willEvaluateScript(const String&, int);
    108         void didEvaluateScript();
    109 
    110         void didMarkTimeline(const String&);
    111 
    112         void willSendResourceRequest(unsigned long, bool isMainResource, const ResourceRequest&);
    113         void willReceiveResourceResponse(unsigned long, const ResourceResponse&);
    114         void didReceiveResourceResponse();
    115         void didFinishLoadingResource(unsigned long, bool didFail);
    116         void willReceiveResourceData(unsigned long identifier);
    117         void didReceiveResourceData();
    118        
    119         static int instanceCount() { return s_instanceCount; }
    120         static InspectorTimelineAgent* retrieve(ScriptExecutionContext*);
    121 
    122     private:
    123         struct TimelineRecordEntry {
    124             TimelineRecordEntry(ScriptObject record, ScriptObject data, ScriptArray children, TimelineRecordType type) : record(record), data(data), children(children), type(type) { }
    125             ScriptObject record;
    126             ScriptObject data;
    127             ScriptArray children;
    128             TimelineRecordType type;
    129         };
    130        
    131         void pushCurrentRecord(ScriptObject, TimelineRecordType);
    132        
    133         static double currentTimeInMilliseconds();
    134 
    135         void didCompleteCurrentRecord(TimelineRecordType);
    136 
    137         void addRecordToTimeline(ScriptObject, TimelineRecordType);
    138 
    139         InspectorFrontend* m_frontend;
    140 
    141         Vector< TimelineRecordEntry > m_recordStack;
    142         static int s_instanceCount;
     150    Vector<TimelineRecordEntry> m_recordStack;
     151    static int s_instanceCount;
     152    struct GCEvent {
     153        GCEvent(double startTime, double endTime, size_t collectedBytes)
     154            : startTime(startTime), endTime(endTime), collectedBytes(collectedBytes)
     155        {
     156        }
     157        double startTime;
     158        double endTime;
     159        size_t collectedBytes;
    143160    };
     161    typedef Vector<GCEvent> GCEvents;
     162    GCEvents m_gcEvents;
     163};
    144164
    145165inline InspectorTimelineAgent* InspectorTimelineAgent::retrieve(ScriptExecutionContext* context)
  • trunk/WebCore/inspector/TimelineRecordFactory.cpp

    r56108 r57150  
    5757    }
    5858    return record;
     59}
     60
     61ScriptObject TimelineRecordFactory::createGCEventData(InspectorFrontend* frontend, const size_t usedHeapSizeDelta)
     62{
     63    ScriptObject data = frontend->newScriptObject();
     64    data.set("usedHeapSizeDelta", usedHeapSizeDelta);
     65    return data;
    5966}
    6067
  • trunk/WebCore/inspector/TimelineRecordFactory.h

    r56108 r57150  
    4747        static ScriptObject createGenericRecord(InspectorFrontend*, double startTime);
    4848
     49        static ScriptObject createGCEventData(InspectorFrontend* frontend, const size_t usedHeapSizeDelta);
     50
    4951        static ScriptObject createFunctionCallData(InspectorFrontend*, const String& scriptName, int scriptLine);
    5052
  • trunk/WebCore/inspector/front-end/Popover.js

    r55614 r57150  
    222222
    223223        this._popup = this._showPopup(element);
    224         this._popup.contentElement.addEventListener("mousemove", this._killHidePopupTimer.bind(this), true);
     224        if (this._popup)
     225            this._popup.contentElement.addEventListener("mousemove", this._killHidePopupTimer.bind(this), true);
    225226    },
    226227
  • trunk/WebCore/inspector/front-end/TimelineAgent.js

    r56108 r57150  
    5151    ResourceFinish : 14,
    5252    FunctionCall : 15,
    53     ResourceReceiveData: 16
     53    ResourceReceiveData: 16,
     54    GCEvent : 17
    5455};
    5556
  • trunk/WebCore/inspector/front-end/TimelinePanel.js

    r56997 r57150  
    152152            recordStyles[recordTypes.FunctionCall] = { title: WebInspector.UIString("Function Call"), category: this.categories.scripting };
    153153            recordStyles[recordTypes.ResourceReceiveData] = { title: WebInspector.UIString("Receive Data"), category: this.categories.loading };
     154            recordStyles[recordTypes.GCEvent] = { title: WebInspector.UIString("GC Event"), category: this.categories.scripting };
    154155            this._recordStylesArray = recordStyles;
    155156        }
     
    726727    this.callerScriptName = record.callerScriptName;
    727728    this.callerScriptLine = record.callerScriptLine;
     729    this.totalHeapSize = record.totalHeapSize;
     730    this.usedHeapSize = record.usedHeapSize;
    728731
    729732    // Make resource receive record last since request was sent; make finish record last since response received.
     
    818821        const recordTypes = WebInspector.TimelineAgent.RecordType;
    819822        if (this.details) {
    820             if (this.type === recordTypes.TimerInstall ||
     823            if (this.type === recordTypes.GCEvent )
     824                recordContentTable.appendChild(this._createRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data.usedHeapSizeDelta)));
     825            else if (this.type === recordTypes.TimerInstall ||
    821826                this.type === recordTypes.TimerFire ||
    822827                this.type === recordTypes.TimerRemove) {
     
    857862        }
    858863
    859         if (this.callerScriptName) {
     864        if (this.type !== recordTypes.GCEvent && this.callerScriptName) {
    860865            var link = WebInspector.linkifyResourceAsNode(this.callerScriptName, "scripts", this.callerScriptLine);
    861866            recordContentTable.appendChild(this._createLinkRow(WebInspector.UIString("Caller"), link));
    862867        }
     868        if (this.usedHeapSize) {
     869            recordContentTable.appendChild(this._createRow(WebInspector.UIString("Used Heap Size"), Number.bytesToString(this.usedHeapSize)));
     870            recordContentTable.appendChild(this._createRow(WebInspector.UIString("Total Heap Size"), Number.bytesToString(this.totalHeapSize)));
     871        }
    863872        return recordContentTable;
    864873    },
     
    867876    {
    868877        switch (record.type) {
     878            case WebInspector.TimelineAgent.RecordType.GCEvent:
     879                return WebInspector.UIString("%s collected", Number.bytesToString(record.data.usedHeapSizeDelta));
    869880            case WebInspector.TimelineAgent.RecordType.FunctionCall:
    870881                return WebInspector.displayNameForURL(record.data.scriptName) + ":" + record.data.scriptLine;
Note: See TracChangeset for help on using the changeset viewer.