author | Panos Astithas <past@mozilla.com> |
Wed, 20 Mar 2013 09:48:35 +0200 | |
changeset 125730 | f2f57f88ecdfa87c6d272b0e4cdb2897d967e216 |
parent 125729 | 2f092e92dd1eed18e4982e730bf2560598104385 |
child 125731 | a4742ca5ca32fcec7abad7518274167e765e15fe |
push id | 25087 |
push user | eakhgari@mozilla.com |
push date | Thu, 21 Mar 2013 12:27:40 +0000 |
treeherder | mozilla-inbound@be6da6dbf632 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | vporof |
bugs | 852860 |
milestone | 22.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/devtools/debugger/server/dbg-script-actors.js +++ b/toolkit/devtools/debugger/server/dbg-script-actors.js @@ -28,36 +28,16 @@ function ThreadActor(aHooks, aGlobal) { this._state = "detached"; this._frameActors = []; this._environmentActors = []; this._hooks = aHooks; this._sources = {}; this.global = aGlobal; - /** - * A script cache that maps script URLs to arrays of different Debugger.Script - * instances that have the same URL. For example, when an inline <script> tag - * in a web page contains a function declaration, the JS engine creates two - * Debugger.Script objects, one for the function and one for the script tag - * as a whole. The two objects will usually have different startLine and/or - * lineCount properties. For the edge case where two scripts are contained in - * the same line we need column support. - * - * The sparse array that is mapped to each URL serves as an additional mapping - * from startLine numbers to Debugger.Script objects, facilitating retrieval - * of the scripts that contain a particular line number. For example, if a - * cache holds two scripts with the URL http://foo.com/ starting at lines 4 - * and 10, then the corresponding cache will be: - * this._scripts: { - * 'http://foo.com/': [,,,,[Debugger.Script],,,,,,[Debugger.Script]] - * } - */ - this._scripts = {}; - // A cache of prototype chains for objects that have received a // prototypeAndProperties request. Due to the way the debugger frontend works, // this corresponds to a cache of prototype chains that the user has been // inspecting in the variables tree view. This allows the debugger to evaluate // native getter methods for WebIDL attributes that are meant to be called on // the instace and not on the prototype. // // The map keys are Debugger.Object instances requested by the client and the @@ -94,17 +74,16 @@ ThreadActor.prototype = { }, clearDebuggees: function TA_clearDebuggees() { if (this.dbg) { this.dbg.removeAllDebuggees(); } this.conn.removeActorPool(this._threadLifetimePool || undefined); this._threadLifetimePool = null; - this._scripts = {}; this._sources = {}; }, /** * Add a debuggee global to the Debugger object. */ addDebuggee: function TA_addDebuggee(aGlobal) { try { @@ -485,17 +464,17 @@ ThreadActor.prototype = { onSetBreakpoint: function TA_onSetBreakpoint(aRequest) { if (this.state !== "paused") { return { error: "wrongState", message: "Breakpoints can only be set while the debuggee is paused."}; } let location = aRequest.location; let line = location.line; - if (!this._scripts[location.url] || line < 0) { + if (this.dbg.findScripts({ url: location.url }).length == 0 || line < 0) { return { error: "noScript" }; } // Add the breakpoint to the store for later reuse, in case it belongs to a // script that hasn't appeared yet. if (!this._breakpointStore[location.url]) { this._breakpointStore[location.url] = []; } @@ -609,45 +588,16 @@ ThreadActor.prototype = { return { error: "noCodeAtLineColumn", actor: actor.actorID }; }, /** - * A recursive generator function for iterating over the scripts that contain - * the specified line, by looking through child scripts of the supplied - * script. As an example, an inline <script> tag has the top-level functions - * declared in it as its children. - * - * @param aScript Debugger.Script - * The source script. - * @param aLine number - * The line number. - */ - _getContainers: function TA__getContainers(aScript, aLine) { - let children = aScript.getChildScripts(); - if (children.length > 0) { - for (let i = 0; i < children.length; i++) { - let child = children[i]; - // Iterate over the children that contain this location. - if (child.startLine <= aLine && - child.startLine + child.lineCount > aLine) { - for (let j of this._getContainers(child, aLine)) { - yield j; - } - } - } - } - // Include this script in the iteration, too. - yield aScript; - }, - - /** * Get the script and source lists from the debugger. */ _discoverScriptsAndSources: function TA__discoverScriptsAndSources() { for (let s of this.dbg.findScripts()) { this._addScript(s); } }, @@ -1183,23 +1133,16 @@ ThreadActor.prototype = { if (!this._allowSource(aScript.url)) { return false; } // TODO bug 637572: we should be dealing with sources directly, not // inferring them through scripts. this._addSource(aScript.url); - // Use a sparse array for storing the scripts for each URL in order to - // optimize retrieval. - if (!this._scripts[aScript.url]) { - this._scripts[aScript.url] = []; - } - this._scripts[aScript.url][aScript.startLine] = aScript; - // Set any stored breakpoints. let existing = this._breakpointStore[aScript.url]; if (existing) { let endLine = aScript.startLine + aScript.lineCount - 1; // Iterate over the lines backwards, so that sliding breakpoints don't // affect the loop. for (let line = existing.length - 1; line >= 0; line--) { let bp = existing[line];
--- a/toolkit/devtools/debugger/tests/unit/testcompatactors.js +++ b/toolkit/devtools/debugger/tests/unit/testcompatactors.js @@ -28,30 +28,27 @@ function createRootActor() threadActor: actor.thread.actorID }; }; actor.thread.requestTypes["scripts"] = function (aRequest) { this._discoverScriptsAndSources(); let scripts = []; - for (let url in this._scripts) { - for (let i = 0; i < this._scripts[url].length; i++) { - if (!this._scripts[url][i]) { - continue; - } - - let script = { - url: url, - startLine: i, - lineCount: this._scripts[url][i].lineCount, - source: this._getSource(url).form() - }; - scripts.push(script); + for (let s of this.dbg.findScripts()) { + if (!s.url) { + continue; } + let script = { + url: s.url, + startLine: s.startLine, + lineCount: s.lineCount, + source: this._getSource(s.url).form() + }; + scripts.push(script); } return { from: this.actorID, scripts: scripts }; };