2011-04-22 Mikhail Naganov <mnaganov@chromium.org>
authormnaganov@chromium.org <mnaganov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2011 13:52:13 +0000 (13:52 +0000)
committermnaganov@chromium.org <mnaganov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2011 13:52:13 +0000 (13:52 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: [Chromium] Move detailed heap snapshots storage and processing into workers.
        https://bugs.webkit.org/show_bug.cgi?id=59094

        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * gyp/streamline-inspector-source.sh:
        * inspector/front-end/DetailedHeapshotGridNodes.js:
        (WebInspector.HeapSnapshotGridNode.prototype.dispose):
        (WebInspector.HeapSnapshotObjectNode.prototype._createProvider):
        (WebInspector.HeapSnapshotInstanceNode.prototype._createProvider):
        (WebInspector.HeapSnapshotConstructorNode.prototype._createNodesProvider):
        (WebInspector.HeapSnapshotIteratorsTuple.prototype.dispose):
        (WebInspector.HeapSnapshotDiffNode.prototype.calculateDiff.diffCalculated):
        (WebInspector.HeapSnapshotDiffNode.prototype._createNodesProvider.createProvider):
        (WebInspector.HeapSnapshotDiffNode.prototype._createNodesProvider):
        (WebInspector.HeapSnapshotDominatorObjectNode.prototype._createProvider):
        (MixInSnapshotNodeFunctions):
        * inspector/front-end/DetailedHeapshotView.js:
        (WebInspector.HeapSnapshotSortableDataGrid.prototype.dispose):
        (WebInspector.HeapSnapshotSortableDataGrid.prototype.resetSortingCache):
        (WebInspector.HeapSnapshotDiffDataGrid.prototype.setBaseDataSource):
        (WebInspector.HeapSnapshotRetainingPathsList.prototype.dispose):
        (WebInspector.HeapSnapshotRetainingPathsList.prototype._resetPaths):
        (WebInspector.HeapSnapshotRetainingPathsList.prototype.setDataSource):
        (WebInspector.HeapSnapshotRetainingPathsList.prototype.showNext):
        (WebInspector.HeapSnapshotRetainingPathsList.prototype.searchCancelled):
        (WebInspector.HeapSnapshotRetainingPathsList.prototype._setRootChildrenForFinder):
        (WebInspector.DetailedHeapshotView.prototype.dispose):
        (WebInspector.DetailedHeapshotView.prototype.get profileWrapper):
        (WebInspector.DetailedHeapshotView.prototype.get baseProfileWrapper):
        * inspector/front-end/HeapSnapshot.js:
        (WebInspector.HeapSnapshotLoader):
        (WebInspector.HeapSnapshotLoader.prototype.finishLoading):
        (WebInspector.HeapSnapshotLoader.prototype.pushJSONChunk):
        (WebInspector.HeapSnapshot.prototype.pushBaseIds):
        (WebInspector.HeapSnapshot.prototype.createDiff):
        (WebInspector.HeapSnapshot.prototype._parseFilter):
        (WebInspector.HeapSnapshot.prototype.createEdgesProvider):
        (WebInspector.HeapSnapshot.prototype.createNodesProvider):
        (WebInspector.HeapSnapshot.prototype.createPathFinder):
        (WebInspector.HeapSnapshot.prototype.updateStaticData):
        (WebInspector.HeapSnapshotPathFinder):
        (WebInspector.HeapSnapshotPathFinder.prototype.updateRoots):
        (WebInspector.HeapSnapshotPathFinder.prototype._reset):
        * inspector/front-end/HeapSnapshotProxy.js:
        (WebInspector.HeapSnapshotRealWorker):
        (WebInspector.HeapSnapshotRealWorker.prototype._messageReceived):
        (WebInspector.HeapSnapshotRealWorker.prototype.postMessage):
        (WebInspector.HeapSnapshotRealWorker.prototype.terminate):
        (WebInspector.HeapSnapshotFakeWorker):
        (WebInspector.HeapSnapshotFakeWorker.prototype.postMessage):
        (WebInspector.HeapSnapshotFakeWorker.prototype.terminate):
        (WebInspector.HeapSnapshotFakeWorker.prototype._postMessageFromWorker):
        (WebInspector.HeapSnapshotWorker):
        (WebInspector.HeapSnapshotWorker.prototype.createObject):
        (WebInspector.HeapSnapshotWorker.prototype.dispose):
        (WebInspector.HeapSnapshotWorker.prototype.disposeObject):
        (WebInspector.HeapSnapshotWorker.prototype.callGetter):
        (WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod.wrapCallback):
        (WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod):
        (WebInspector.HeapSnapshotWorker.prototype.callMethod):
        (WebInspector.HeapSnapshotWorker.prototype._findFunction):
        (WebInspector.HeapSnapshotWorker.prototype._messageReceived):
        (WebInspector.HeapSnapshotWorker.prototype._postMessage):
        (WebInspector.HeapSnapshotProxyObject):
        (WebInspector.HeapSnapshotProxyObject.prototype._callWorker):
        (WebInspector.HeapSnapshotProxyObject.prototype.dispose):
        (WebInspector.HeapSnapshotProxyObject.prototype.disposeWorker):
        (WebInspector.HeapSnapshotProxyObject.prototype.callFactoryMethod):
        (WebInspector.HeapSnapshotProxyObject.prototype.callGetter):
        (WebInspector.HeapSnapshotProxyObject.prototype.callMethod):
        (WebInspector.HeapSnapshotLoaderProxy):
        (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading.callLoadCallbacks):
        (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading.updateStaticData):
        (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading):
        (WebInspector.HeapSnapshotLoaderProxy.prototype.get loaded):
        (WebInspector.HeapSnapshotLoaderProxy.prototype.startLoading):
        (WebInspector.HeapSnapshotLoaderProxy.prototype.pushJSONChunk):
        (WebInspector.HeapSnapshotProxy):
        (WebInspector.HeapSnapshotProxy.prototype.aggregates):
        (WebInspector.HeapSnapshotProxy.prototype.createDiff):
        (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
        (WebInspector.HeapSnapshotProxy.prototype.createNodesProvider):
        (WebInspector.HeapSnapshotProxy.prototype.createPathFinder):
        (WebInspector.HeapSnapshotProxy.prototype.dispose):
        (WebInspector.HeapSnapshotProxy.prototype.finishLoading):
        (WebInspector.HeapSnapshotProxy.prototype.get loaded):
        (WebInspector.HeapSnapshotProxy.prototype.get nodeCount):
        (WebInspector.HeapSnapshotProxy.prototype.nodeFieldValuesByIndex):
        (WebInspector.HeapSnapshotProxy.prototype.pushBaseIds):
        (WebInspector.HeapSnapshotProxy.prototype.get rootNodeIndex):
        (WebInspector.HeapSnapshotProxy.prototype.updateStaticData):
        (WebInspector.HeapSnapshotProxy.prototype.startLoading):
        (WebInspector.HeapSnapshotProxy.prototype.get totalSize):
        (WebInspector.HeapSnapshotProxy.prototype.get uid):
        (WebInspector.HeapSnapshotProviderProxy):
        (WebInspector.HeapSnapshotProviderProxy.prototype.isEmpty):
        (WebInspector.HeapSnapshotProviderProxy.prototype.serializeNextItems):
        (WebInspector.HeapSnapshotProviderProxy.prototype.sortAndRewind):
        (WebInspector.HeapSnapshotPathFinderProxy):
        (WebInspector.HeapSnapshotPathFinderProxy.prototype.findNext):
        (WebInspector.HeapSnapshotPathFinderProxy.prototype.updateRoots):
        (WebInspector.HeapSnapshotsDiffProxy):
        (WebInspector.HeapSnapshotsDiffProxy.prototype.calculate):
        (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseIds):
        (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseSelfSizes):
        * inspector/front-end/HeapSnapshotWorker.js: Added.
        (WebInspector.UIString):
        (postMessageWrapper):
        * inspector/front-end/HeapSnapshotWorkerDispatcher.js: Added.
        (WebInspector.HeapSnapshotWorkerDispatcher):
        (WebInspector.HeapSnapshotWorkerDispatcher.prototype._findFunction):
        (WebInspector.HeapSnapshotWorkerDispatcher.prototype.dispatchMessage):
        * inspector/front-end/ProfilesPanel.js:
        (WebInspector.ProfilesPanel.prototype.loadHeapSnapshot):
        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot.else.parsed):
        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.html:

2011-04-22  Mikhail Naganov  <mnaganov@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: [Chromium] Move detailed heap snapshots storage and processing into workers.
        https://bugs.webkit.org/show_bug.cgi?id=59094

        * WebKit.gyp:

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/gyp/streamline-inspector-source.sh
Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js
Source/WebCore/inspector/front-end/DetailedHeapshotView.js
Source/WebCore/inspector/front-end/HeapSnapshot.js
Source/WebCore/inspector/front-end/HeapSnapshotProxy.js
Source/WebCore/inspector/front-end/HeapSnapshotWorker.js [new file with mode: 0644]
Source/WebCore/inspector/front-end/HeapSnapshotWorkerDispatcher.js [new file with mode: 0644]
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/WebKit.qrc
Source/WebCore/inspector/front-end/inspector.html
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp

index 7e7a292..81e06b2 100644 (file)
@@ -1,3 +1,127 @@
+2011-04-22  Mikhail Naganov  <mnaganov@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Chromium] Move detailed heap snapshots storage and processing into workers.
+        https://bugs.webkit.org/show_bug.cgi?id=59094
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * gyp/streamline-inspector-source.sh:
+        * inspector/front-end/DetailedHeapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGridNode.prototype.dispose):
+        (WebInspector.HeapSnapshotObjectNode.prototype._createProvider):
+        (WebInspector.HeapSnapshotInstanceNode.prototype._createProvider):
+        (WebInspector.HeapSnapshotConstructorNode.prototype._createNodesProvider):
+        (WebInspector.HeapSnapshotIteratorsTuple.prototype.dispose):
+        (WebInspector.HeapSnapshotDiffNode.prototype.calculateDiff.diffCalculated):
+        (WebInspector.HeapSnapshotDiffNode.prototype._createNodesProvider.createProvider):
+        (WebInspector.HeapSnapshotDiffNode.prototype._createNodesProvider):
+        (WebInspector.HeapSnapshotDominatorObjectNode.prototype._createProvider):
+        (MixInSnapshotNodeFunctions):
+        * inspector/front-end/DetailedHeapshotView.js:
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.dispose):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.resetSortingCache):
+        (WebInspector.HeapSnapshotDiffDataGrid.prototype.setBaseDataSource):
+        (WebInspector.HeapSnapshotRetainingPathsList.prototype.dispose):
+        (WebInspector.HeapSnapshotRetainingPathsList.prototype._resetPaths):
+        (WebInspector.HeapSnapshotRetainingPathsList.prototype.setDataSource):
+        (WebInspector.HeapSnapshotRetainingPathsList.prototype.showNext):
+        (WebInspector.HeapSnapshotRetainingPathsList.prototype.searchCancelled):
+        (WebInspector.HeapSnapshotRetainingPathsList.prototype._setRootChildrenForFinder):
+        (WebInspector.DetailedHeapshotView.prototype.dispose):
+        (WebInspector.DetailedHeapshotView.prototype.get profileWrapper):
+        (WebInspector.DetailedHeapshotView.prototype.get baseProfileWrapper):
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshotLoader):
+        (WebInspector.HeapSnapshotLoader.prototype.finishLoading):
+        (WebInspector.HeapSnapshotLoader.prototype.pushJSONChunk):
+        (WebInspector.HeapSnapshot.prototype.pushBaseIds):
+        (WebInspector.HeapSnapshot.prototype.createDiff):
+        (WebInspector.HeapSnapshot.prototype._parseFilter):
+        (WebInspector.HeapSnapshot.prototype.createEdgesProvider):
+        (WebInspector.HeapSnapshot.prototype.createNodesProvider):
+        (WebInspector.HeapSnapshot.prototype.createPathFinder):
+        (WebInspector.HeapSnapshot.prototype.updateStaticData):
+        (WebInspector.HeapSnapshotPathFinder):
+        (WebInspector.HeapSnapshotPathFinder.prototype.updateRoots):
+        (WebInspector.HeapSnapshotPathFinder.prototype._reset):
+        * inspector/front-end/HeapSnapshotProxy.js:
+        (WebInspector.HeapSnapshotRealWorker):
+        (WebInspector.HeapSnapshotRealWorker.prototype._messageReceived):
+        (WebInspector.HeapSnapshotRealWorker.prototype.postMessage):
+        (WebInspector.HeapSnapshotRealWorker.prototype.terminate):
+        (WebInspector.HeapSnapshotFakeWorker):
+        (WebInspector.HeapSnapshotFakeWorker.prototype.postMessage):
+        (WebInspector.HeapSnapshotFakeWorker.prototype.terminate):
+        (WebInspector.HeapSnapshotFakeWorker.prototype._postMessageFromWorker):
+        (WebInspector.HeapSnapshotWorker):
+        (WebInspector.HeapSnapshotWorker.prototype.createObject):
+        (WebInspector.HeapSnapshotWorker.prototype.dispose):
+        (WebInspector.HeapSnapshotWorker.prototype.disposeObject):
+        (WebInspector.HeapSnapshotWorker.prototype.callGetter):
+        (WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod.wrapCallback):
+        (WebInspector.HeapSnapshotWorker.prototype.callFactoryMethod):
+        (WebInspector.HeapSnapshotWorker.prototype.callMethod):
+        (WebInspector.HeapSnapshotWorker.prototype._findFunction):
+        (WebInspector.HeapSnapshotWorker.prototype._messageReceived):
+        (WebInspector.HeapSnapshotWorker.prototype._postMessage):
+        (WebInspector.HeapSnapshotProxyObject):
+        (WebInspector.HeapSnapshotProxyObject.prototype._callWorker):
+        (WebInspector.HeapSnapshotProxyObject.prototype.dispose):
+        (WebInspector.HeapSnapshotProxyObject.prototype.disposeWorker):
+        (WebInspector.HeapSnapshotProxyObject.prototype.callFactoryMethod):
+        (WebInspector.HeapSnapshotProxyObject.prototype.callGetter):
+        (WebInspector.HeapSnapshotProxyObject.prototype.callMethod):
+        (WebInspector.HeapSnapshotLoaderProxy):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading.callLoadCallbacks):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading.updateStaticData):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.get loaded):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.startLoading):
+        (WebInspector.HeapSnapshotLoaderProxy.prototype.pushJSONChunk):
+        (WebInspector.HeapSnapshotProxy):
+        (WebInspector.HeapSnapshotProxy.prototype.aggregates):
+        (WebInspector.HeapSnapshotProxy.prototype.createDiff):
+        (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createNodesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createPathFinder):
+        (WebInspector.HeapSnapshotProxy.prototype.dispose):
+        (WebInspector.HeapSnapshotProxy.prototype.finishLoading):
+        (WebInspector.HeapSnapshotProxy.prototype.get loaded):
+        (WebInspector.HeapSnapshotProxy.prototype.get nodeCount):
+        (WebInspector.HeapSnapshotProxy.prototype.nodeFieldValuesByIndex):
+        (WebInspector.HeapSnapshotProxy.prototype.pushBaseIds):
+        (WebInspector.HeapSnapshotProxy.prototype.get rootNodeIndex):
+        (WebInspector.HeapSnapshotProxy.prototype.updateStaticData):
+        (WebInspector.HeapSnapshotProxy.prototype.startLoading):
+        (WebInspector.HeapSnapshotProxy.prototype.get totalSize):
+        (WebInspector.HeapSnapshotProxy.prototype.get uid):
+        (WebInspector.HeapSnapshotProviderProxy):
+        (WebInspector.HeapSnapshotProviderProxy.prototype.isEmpty):
+        (WebInspector.HeapSnapshotProviderProxy.prototype.serializeNextItems):
+        (WebInspector.HeapSnapshotProviderProxy.prototype.sortAndRewind):
+        (WebInspector.HeapSnapshotPathFinderProxy):
+        (WebInspector.HeapSnapshotPathFinderProxy.prototype.findNext):
+        (WebInspector.HeapSnapshotPathFinderProxy.prototype.updateRoots):
+        (WebInspector.HeapSnapshotsDiffProxy):
+        (WebInspector.HeapSnapshotsDiffProxy.prototype.calculate):
+        (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseIds):
+        (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseSelfSizes):
+        * inspector/front-end/HeapSnapshotWorker.js: Added.
+        (WebInspector.UIString):
+        (postMessageWrapper):
+        * inspector/front-end/HeapSnapshotWorkerDispatcher.js: Added.
+        (WebInspector.HeapSnapshotWorkerDispatcher):
+        (WebInspector.HeapSnapshotWorkerDispatcher.prototype._findFunction):
+        (WebInspector.HeapSnapshotWorkerDispatcher.prototype.dispatchMessage):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.loadHeapSnapshot):
+        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot.else.parsed):
+        (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2011-04-22  Pavel Podivilov  <podivilov@chromium.org>
 
         Reviewed by Pavel Feldman.
index 7d6f6ec..8950051 100644 (file)
             'inspector/front-end/HeapSnapshot.js',
             'inspector/front-end/HeapSnapshotProxy.js',
             'inspector/front-end/HeapSnapshotView.js',
+            'inspector/front-end/HeapSnapshotWorker.js',
+            'inspector/front-end/HeapSnapshotWorkerDispatcher.js',
             'inspector/front-end/HelpScreen.js',
             'inspector/front-end/ImageView.js',
             'inspector/front-end/InspectorFrontendHostStub.js',
index d50c53a..523a92b 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\HeapSnapshotWorker.js"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\inspector\front-end\HeapSnapshotWorkerDispatcher.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\helpScreen.css"
                                        >
                                </File>
index 6611554..b5a1c5a 100755 (executable)
@@ -8,6 +8,9 @@ fi
 # Combine all script resources in the inspector.html file.
 "$SRCROOT/../inspector/combine-javascript-resources.pl" --input-html "${SRCROOT}/../inspector/front-end/inspector.html" --generated-scripts-dir ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore --output-dir "${DERIVED_FILE_DIR}/WebCore" --output-script-name inspector.js
 
+# Inline script imports in HeapSnapshotWorker.js file.
+"$SRCROOT/../inspector/inline-javascript-imports.py" "${SRCROOT}/../inspector/front-end/HeapSnapshotWorker.js" "${SRCROOT}/../inspector/front-end" "${DERIVED_FILE_DIR}/WebCore/HeapSnapshotWorker.js"
+
 # Inline script imports in ScriptFormatterWorker.js file.
 "$SRCROOT/../inspector/inline-javascript-imports.py" "${SRCROOT}/../inspector/front-end/ScriptFormatterWorker.js" "${SRCROOT}/../inspector/front-end" "${DERIVED_FILE_DIR}/WebCore/scriptFormatterWorker.js"
 
@@ -19,5 +22,6 @@ if [ -d "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector" ];
     # Copy the modified HTML file and the combined scripts.
     cp "${DERIVED_FILE_DIR}/WebCore/inspector.html" inspector.html
     cp "${DERIVED_FILE_DIR}/WebCore/inspector.js" inspector.js
+    cp "${DERIVED_FILE_DIR}/WebCore/HeapSnapshotWorker.js" HeapSnapshotWorker.js
     cp "${DERIVED_FILE_DIR}/WebCore/scriptFormatterWorker.js" scriptFormatterWorker.js
 fi
index 7e29349..e44df28 100644 (file)
@@ -45,6 +45,15 @@ WebInspector.HeapSnapshotGridNode.prototype = {
         return cell;
     },
 
+    dispose: function()
+    {
+        if (this._provider)
+            this._provider.dispose();
+        for (var node = this.children[0]; node; node = node.traverseNextNode(true, this, true))
+            if (node.dispose)
+                node.dispose();
+    },
+
     _populate: function(event)
     {
         this.removeEventListener("populate", this._populate, this);
@@ -275,10 +284,10 @@ WebInspector.HeapSnapshotObjectNode.prototype = {
         var showHiddenData = WebInspector.DetailedHeapshotView.prototype.showHiddenData;
         return snapshot.createEdgesProvider(
             nodeIndex,
-            function(edge) {
-                return !edge.isInvisible
-                    && (showHiddenData || (!edge.isHidden && !edge.node.isHidden));
-            });
+            "function(edge) {" +
+            "    return !edge.isInvisible" +
+            "        && (" + showHiddenData + " || (!edge.isHidden && !edge.node.isHidden));" +
+            "}");
     },
 
     _childHashForEntity: function(edge)
@@ -362,10 +371,10 @@ WebInspector.HeapSnapshotInstanceNode.prototype = {
         var showHiddenData = WebInspector.DetailedHeapshotView.prototype.showHiddenData;
         return snapshot.createEdgesProvider(
             nodeIndex,
-            function(edge) {
-                return !edge.isInvisible
-                    && (showHiddenData || (!edge.isHidden && !edge.node.isHidden));
-            });
+            "function(edge) {" +
+            "    return !edge.isInvisible" +
+            "        && (" + showHiddenData + " || (!edge.isHidden && !edge.node.isHidden));" +
+            "}");
     },
 
     _childHashForEntity: function(edge)
@@ -441,10 +450,10 @@ WebInspector.HeapSnapshotConstructorNode.prototype = {
     _createNodesProvider: function(snapshot, nodeType, nodeClassName)
     {
         return snapshot.createNodesProvider(
-            function (node) {
-                 return node.type === nodeType
-                    && (nodeClassName === null || node.className === nodeClassName);
-            });
+            "function (node) {" + 
+            "     return node.type === \"" + nodeType + "\" " +
+            (nodeClassName !== null ? "&& node.className === \"" + nodeClassName + "\"" : "") +
+            "}");
     },
 
     comparator: function()
@@ -505,6 +514,12 @@ WebInspector.HeapSnapshotIteratorsTuple = function(it1, it2)
 }
 
 WebInspector.HeapSnapshotIteratorsTuple.prototype = {
+    dispose: function()
+    {
+        this._it1.dispose();
+        this._it2.dispose();
+    },
+
     sortAndRewind: function(comparator, callback)
     {
         function afterSort(ignored)
@@ -531,6 +546,7 @@ WebInspector.HeapSnapshotDiffNode.prototype = {
         
         function diffCalculated(diffResult)
         {
+            diff.dispose();
             this._addedCount = diffResult.addedCount;
             this._removedCount = diffResult.removedCount;
             this._countDelta = diffResult.countDelta;
@@ -578,11 +594,11 @@ WebInspector.HeapSnapshotDiffNode.prototype = {
         {
             var otherSnapshotId = otherSnapshot.uid;
             var provider = snapshot.createNodesProvider(
-                function (node) {
-                     return node.type === nodeType
-                         && (nodeClassName === null || node.className === nodeClassName)
-                         && !this.baseSnapshotHasNode(otherSnapshotId, className, node.id);
-                });
+                "function (node) {" +
+                "     return node.type === \"" + nodeType + "\" " +
+                (nodeClassName !== null ? "&& node.className === \"" + nodeClassName + "\"" : "") +
+                "         && !this.baseSnapshotHasNode(" + otherSnapshotId + ", \"" + className + "\", node.id);" +
+                "}");
             provider.snapshot = snapshot;
             return provider;
         }
@@ -676,12 +692,12 @@ WebInspector.HeapSnapshotDominatorObjectNode.prototype = {
     {
         var showHiddenData = WebInspector.DetailedHeapshotView.prototype.showHiddenData;
         return snapshot.createNodesProvider(
-            function (node) {
-                 var dominatorIndex = node.dominatorIndex;
-                 return dominatorIndex === nodeIndex
-                     && dominatorIndex !== node.nodeIndex
-                     && (showHiddenData || !node.isHidden);
-            });
+            "function (node) {" +
+            "     var dominatorIndex = node.dominatorIndex;" +
+            "     return dominatorIndex === " + nodeIndex + 
+            "         && dominatorIndex !== node.nodeIndex" +
+            "         && (" + showHiddenData + " || !node.isHidden);" +
+            "}");
     },
 
     _childHashForEntity: function(node)
@@ -721,6 +737,7 @@ function MixInSnapshotNodeFunctions(sourcePrototype, targetPrototype)
     targetPrototype.comparator = sourcePrototype.comparator;
     targetPrototype._createChildNode = sourcePrototype._createChildNode;
     targetPrototype._createProvider = sourcePrototype._createProvider;
+    targetPrototype.dispose = sourcePrototype.dispose;
     targetPrototype.populateChildren = sourcePrototype.populateChildren;
     targetPrototype._saveChildren = sourcePrototype._saveChildren;
     targetPrototype.sort = sourcePrototype.sort;
index 7c0466a..4d4104e 100644 (file)
@@ -35,6 +35,18 @@ WebInspector.HeapSnapshotSortableDataGrid = function(columns)
 }
 
 WebInspector.HeapSnapshotSortableDataGrid.prototype = {
+    dispose: function()
+    {
+        for (var i = 0, l = this.children.length; i < l; ++i)
+            this.children[i].dispose();
+    },
+
+    resetSortingCache: function()
+    {
+        delete this._lastSortColumnIdentifier;
+        delete this._lastSortAscending;
+    },
+
     sortingChanged: function()
     {
         var sortAscending = this.sortOrder === "ascending";
@@ -222,7 +234,9 @@ WebInspector.HeapSnapshotDiffDataGrid.prototype = {
     setBaseDataSource: function(baseSnapshot)
     {
         this.baseSnapshot = baseSnapshot;
+        this.dispose();
         this.removeChildren();
+        this.resetSortingCache();
         if (this.baseSnapshot === this.snapshot) {
             this.dispatchEventToListeners("sorting complete");
             return;
@@ -307,6 +321,12 @@ WebInspector.HeapSnapshotRetainingPathsList = function()
 }
 
 WebInspector.HeapSnapshotRetainingPathsList.prototype = {
+    dispose: function()
+    {
+        if (this.pathFinder)
+            this.pathFinder.dispose();
+    }, 
+
     _sortFields: function(sortColumn, sortAscending)
     {
         return {
@@ -319,6 +339,7 @@ WebInspector.HeapSnapshotRetainingPathsList.prototype = {
     {
         this._setRootChildrenForFinder();
         this.removeChildren();
+        this.resetSortingCache();
         this._counter = 0;
         this.showNext(this._defaultPopulateCount);
     },
@@ -328,9 +349,11 @@ WebInspector.HeapSnapshotRetainingPathsList.prototype = {
         this.snapshotView = snapshotView;
         this._prefix = prefix;
 
-        if (this.pathFinder)
+        if (this.pathFinder) {
             this.searchCancelled();
-        this.pathFinder = snapshot.createPathFinder(nodeIndex);
+            this.pathFinder.dispose();
+        }
+        this.pathFinder = snapshot.createPathFinder(nodeIndex, !WebInspector.DetailedHeapshotView.prototype.showHiddenData);
         this._resetPaths();
     },
 
@@ -372,7 +395,7 @@ WebInspector.HeapSnapshotRetainingPathsList.prototype = {
                 delete this._cancel;
             }
         }
-        setTimeout(startSearching.bind(this), 0);
+        startSearching.call(this);
     },
 
     searchCancelled: function(pathsCount)
@@ -382,19 +405,16 @@ WebInspector.HeapSnapshotRetainingPathsList.prototype = {
         this._cancel = this.pathFinder;
         if (pathsCount) {
             this.appendChild(new WebInspector.ShowMoreDataGridNode(this.showNext.bind(this), pathsCount));
+            this.resetSortingCache();
             this.sortingChanged();
         }
     },
 
     _setRootChildrenForFinder: function()
     {
-        function FilterDOMWindow(node)
-        {
-            return node.name === "DOMWindow";
-        }
-
         if (this.snapshotView.isTracingToWindowObjects)
-            this.pathFinder.updateRoots(FilterDOMWindow);
+            this.pathFinder.updateRoots(
+                "function (node) { return node.name === \"DOMWindow\"; }");
         else
             this.pathFinder.updateRoots();
     },
@@ -534,10 +554,14 @@ WebInspector.DetailedHeapshotView = function(parent, profile)
 WebInspector.DetailedHeapshotView.prototype = {
     dispose: function()
     {
-        if (this._profileWrapper)
-            this._profileWrapper.dispose();
-        if (this._baseProfileWrapper)
-            this._baseProfileWrapper.dispose();
+        this.profileWrapper.dispose();
+        if (this.baseProfile)
+            this.baseProfileWrapper.dispose();
+        this.containmentDataGrid.dispose();
+        this.constructorsDataGrid.dispose();
+        this.diffDataGrid.dispose();
+        this.dominatorDataGrid.dispose();
+        this.retainmentDataGrid.dispose();
     },
 
     get statusBarItems()
@@ -552,9 +576,7 @@ WebInspector.DetailedHeapshotView.prototype = {
 
     get profileWrapper()
     {
-        if (!this._profileWrapper)
-            this._profileWrapper = this.profile.proxy;
-        return this._profileWrapper;
+        return this.profile.proxy;
     },
 
     get baseProfile()
@@ -564,9 +586,7 @@ WebInspector.DetailedHeapshotView.prototype = {
 
     get baseProfileWrapper()
     {
-        if (!this._baseProfileWrapper)
-            this._baseProfileWrapper = this.baseProfile.proxy;
-        return this._baseProfileWrapper;
+        return this.baseProfile.proxy;
     },
 
     show: function(parentElement)
index 600cbb2..277fda9 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+WebInspector.HeapSnapshotLoader = function()
+{
+    this._json = "";
+}
+
+WebInspector.HeapSnapshotLoader.prototype = {
+    finishLoading: function()
+    {
+        if (!this._json)
+            return null;
+        var rawSnapshot = JSON.parse(this._json);
+        this._json = "";
+        return new WebInspector.HeapSnapshot(rawSnapshot);
+    },
+
+    pushJSONChunk: function(chunk)
+    {
+        this._json += chunk;
+    }
+};
+
 WebInspector.HeapSnapshotArraySlice = function(snapshot, arrayName, start, end)
 {
     // Note: we don't reference snapshot contents directly to avoid
@@ -751,13 +772,46 @@ WebInspector.HeapSnapshot.prototype = {
         return this._baseNodeIds[baseSnapshotId][className].binaryIndexOf(nodeId, this._numbersComparator) !== -1;
     },
 
-    pushBaseNodeIds: function(baseSnapshotId, className, nodeIds)
+    pushBaseIds: function(baseSnapshotId, className, nodeIds)
     {
         if (!this._baseNodeIds)
             this._baseNodeIds = [];
         if (!this._baseNodeIds[baseSnapshotId])
             this._baseNodeIds[baseSnapshotId] = {};
         this._baseNodeIds[baseSnapshotId][className] = nodeIds;
+    },
+
+    createDiff: function(className)
+    {
+        return new WebInspector.HeapSnapshotsDiff(this, className);
+    },
+
+    _parseFilter: function(filter)
+    {
+        if (!filter)
+            return null;
+        var parsedFilter = eval("(function(){return " + filter + "})()");
+        return parsedFilter.bind(this);
+    },
+
+    createEdgesProvider: function(nodeIndex, filter)
+    {
+        return new WebInspector.HeapSnapshotEdgesProvider(this, nodeIndex, this._parseFilter(filter));
+    },
+
+    createNodesProvider: function(filter)
+    {
+        return new WebInspector.HeapSnapshotNodesProvider(this, this._parseFilter(filter));
+    },
+
+    createPathFinder: function(targetNodeIndex, skipHidden)
+    {
+        return new WebInspector.HeapSnapshotPathFinder(this, targetNodeIndex, skipHidden);
+    },
+
+    updateStaticData: function()
+    {
+        return {nodeCount: this.nodeCount, rootNodeIndex: this._rootNodeIndex, totalSize: this.totalSize, uid: this.uid};
     }
 };
 
@@ -994,14 +1048,14 @@ WebInspector.HeapSnapshotNodesProvider.prototype = {
 
 WebInspector.HeapSnapshotNodesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype;
 
-WebInspector.HeapSnapshotPathFinder = function(snapshot, targetNodeIndex)
+WebInspector.HeapSnapshotPathFinder = function(snapshot, targetNodeIndex, skipHidden)
 {
     this._snapshot = snapshot;
     this._maxLength = 1;
     this._lengthLimit = 15;
     this._targetNodeIndex = targetNodeIndex;
     this._currentPath = null;
-    this._skipHidden = !WebInspector.DetailedHeapshotView.prototype.showHiddenData;
+    this._skipHidden = skipHidden;
     this._rootChildren = this._fillRootChildren();
 }
 
@@ -1025,7 +1079,16 @@ WebInspector.HeapSnapshotPathFinder.prototype = {
 
     updateRoots: function(filter)
     {
+        if (filter)
+            filter = eval("(function(){return " + filter + "})()");
         this._rootChildren = this._fillRootChildren(filter);  
+        this._reset();
+    },
+
+    _reset: function()
+    {
+        this._maxLength = 1;
+        this._currentPath = null;
     },
 
     _fillRootChildren: function(filter)
index 6c49ce7..9863d89 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.HeapSnapshotProxy = function()
-{   
-    this._snapshot = null;
+WebInspector.HeapSnapshotRealWorker = function()
+{
+    this._worker = new Worker("HeapSnapshotWorker.js");
+    this._worker.addEventListener("message", this._messageReceived.bind(this), false);
 }
 
-WebInspector.HeapSnapshotProxy.prototype = {
-    _invokeGetter: function(getterName, callback)
+WebInspector.HeapSnapshotRealWorker.prototype = {
+    _messageReceived: function(event)
     {
-        function returnResult()
-        {
-            callback(this._snapshot[getterName]);
-        }
-        setTimeout(returnResult.bind(this), 0);
+        this.dispatchEventToListeners("message", event.data);
     },
 
-    aggregates: function(withNodeIndexes, callback)
+    postMessage: function(message)
+    {
+        this._worker.postMessage(message);
+    },
+
+    terminate: function()
+    {
+        this._worker.terminate();
+    }
+};
+
+WebInspector.HeapSnapshotRealWorker.prototype.__proto__ = WebInspector.Object.prototype;
+
+WebInspector.HeapSnapshotFakeWorker = function()
+{
+    this._dispatcher = new WebInspector.HeapSnapshotWorkerDispatcher(window, this._postMessageFromWorker.bind(this));
+}
+
+WebInspector.HeapSnapshotFakeWorker.prototype = {
+    postMessage: function(message)
     {
-        function returnResult()
+        function dispatch()
         {
-            callback(this._snapshot.aggregates(withNodeIndexes));
+            this._dispatcher.dispatchMessage({data: message});
         }
-        setTimeout(returnResult.bind(this), 0);
+        setTimeout(dispatch.bind(this), 0);
     },
 
-    createDiff: function(className)
+    terminate: function()
     {
-        return new WebInspector.HeapSnapshotsDiffProxy(new WebInspector.HeapSnapshotsDiff(this._snapshot, className));
+        this._dispatcher = null;
     },
 
-    createEdgesProvider: function(nodeIndex, filter)
+    _postMessageFromWorker: function(message)
     {
-        function createProvider()
+        function send()
         {
-            if (filter)
-                filter = filter.bind(this._snapshot);
-            return new WebInspector.HeapSnapshotEdgesProvider(this._snapshot, nodeIndex, filter);
+            this.dispatchEventToListeners("message", message);
         }
-        return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this));
+        setTimeout(send.bind(this), 0);
+    }
+};
+
+WebInspector.HeapSnapshotFakeWorker.prototype.__proto__ = WebInspector.Object.prototype;
+
+WebInspector.HeapSnapshotWorker = function()
+{
+    this._nextObjectId = 1;
+    this._nextCallId = 1;
+    this._callbacks = [];
+    // There is no support for workers in Chromium DRT.
+    this._worker = typeof InspectorTest === "undefined" ? new WebInspector.HeapSnapshotRealWorker() : new WebInspector.HeapSnapshotFakeWorker();
+    this._worker.addEventListener("message", this._messageReceived.bind(this), false);
+}
+
+WebInspector.HeapSnapshotWorker.prototype = {
+    createObject: function(constructorName)
+    {
+        var proxyConstructorFunction = this._findFunction(constructorName + "Proxy");
+        var objectId = this._nextObjectId++;
+        var proxy = new proxyConstructorFunction(this, objectId);
+        this._postMessage({callId: this._nextCallId++, disposition: "create", objectId: objectId, methodName: constructorName});
+        return proxy;
     },
 
-    createNodesProvider: function(filter)
+    dispose: function()
     {
-        function createProvider()
-        {
-            if (filter)
-                filter = filter.bind(this._snapshot);
-            return new WebInspector.HeapSnapshotNodesProvider(this._snapshot, filter);
+        this._worker.terminate();
+    },
+
+    disposeObject: function(objectId)
+    {
+        this._postMessage({callId: this._nextCallId++, disposition: "dispose", objectId: objectId});
+    },
+
+    callGetter: function(callback, objectId, getterName)
+    {
+        var callId = this._nextCallId++;
+        this._callbacks[callId] = callback;
+        this._postMessage({callId: callId, disposition: "getter", objectId: objectId, methodName: getterName});
+    },
+
+    callFactoryMethod: function(callback, objectId, methodName, proxyConstructorName)
+    {
+        var callId = this._nextCallId++;
+        var methodArguments = Array.prototype.slice.call(arguments, 4);
+        var newObjectId = this._nextObjectId++;
+        var proxyConstructorFunction = this._findFunction(proxyConstructorName);
+        if (callback) {
+            function wrapCallback(remoteResult)
+            {
+                callback(remoteResult ? new proxyConstructorFunction(this, newObjectId) : null);
+            }
+            this._callbacks[callId] = wrapCallback.bind(this);
+            this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId: newObjectId});
+            return null;
+        } else {
+            this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId: newObjectId});
+            return new proxyConstructorFunction(this, newObjectId);
         }
-        return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this));
     },
 
-    createPathFinder: function(targetNodeIndex)
+    callMethod: function(callback, objectId, methodName)
     {
-        return new WebInspector.HeapSnapshotPathFinderProxy(new WebInspector.HeapSnapshotPathFinder(this._snapshot, targetNodeIndex));
+        var callId = this._nextCallId++;
+        var methodArguments = Array.prototype.slice.call(arguments, 3);
+        if (callback)
+            this._callbacks[callId] = callback;
+        this._postMessage({callId: callId, disposition: "method", objectId: objectId, methodName: methodName, methodArguments: methodArguments});
+    },
+
+    _findFunction: function(name)
+    {
+        var path = name.split(".");
+        var result = window;
+        for (var i = 0; i < path.length; ++i)
+            result = result[path[i]];
+        return result;
+    },
+
+    _messageReceived: function(event)
+    {
+        var data = event.data;
+        if (!this._callbacks[data.callId])
+            return;
+        var callback = this._callbacks[data.callId];
+        delete this._callbacks[data.callId];
+        callback(data.result);
+    },
+
+    _postMessage: function(message)
+    {
+        this._worker.postMessage(message);      
+    }
+};
+
+WebInspector.HeapSnapshotProxyObject = function(worker, objectId)
+{
+    this._worker = worker;
+    this._objectId = objectId;
+}
+
+WebInspector.HeapSnapshotProxyObject.prototype = {
+    _callWorker: function(workerMethodName, args)
+    {
+        args.splice(1, 0, this._objectId);
+        return this._worker[workerMethodName].apply(this._worker, args);
     },
 
     dispose: function()
     {
-        this._snapshot.dispose();
+        this._worker.disposeObject(this._objectId);
+    },
+
+    disposeWorker: function()
+    {
+        this._worker.dispose();
+    },
+
+    callFactoryMethod: function(callback, methodName, proxyConstructorName)
+    {
+        return this._callWorker("callFactoryMethod", Array.prototype.slice.call(arguments, 0));
+    },
+
+    callGetter: function(callback, getterName)
+    {
+        return this._callWorker("callGetter", Array.prototype.slice.call(arguments, 0));
     },
 
+    callMethod: function(callback, methodName)
+    {
+        return this._callWorker("callMethod", Array.prototype.slice.call(arguments, 0));
+    }
+};
+
+WebInspector.HeapSnapshotLoaderProxy = function(worker, objectId)
+{
+    WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
+    this._loading = false;
+    this._loaded = false;
+}
+
+WebInspector.HeapSnapshotLoaderProxy.prototype = {
     finishLoading: function(callback)
     {
-        if (this._snapshot || !this._isLoading)
+        if (!this._loading)
             return false;
-        function parse() {
-            var rawSnapshot = JSON.parse(this._json);
-            var loadCallbacks = this._onLoadCallbacks;
-            loadCallbacks.splice(0, 0, callback);
-            delete this._onLoadCallback;
-            delete this._json;
-            delete this._isLoading;
-            this._snapshot = new WebInspector.HeapSnapshot(rawSnapshot);
-            this._nodeCount = this._snapshot.nodeCount;
-            this._rootNodeIndex = this._snapshot._rootNodeIndex;
-            this._totalSize = this._snapshot.totalSize;
+        var loadCallbacks = this._onLoadCallbacks;
+        loadCallbacks.splice(0, 0, callback);
+        delete this._onLoadCallbacks;
+        this._loading = false;
+        this._loaded = true;
+        function callLoadCallbacks(snapshotProxy)
+        {
             for (var i = 0; i < loadCallbacks.length; ++i)
-                loadCallbacks[i]();
+                loadCallbacks[i](snapshotProxy);
+        }
+        function updateStaticData(snapshotProxy)
+        {
+            this.dispose();
+            snapshotProxy.updateStaticData(callLoadCallbacks);
         }
-        setTimeout(parse.bind(this), 0);
+        this.callFactoryMethod(updateStaticData.bind(this), "finishLoading", "WebInspector.HeapSnapshotProxy");
         return true;
     },
 
     get loaded()
     {
-        return !!this._snapshot;
-    },
-
-    get nodeCount()
-    {
-        return this._nodeCount;
+        return this._loaded;
     },
 
-    nodeFieldValuesByIndex: function(fieldName, indexes, callback)
+    startLoading: function(callback)
     {
-        function returnResult()
-        {
-            callback(this._snapshot.nodeFieldValuesByIndex(fieldName, indexes));
+        if (!this._loading) {
+            this._onLoadCallbacks = [callback];
+            this._loading = true;
+            return true;
+        } else {
+            this._onLoadCallbacks.push(callback);
+            return false;
         }
-        setTimeout(returnResult.bind(this), 0);
     },
 
     pushJSONChunk: function(chunk)
     {
-        if (this.loaded || !this._isLoading)
+        if (!this._loading)
             return;
-        this._json += chunk;
+        this.callMethod(null, "pushJSONChunk", chunk);
+    }
+};
+
+WebInspector.HeapSnapshotLoaderProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype;
+
+WebInspector.HeapSnapshotProxy = function(worker, objectId)
+{
+    WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
+}
+
+WebInspector.HeapSnapshotProxy.prototype = {
+    aggregates: function(withNodeIndexes, callback)
+    {
+        this.callMethod(callback, "aggregates", withNodeIndexes);
+    },
+
+    createDiff: function(className)
+    {
+        return this.callFactoryMethod(null, "createDiff",  "WebInspector.HeapSnapshotsDiffProxy", className);
+    },
+
+    createEdgesProvider: function(nodeIndex, filter)
+    {
+        return this.callFactoryMethod(null, "createEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, filter);
+    },
+
+    createNodesProvider: function(filter)
+    {
+        return this.callFactoryMethod(null, "createNodesProvider", "WebInspector.HeapSnapshotProviderProxy", filter);
+    },
+
+    createPathFinder: function(targetNodeIndex)
+    {
+        return this.callFactoryMethod(null, "createPathFinder", "WebInspector.HeapSnapshotPathFinderProxy", targetNodeIndex);
+    },
+
+    dispose: function()
+    {
+        this.disposeWorker();
+    },
+
+    finishLoading: function()
+    {
+        return false;
+    },
+
+    get loaded()
+    {
+        return !!this._objectId;
+    },
+
+    get nodeCount()
+    {
+        return this._staticData.nodeCount;
+    },
+
+    nodeFieldValuesByIndex: function(fieldName, indexes, callback)
+    {
+        this.callMethod(callback, "nodeFieldValuesByIndex", fieldName, indexes);
     },
 
     pushBaseIds: function(snapshotId, className, nodeIds)
     {
-        this._snapshot.pushBaseNodeIds(snapshotId, className, nodeIds);
+        this.callMethod(null, "pushBaseIds", snapshotId, className, nodeIds);
     },
 
     get rootNodeIndex()
     {
-        return this._rootNodeIndex;
+        return this._staticData.rootNodeIndex;
     },
 
-    startLoading: function(callback)
+    updateStaticData: function(callback)
     {
-        if (this._snapshot) {
-            function asyncInvoke()
-            {
-                callback();
-            }
-            setTimeout(callback, 0);
-            return false;
-        } else if (this._isLoading) {
-            this._onLoadCallbacks.push(callback);
-            return false;
-        } else {
-            this._isLoading = true;
-            this._onLoadCallbacks = [callback];
-            this._json = "";
-            return true;
+        function dataReceived(staticData)
+        {
+            this._staticData = staticData;
+            callback(this);
         }
+        this.callMethod(dataReceived.bind(this), "updateStaticData");
+    },
+
+    startLoading: function(callback)
+    {
+        setTimeout(callback, 0);
+        return false;
     },
 
     get totalSize()
     {
-        return this._totalSize;
+        return this._staticData.totalSize;
     },
 
     get uid()
     {
-        return this._snapshot.uid;
+        return this._staticData.uid;
     }
 };
 
-WebInspector.HeapSnapshotProviderProxy = function(createProvider)
+WebInspector.HeapSnapshotProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype;
+
+WebInspector.HeapSnapshotProviderProxy = function(worker, objectId)
 {
-    this._provider = createProvider();
+    WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
 }
 
 WebInspector.HeapSnapshotProviderProxy.prototype = {
-    serializeNextItems: function(count, callback)
+    isEmpty: function(callback)
     {
-        function returnResult()
-        {
-            callback(this._provider.serializeNextItems(count));
-        }
-        setTimeout(returnResult.bind(this), 0);
+        this.callGetter(callback, "isEmpty");
     },
 
-    isEmpty: function(callback)
+    serializeNextItems: function(count, callback)
     {
-        function returnResult()
-        {
-            callback(this._provider.isEmpty);
-        }
-        setTimeout(returnResult.bind(this), 0);
+        this.callMethod(callback, "serializeNextItems", count);
     },
 
     sortAndRewind: function(comparator, callback)
     {
-        function returnResult()
-        {
-            callback(this._provider.sortAndRewind(comparator));
-        }
-        setTimeout(returnResult.bind(this), 0);
+        this.callMethod(callback, "sortAndRewind", comparator);
     }
 };
 
-WebInspector.HeapSnapshotPathFinderProxy = function(pathFinder)
+WebInspector.HeapSnapshotProviderProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype;
+
+WebInspector.HeapSnapshotPathFinderProxy = function(worker, objectId)
 {
-    this._pathFinder = pathFinder;
+    WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
 }
 
 WebInspector.HeapSnapshotPathFinderProxy.prototype = {
     findNext: function(callback)
     {
-        function returnResult()
-        {
-            callback(this._pathFinder.findNext());
-        }
-        setTimeout(returnResult.bind(this), 0);
+        this.callMethod(callback, "findNext");
     },
 
     updateRoots: function(filter)
     {
-        function asyncInvoke()
-        {
-            this._pathFinder.updateRoots(filter);
-        }
-        setTimeout(asyncInvoke.bind(this), 0);
+        this.callMethod(null, "updateRoots", filter);
     }
 };
 
-WebInspector.HeapSnapshotsDiffProxy = function(diff)
+WebInspector.HeapSnapshotPathFinderProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype;
+
+WebInspector.HeapSnapshotsDiffProxy = function(worker, objectId)
 {
-    this._diff = diff;
+    WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId);
 }
 
 WebInspector.HeapSnapshotsDiffProxy.prototype = {
     calculate: function(callback)
     {
-        function returnResult()
-        {
-            callback(this._diff.calculate());
-        }
-        setTimeout(returnResult.bind(this), 0);
+        this.callMethod(callback, "calculate");
     },
 
     pushBaseIds: function(baseIds)
     {
-        this._diff.pushBaseIds(baseIds);
+        this.callMethod(null, "pushBaseIds", baseIds);
     },
 
     pushBaseSelfSizes: function(baseSelfSizes)
     {
-        this._diff.pushBaseSelfSizes(baseSelfSizes);
+        this.callMethod(null, "pushBaseSelfSizes", baseSelfSizes);
     }
 };
+
+WebInspector.HeapSnapshotsDiffProxy.prototype.__proto__ = WebInspector.HeapSnapshotProxyObject.prototype;
diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotWorker.js b/Source/WebCore/inspector/front-end/HeapSnapshotWorker.js
new file mode 100644 (file)
index 0000000..ea48f29
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector = {};
+WebInspector.UIString = function(s) { return s; };
+
+importScripts("BinarySearch.js");
+importScripts("HeapSnapshot.js");
+importScripts("HeapSnapshotWorkerDispatcher.js");
+
+function postMessageWrapper(message)
+{
+    postMessage(message);
+}
+
+var dispatcher = new WebInspector.HeapSnapshotWorkerDispatcher(this, postMessageWrapper);
+addEventListener("message", dispatcher.dispatchMessage.bind(dispatcher), false);
diff --git a/Source/WebCore/inspector/front-end/HeapSnapshotWorkerDispatcher.js b/Source/WebCore/inspector/front-end/HeapSnapshotWorkerDispatcher.js
new file mode 100644 (file)
index 0000000..1f32ec2
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.HeapSnapshotWorkerDispatcher = function(globalObject, postMessage)
+{
+    this._objects = [];
+    this._global = globalObject;
+    this._postMessage = postMessage;
+}
+
+WebInspector.HeapSnapshotWorkerDispatcher.prototype = {
+    _findFunction: function(name)
+    {
+        var path = name.split(".");
+        var result = this._global;
+        for (var i = 0; i < path.length; ++i)
+            result = result[path[i]];
+        return result;
+    },
+
+    dispatchMessage: function(event)
+    {
+        var data = event.data;
+        switch (data.disposition) {
+            case "create": {
+                var constructorFunction = this._findFunction(data.methodName);
+                this._objects[data.objectId] = new constructorFunction();
+                this._postMessage({callId: data.callId});
+                break;
+            }
+            case "dispose": {
+                delete this._objects[data.objectId];
+                this._postMessage({callId: data.callId});
+                break;
+            }
+            case "getter": {
+                var object = this._objects[data.objectId];
+                var result = object[data.methodName];
+                this._postMessage({callId: data.callId, result: result});
+                break;
+            }
+            case "factory": {
+                var object = this._objects[data.objectId];
+                var result = object[data.methodName].apply(object, data.methodArguments);
+                if (result)
+                    this._objects[data.newObjectId] = result;            
+                this._postMessage({callId: data.callId, result: !!result});
+                break;
+            }
+            case "method": {
+                var object = this._objects[data.objectId];
+                var result = object[data.methodName].apply(object, data.methodArguments);
+                this._postMessage({callId: data.callId, result: result});
+                break;
+            }
+        }
+    }
+};
index 6e6e697..fdd2017 100644 (file)
@@ -459,7 +459,7 @@ WebInspector.ProfilesPanel.prototype = {
             }
         } else {
             if (!profile.proxy)
-                profile.proxy = new WebInspector.HeapSnapshotProxy();
+                profile.proxy = (new WebInspector.HeapSnapshotWorker()).createObject("WebInspector.HeapSnapshotLoader");
             var proxy = profile.proxy;
             if (proxy.startLoading(callback)) {
                 profile.sideBarElement.subtitle = WebInspector.UIString("Loading\u2026");
@@ -517,9 +517,10 @@ WebInspector.ProfilesPanel.prototype = {
             if (!profile.proxy)
                 return;
             var proxy = profile.proxy;
-            function parsed()
+            function parsed(snapshotProxy)
             {
-                profile.sideBarElement.subtitle = Number.bytesToString(proxy.totalSize);
+                profile.proxy = snapshotProxy;
+                profile.sideBarElement.subtitle = Number.bytesToString(snapshotProxy.totalSize);
             }
             if (proxy.finishLoading(parsed))
                 profile.sideBarElement.subtitle = WebInspector.UIString("Parsing\u2026");
index dbe5aa4..5a20b9a 100644 (file)
@@ -53,6 +53,8 @@
     <file>HeapSnapshot.js</file>
     <file>HeapSnapshotProxy.js</file>
     <file>HeapSnapshotView.js</file>
+    <file>HeapSnapshotWorker.js</file>
+    <file>HeapSnapshotWorkerDispatcher.js</file>
     <file>HelpScreen.js</file>
     <file>ImageView.js</file>
     <file>InjectedFakeWorker.js</file>
index 1ed3be8..0bc2b7b 100644 (file)
@@ -143,6 +143,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="HeapSnapshot.js"></script>
     <script type="text/javascript" src="HeapSnapshotProxy.js"></script>
     <script type="text/javascript" src="HeapSnapshotView.js"></script>
+    <script type="text/javascript" src="HeapSnapshotWorkerDispatcher.js"></script>
     <script type="text/javascript" src="DetailedHeapshotGridNodes.js"></script>
     <script type="text/javascript" src="DetailedHeapshotView.js"></script>
     <script type="text/javascript" src="DebuggerModel.js"></script>
index f4a9018..72d4b05 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-22  Mikhail Naganov  <mnaganov@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: [Chromium] Move detailed heap snapshots storage and processing into workers.
+        https://bugs.webkit.org/show_bug.cgi?id=59094
+
+        * WebKit.gyp:
+
 2011-04-22  Andrey Kosyakov  <caseq@chromium.org>
 
         Reviewed by Pavel Feldman.
index 0ee5dd6..2a20349 100644 (file)
             'conditions': [
                 ['debug_devtools==0', {
                     'dependencies': ['concatenated_devtools_js',
+                                     'concatenated_heap_snapshot_worker_js',
                                      'concatenated_script_formatter_worker_js',
                                      'concatenated_devtools_css'],
                 },{
                 'input_pages': [
                     '<(PRODUCT_DIR)/resources/inspector/devtools.html',
                     '<(PRODUCT_DIR)/resources/inspector/DevTools.js',
+                    '<(PRODUCT_DIR)/resources/inspector/HeapSnapshotWorker.js',
                     '<(PRODUCT_DIR)/resources/inspector/ScriptFormatterWorker.js',
                     '<(PRODUCT_DIR)/resources/inspector/devTools.css',
                 ],
                     }],
                 },
                 {
+                    'target_name': 'concatenated_heap_snapshot_worker_js',
+                    'type': 'none',
+                    'actions': [{
+                        'action_name': 'concatenate_heap_snapshot_worker_js',
+                        'script_name': 'scripts/inline_js_imports.py',
+                        'input_file': '../../WebCore/inspector/front-end/HeapSnapshotWorker.js',
+                        'inputs': [
+                            '<@(_script_name)',
+                            '../../WebCore/inspector/front-end/BinarySearch.js',
+                            '../../WebCore/inspector/front-end/HeapSnapshot.js',
+                            '../../WebCore/inspector/front-end/HeapSnapshotWorkerDispatcher.js',
+                        ],
+                        'search_path': '../../WebCore/inspector/front-end',
+                        'outputs': ['<(PRODUCT_DIR)/resources/inspector/HeapSnapshotWorker.js'],
+                        'action': ['python', '<@(_script_name)', '<@(_input_file)', '<@(_search_path)', '<@(_outputs)'],
+                    }],
+                },
+                {
                     'target_name': 'concatenated_script_formatter_worker_js',
                     'type': 'none',
                     'actions': [{