Re-apply the patch after v8 roll to r11000.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2012 13:59:47 +0000 (13:59 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2012 13:59:47 +0000 (13:59 +0000)
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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@110423 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/profiler/heap-snapshot-loader.html
LayoutTests/inspector/profiler/heap-snapshot-test.js
PerformanceTests/inspector/detailed-heapshots-smoke-test.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/HeapSnapshot.js

index 2e83266..d956bda 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-12  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Re-apply the patch after v8 roll to r11000.
+
+        Web Inspector: move heap snapshot nodes data to external array.
+        https://bugs.webkit.org/show_bug.cgi?id=79911
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/profiler/heap-snapshot-loader.html:
+        * inspector/profiler/heap-snapshot-test.js:
+        (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockRaw):
+        (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMock):
+        (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockWithDOM):
+
 2012-03-12  Hans Wennborg  <hans@chromium.org>
 
         Speech JavaScript API: SpeechRecognitionEvent
index 9727d3e..1c3082d 100644 (file)
@@ -14,14 +14,14 @@ function test()
     InspectorTest.runTestSuite([
         function heapSnapshotLoaderTest(next)
         {
-            var source = InspectorTest.createHeapSnapshotMock();
+            var source = InspectorTest.createHeapSnapshotMockRaw();
             var sourceStringified = JSON.stringify(source);
             var partSize = sourceStringified.length >> 3;
             var loader = new WebInspector.HeapSnapshotLoader();
             for (var i = 0, l = sourceStringified.length; i < l; i += partSize)
                 loader.pushJSONChunk(sourceStringified.slice(i, i + partSize));
             var result = loader.finishLoading();
-            InspectorTest.assertSnapshotEquals(new WebInspector.HeapSnapshot(source), result);
+            InspectorTest.assertSnapshotEquals(new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock()), result);
             next();
         }
     ]);
index 9054b23..3e75001 100644 (file)
@@ -37,7 +37,7 @@ InspectorTest.createHeapSnapshotMockObject = function()
     };
 };
 
-InspectorTest.createHeapSnapshotMock = function()
+InspectorTest.createHeapSnapshotMockRaw = function()
 {
     return {
         snapshot: {},
@@ -66,9 +66,24 @@ InspectorTest.createHeapSnapshotMock = function()
     };
 };
 
+InspectorTest._postprocessHeapSnapshotMock = function(mock)
+{
+    mock.metaNode = mock.nodes[0];
+    mock.nodes[0] = 0;
+    var tempNodes = new Int32Array(1000);
+    tempNodes.set(mock.nodes);
+    mock.nodes = tempNodes.subarray(0, mock.nodes.length);
+    return mock;
+};
+
+InspectorTest.createHeapSnapshotMock = function()
+{
+    return InspectorTest._postprocessHeapSnapshotMock(InspectorTest.createHeapSnapshotMockRaw());
+};
+
 InspectorTest.createHeapSnapshotMockWithDOM = function()
 {
-    return {
+    return InspectorTest._postprocessHeapSnapshotMock({
         snapshot: {},
         nodes: [
             { fields: ["type", "name", "id", "children_count", "children"],
@@ -100,7 +115,7 @@ InspectorTest.createHeapSnapshotMockWithDOM = function()
             /* M */         1,  9, 13, 0
             ],
         strings: ["", "A", "B", "C", "D", "E", "F", "G", "H", "M", "N", "Window", "native"]
-    };
+    });
 };
 
 };
index 8daaa7a..12c5e46 100644 (file)
@@ -89,7 +89,7 @@ function makeObjectsTree2(name, deep)
     window[name] = makeObjectsTree(deep);
 }
 
-makeObjectsTree2("t", 14);
+makeObjectsTree2("t", 16);
 
 </script>
 </head>
index d6dd04c..bb4d9f3 100644 (file)
@@ -1,3 +1,24 @@
+2012-03-12  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Re-apply the patch after v8 roll to r11000.
+
+        Web Inspector: move heap snapshot nodes data to external array.
+        https://bugs.webkit.org/show_bug.cgi?id=79911
+
+        Reviewed by Vsevolod Vlasov.
+
+        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):
+
 2012-03-12  Simon Hausmann  <simon.hausmann@nokia.com>
 
         [Qt] Fix build with newer Qt 5.
index 437cd9a..054f46e 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+WebInspector.Int32Array = function(size)
+{
+    const preallocateSize = 1000;
+    size = size || preallocateSize;
+    this._usedSize = 0;
+    this._array = new Int32Array(preallocateSize);
+}
+
+WebInspector.Int32Array.prototype = {
+    push: function(value)
+    {
+        if (this._usedSize + 1 > this._array.length) {
+            var tempArray = new Int32Array(this._array.length * 2);
+            tempArray.set(this._array);
+            this._array = tempArray;
+        }
+        this._array[this._usedSize++] = value;
+    },
+
+    get array()
+    {
+        return this._array.subarray(0, this._usedSize);
+    }
+}
+
 WebInspector.HeapSnapshotLoader = function()
 {
     this._json = "";
@@ -76,8 +101,7 @@ WebInspector.HeapSnapshotLoader.prototype = {
                     break;
                 else if (code === closingBracket) {
                     this._json = this._json.slice(index + 1);
-                    // Shave off provisionally allocated space.
-                    this._snapshot.nodes = this._snapshot.nodes.slice(0);
+                    this._snapshot.nodes = this._nodes.array;
                     return false;
                 }
                 ++index;
@@ -97,7 +121,7 @@ WebInspector.HeapSnapshotLoader.prototype = {
                 this._json = this._json.slice(startIndex);
                 return true;
             }
-            this._snapshot.nodes.push(parseInt(this._json.slice(startIndex, index)));
+            this._nodes.push(parseInt(this._json.slice(startIndex, index)));
         }
     },
 
@@ -151,7 +175,9 @@ WebInspector.HeapSnapshotLoader.prototype = {
             var closingBracketIndex = this._findBalancedCurlyBrackets();
             if (closingBracketIndex === -1)
                 return;
-            this._snapshot.nodes = [JSON.parse(this._json.slice(0, closingBracketIndex))];
+            this._nodes = new WebInspector.Int32Array();
+            this._nodes.push(0);
+            this._snapshot.metaNode = JSON.parse(this._json.slice(0, closingBracketIndex));
             this._json = this._json.slice(closingBracketIndex);
             this._state = "parse-nodes";
             this.pushJSONChunk("");
@@ -202,7 +228,7 @@ WebInspector.HeapSnapshotArraySlice.prototype = {
     {
         if (typeof end === "undefined")
             end = start + this._start + this.length;
-        return this._snapshot[this._arrayName].slice(this._start + start, end);
+        return this._snapshot[this._arrayName].subarray(this._start + start, end);
     }
 }
 
@@ -709,6 +735,7 @@ WebInspector.HeapSnapshot = function(profile)
 {
     this.uid = profile.snapshot.uid;
     this._nodes = profile.nodes;
+    this._metaNode = profile.metaNode;
     this._strings = profile.strings;
 
     this._init();
@@ -717,9 +744,8 @@ WebInspector.HeapSnapshot = function(profile)
 WebInspector.HeapSnapshot.prototype = {
     _init: function()
     {
-        this._metaNodeIndex = 0;
         this._rootNodeIndex = 1;
-        var meta = this._nodes[this._metaNodeIndex];
+        var meta = this._metaNode;
         this._nodeTypeOffset = meta.fields.indexOf("type");
         this._nodeNameOffset = meta.fields.indexOf("name");
         this._nodeIdOffset = meta.fields.indexOf("id");
@@ -895,7 +921,7 @@ WebInspector.HeapSnapshot.prototype = {
         //    interval (can be empty) with corresponding back references.
         //  - "indexArray" is an array of indexes in the "backRefsArray"
         //    with the same positions as in the _nodeIndex.
-        var indexArray = this[indexArrayName] = new Array(this._nodeIndex.length);
+        var indexArray = this[indexArrayName] = new Int32Array(this._nodeIndex.length);
         for (var i = 0, l = indexArray.length; i < l; ++i)
             indexArray[i] = 0;
         for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next()) {
@@ -904,7 +930,7 @@ WebInspector.HeapSnapshot.prototype = {
         var backRefsCount = 0;
         for (i = 0, l = indexArray.length; i < l; ++i)
             backRefsCount += indexArray[i];
-        var backRefsArray = this[backRefsArrayName] = new Array(backRefsCount + 1);
+        var backRefsArray = this[backRefsArrayName] = new Int32Array(backRefsCount + 1);
         // Put in the first slot of each backRefsArray slice the count of entries
         // that will be filled.
         var backRefsPosition = 0;
@@ -1057,7 +1083,7 @@ WebInspector.HeapSnapshot.prototype = {
     _buildNodeIndex: function()
     {
         var count = this.nodeCount;
-        this._nodeIndex = new Array(count + 1);
+        this._nodeIndex = new Int32Array(count + 1);
         count = 0;
         for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), ++count)
             this._nodeIndex[count] = nodesIter.index;