- Revision
- 109343
- Author
- [email protected]
- Date
- 2012-03-01 06:15:24 -0800 (Thu, 01 Mar 2012)
Log 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):
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (109342 => 109343)
--- trunk/LayoutTests/ChangeLog 2012-03-01 14:00:55 UTC (rev 109342)
+++ trunk/LayoutTests/ChangeLog 2012-03-01 14:15:24 UTC (rev 109343)
@@ -1,3 +1,16 @@
+2012-03-01 Ilya Tikhonovsky <[email protected]>
+
+ 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-01 Nikolas Zimmermann <[email protected]>
Introduce SMIL overrideStyle, to make SVG stop mutating CSS styles directly
Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html (109342 => 109343)
--- trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html 2012-03-01 14:00:55 UTC (rev 109342)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot-loader.html 2012-03-01 14:15:24 UTC (rev 109343)
@@ -14,14 +14,14 @@
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();
}
]);
Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js (109342 => 109343)
--- trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js 2012-03-01 14:00:55 UTC (rev 109342)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js 2012-03-01 14:15:24 UTC (rev 109343)
@@ -37,7 +37,7 @@
};
};
-InspectorTest.createHeapSnapshotMock = function()
+InspectorTest.createHeapSnapshotMockRaw = function()
{
return {
snapshot: {},
@@ -66,9 +66,24 @@
};
};
+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 @@
/* M */ 1, 9, 13, 0
],
strings: ["", "A", "B", "C", "D", "E", "F", "G", "H", "M", "N", "Window", "native"]
- };
+ });
};
};
Modified: trunk/Source/WebCore/ChangeLog (109342 => 109343)
--- trunk/Source/WebCore/ChangeLog 2012-03-01 14:00:55 UTC (rev 109342)
+++ trunk/Source/WebCore/ChangeLog 2012-03-01 14:15:24 UTC (rev 109343)
@@ -1,3 +1,22 @@
+2012-03-01 Ilya Tikhonovsky <[email protected]>
+
+ 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-01 Nikolas Zimmermann <[email protected]>
Introduce SMIL overrideStyle, to make SVG stop mutating CSS styles directly
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js (109342 => 109343)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js 2012-03-01 14:00:55 UTC (rev 109342)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js 2012-03-01 14:15:24 UTC (rev 109343)
@@ -28,6 +28,30 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+WebInspector.Int32Array = function()
+{
+ const preallocateSize = 1000;
+ 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 +100,7 @@
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 +120,7 @@
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 +174,9 @@
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("");
@@ -709,6 +734,7 @@
{
this.uid = profile.snapshot.uid;
this._nodes = profile.nodes;
+ this._metaNode = profile.metaNode;
this._strings = profile.strings;
this._init();
@@ -717,9 +743,8 @@
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");