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
+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.
'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',
>
</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>
# 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"
# 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
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);
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)
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)
_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()
}
WebInspector.HeapSnapshotIteratorsTuple.prototype = {
+ dispose: function()
+ {
+ this._it1.dispose();
+ this._it2.dispose();
+ },
+
sortAndRewind: function(comparator, callback)
{
function afterSort(ignored)
function diffCalculated(diffResult)
{
+ diff.dispose();
this._addedCount = diffResult.addedCount;
this._removedCount = diffResult.removedCount;
this._countDelta = diffResult.countDelta;
{
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;
}
{
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)
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;
}
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";
setBaseDataSource: function(baseSnapshot)
{
this.baseSnapshot = baseSnapshot;
+ this.dispose();
this.removeChildren();
+ this.resetSortingCache();
if (this.baseSnapshot === this.snapshot) {
this.dispatchEventToListeners("sorting complete");
return;
}
WebInspector.HeapSnapshotRetainingPathsList.prototype = {
+ dispose: function()
+ {
+ if (this.pathFinder)
+ this.pathFinder.dispose();
+ },
+
_sortFields: function(sortColumn, sortAscending)
{
return {
{
this._setRootChildrenForFinder();
this.removeChildren();
+ this.resetSortingCache();
this._counter = 0;
this.showNext(this._defaultPopulateCount);
},
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();
},
delete this._cancel;
}
}
- setTimeout(startSearching.bind(this), 0);
+ startSearching.call(this);
},
searchCancelled: function(pathsCount)
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();
},
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()
get profileWrapper()
{
- if (!this._profileWrapper)
- this._profileWrapper = this.profile.proxy;
- return this._profileWrapper;
+ return this.profile.proxy;
},
get baseProfile()
get baseProfileWrapper()
{
- if (!this._baseProfileWrapper)
- this._baseProfileWrapper = this.baseProfile.proxy;
- return this._baseProfileWrapper;
+ return this.baseProfile.proxy;
},
show: function(parentElement)
* 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
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};
}
};
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();
}
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)
* 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;
--- /dev/null
+/*
+ * 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);
--- /dev/null
+/*
+ * 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;
+ }
+ }
+ }
+};
}
} 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");
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");
<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>
<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>
+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.
'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': [{