Changeset 109343 in webkit


Ignore:
Timestamp:
Mar 1, 2012 6:15:24 AM (12 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: move heap snapshot nodes data to external array.
https://bugs.webkit.org/show_bug.cgi?id=79911

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Tests:
heap-shapshot.html
heap-shapshot-loader.html

  • inspector/front-end/HeapSnapshot.js:

(WebInspector.Int32Array):
(WebInspector.Int32Array.prototype.get array):
(WebInspector.HeapSnapshotLoader.prototype._parseNodes):
(WebInspector.HeapSnapshotLoader.prototype.pushJSONChunk):
(WebInspector.HeapSnapshot):
(WebInspector.HeapSnapshot.prototype._init):

LayoutTests:

  • inspector/profiler/heap-snapshot-loader.html:
  • inspector/profiler/heap-snapshot-test.js:

(initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockRaw):
(initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMock):
(initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockWithDOM):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109342 r109343  
     12012-03-01  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: move heap snapshot nodes data to external array.
     4        https://bugs.webkit.org/show_bug.cgi?id=79911
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        * inspector/profiler/heap-snapshot-loader.html:
     9        * inspector/profiler/heap-snapshot-test.js:
     10        (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockRaw):
     11        (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMock):
     12        (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockWithDOM):
     13
    1142012-03-01  Nikolas Zimmermann  <nzimmermann@rim.com>
    215
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html

    r85182 r109343  
    1515        function heapSnapshotLoaderTest(next)
    1616        {
    17             var source = InspectorTest.createHeapSnapshotMock();
     17            var source = InspectorTest.createHeapSnapshotMockRaw();
    1818            var sourceStringified = JSON.stringify(source);
    1919            var partSize = sourceStringified.length >> 3;
     
    2222                loader.pushJSONChunk(sourceStringified.slice(i, i + partSize));
    2323            var result = loader.finishLoading();
    24             InspectorTest.assertSnapshotEquals(new WebInspector.HeapSnapshot(source), result);
     24            InspectorTest.assertSnapshotEquals(new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock()), result);
    2525            next();
    2626        }
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js

    r108729 r109343  
    3838};
    3939
    40 InspectorTest.createHeapSnapshotMock = function()
     40InspectorTest.createHeapSnapshotMockRaw = function()
    4141{
    4242    return {
     
    6767};
    6868
     69InspectorTest._postprocessHeapSnapshotMock = function(mock)
     70{
     71    mock.metaNode = mock.nodes[0];
     72    mock.nodes[0] = 0;
     73    var tempNodes = new Int32Array(1000);
     74    tempNodes.set(mock.nodes);
     75    mock.nodes = tempNodes.subarray(0, mock.nodes.length);
     76    return mock;
     77};
     78
     79InspectorTest.createHeapSnapshotMock = function()
     80{
     81    return InspectorTest._postprocessHeapSnapshotMock(InspectorTest.createHeapSnapshotMockRaw());
     82};
     83
    6984InspectorTest.createHeapSnapshotMockWithDOM = function()
    7085{
    71     return {
     86    return InspectorTest._postprocessHeapSnapshotMock({
    7287        snapshot: {},
    7388        nodes: [
     
    101116            ],
    102117        strings: ["", "A", "B", "C", "D", "E", "F", "G", "H", "M", "N", "Window", "native"]
    103     };
     118    });
    104119};
    105120
  • trunk/Source/WebCore/ChangeLog

    r109342 r109343  
     12012-03-01  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: move heap snapshot nodes data to external array.
     4        https://bugs.webkit.org/show_bug.cgi?id=79911
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        Tests:
     9        heap-shapshot.html
     10        heap-shapshot-loader.html
     11
     12        * inspector/front-end/HeapSnapshot.js:
     13        (WebInspector.Int32Array):
     14        (WebInspector.Int32Array.prototype.get array):
     15        (WebInspector.HeapSnapshotLoader.prototype._parseNodes):
     16        (WebInspector.HeapSnapshotLoader.prototype.pushJSONChunk):
     17        (WebInspector.HeapSnapshot):
     18        (WebInspector.HeapSnapshot.prototype._init):
     19
    1202012-03-01  Nikolas Zimmermann  <nzimmermann@rim.com>
    221
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js

    r108729 r109343  
    2929 */
    3030
     31WebInspector.Int32Array = function()
     32{
     33    const preallocateSize = 1000;
     34    this._usedSize = 0;
     35    this._array = new Int32Array(preallocateSize);
     36}
     37
     38WebInspector.Int32Array.prototype = {
     39    push: function(value)
     40    {
     41        if (this._usedSize + 1 > this._array.length) {
     42            var tempArray = new Int32Array(this._array.length * 2);
     43            tempArray.set(this._array);
     44            this._array = tempArray;
     45        }
     46        this._array[this._usedSize++] = value;
     47    },
     48
     49    get array()
     50    {
     51        return this._array.subarray(0, this._usedSize);
     52    }
     53}
     54
    3155WebInspector.HeapSnapshotLoader = function()
    3256{
     
    77101                else if (code === closingBracket) {
    78102                    this._json = this._json.slice(index + 1);
    79                     // Shave off provisionally allocated space.
    80                     this._snapshot.nodes = this._snapshot.nodes.slice(0);
     103                    this._snapshot.nodes = this._nodes.array;
    81104                    return false;
    82105                }
     
    98121                return true;
    99122            }
    100             this._snapshot.nodes.push(parseInt(this._json.slice(startIndex, index)));
     123            this._nodes.push(parseInt(this._json.slice(startIndex, index)));
    101124        }
    102125    },
     
    152175            if (closingBracketIndex === -1)
    153176                return;
    154             this._snapshot.nodes = [JSON.parse(this._json.slice(0, closingBracketIndex))];
     177            this._nodes = new WebInspector.Int32Array();
     178            this._nodes.push(0);
     179            this._snapshot.metaNode = JSON.parse(this._json.slice(0, closingBracketIndex));
    155180            this._json = this._json.slice(closingBracketIndex);
    156181            this._state = "parse-nodes";
     
    710735    this.uid = profile.snapshot.uid;
    711736    this._nodes = profile.nodes;
     737    this._metaNode = profile.metaNode;
    712738    this._strings = profile.strings;
    713739
     
    718744    _init: function()
    719745    {
    720         this._metaNodeIndex = 0;
    721746        this._rootNodeIndex = 1;
    722         var meta = this._nodes[this._metaNodeIndex];
     747        var meta = this._metaNode;
    723748        this._nodeTypeOffset = meta.fields.indexOf("type");
    724749        this._nodeNameOffset = meta.fields.indexOf("name");
Note: See TracChangeset for help on using the changeset viewer.