Changeset 116077 in webkit


Ignore:
Timestamp:
May 4, 2012 2:10:09 AM (12 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: createRawLocationByURL is too slow if a big number of evals happen.
https://bugs.webkit.org/show_bug.cgi?id=85477

It iterates through all the _scripts even they have no url.
We can keep a separate map of scripts with url.

Reviewed by Yury Semikhatsky.

Source/WebCore:

  • inspector/front-end/DebuggerModel.js:

(WebInspector.DebuggerModel):
(WebInspector.DebuggerModel.prototype._globalObjectCleared):
(WebInspector.DebuggerModel.prototype._resetScriptsMap):
(WebInspector.DebuggerModel.prototype._parsedScriptSource):
(WebInspector.DebuggerModel.prototype.createRawLocationByURL):

LayoutTests:

  • http/tests/inspector/compiler-script-mapping.html:
  • http/tests/inspector/debugger-test.js:

(initialize_DebuggerTest):

  • inspector/debugger/raw-source-code.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116076 r116077  
     12012-05-03  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: createRawLocationByURL is too slow if a big number of evals happen.
     4        https://bugs.webkit.org/show_bug.cgi?id=85477
     5
     6        It iterates through all the _scripts even they have no url.
     7        We can keep a separate map of scripts with url.
     8
     9        Reviewed by Yury Semikhatsky.
     10
     11        * http/tests/inspector/compiler-script-mapping.html:
     12        * http/tests/inspector/debugger-test.js:
     13        (initialize_DebuggerTest):
     14        * inspector/debugger/raw-source-code.html:
     15
    1162012-05-04  Sudarsana Nagineni  <sudarsana.nagineni@linux.intel.com>
    217
  • trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html

    r114241 r116077  
    125125        function testCompilerScriptMapping(next)
    126126        {
    127             WebInspector.debuggerModel._scripts = [];
     127            WebInspector.debuggerModel._reset();
    128128            var mapping = new WebInspector.CompilerScriptMapping();
    129129            var script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
     
    161161        function testInlinedSourceMap(next)
    162162        {
    163             WebInspector.debuggerModel._scripts = [];
     163            WebInspector.debuggerModel._reset();
    164164            var mapping = new WebInspector.CompilerScriptMapping();
    165165            var script = InspectorTest.createScriptMock("http://example.com/compiled.js", 0, 0, true, "");
     
    192192        {
    193193            WebInspector.settings.sourceMapsEnabled.set(true);
    194             WebInspector.debuggerModel._scripts = [];
     194            WebInspector.debuggerModel._reset();
    195195            var mainScriptMapping = new WebInspector.MainScriptMapping();
    196196            mainScriptMapping.addEventListener(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, uiSourceCodeListChanged);
  • trunk/LayoutTests/http/tests/inspector/debugger-test.js

    r115979 r116077  
    292292    var script = new WebInspector.Script(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript);
    293293    script.requestContent = function(callback) { callback(source); };
    294     WebInspector.debuggerModel._scripts[scriptId] = script;
     294    WebInspector.debuggerModel._registerScript(script);
    295295    return script;
    296296}
  • trunk/LayoutTests/inspector/debugger/raw-source-code.html

    r115979 r116077  
    9393        function testScriptWithoutResource(next)
    9494        {
    95             WebInspector.debuggerModel._scripts = [];
     95            WebInspector.debuggerModel._reset();
    9696            var script = InspectorTest.createScriptMock("foo.js", 0, 0, true, "<script source>");
    9797            var rawSourceCode = createRawSourceCode(script, null);
     
    114114        function testHTMLWithPendingResource(next)
    115115        {
    116             WebInspector.debuggerModel._scripts = [];
     116            WebInspector.debuggerModel._reset();
    117117            var script1 = InspectorTest.createScriptMock("index.html", 0, 10, false, "<script source 1>");
    118118            var script2 = InspectorTest.createScriptMock("index.html", 0, 45, false, "<script source 2>");
     
    148148        function testHTMLWithFinishedResource(next)
    149149        {
    150             WebInspector.debuggerModel._scripts = [];
     150            WebInspector.debuggerModel._reset();
    151151            var script1 = InspectorTest.createScriptMock("index.html", 1, 10, false, "<script source 1>");
    152152            var script2 = InspectorTest.createScriptMock("index.html", 5, 45, false, "<script\nsource\n2>");
     
    177177        function testForceUpdateSourceMapping(next)
    178178        {
    179             WebInspector.debuggerModel._scripts = [];
     179            WebInspector.debuggerModel._reset();
    180180            var script1 = InspectorTest.createScriptMock("index.html", 0, 10, false, "<script source 1>");
    181181            var script2 = InspectorTest.createScriptMock("index.html", 0, 45, false, "<script source 2>");
     
    244244        function testFormattingWithFinishedResource(next)
    245245        {
    246             WebInspector.debuggerModel._scripts = [];
     246            WebInspector.debuggerModel._reset();
    247247            var script = InspectorTest.createScriptMock("foo.js", 0, 0, true, "<script source>");
    248248            var request = createFinishedRequestMock("script", "<resource content>");
     
    303303        function testFormattingWithPendingResource(next)
    304304        {
    305             WebInspector.debuggerModel._scripts = [];
     305            WebInspector.debuggerModel._reset();
    306306            var script = InspectorTest.createScriptMock("foo.js", 0, 0, true, "<script source>");
    307307            var request = createPendingRequestMock("script", "<resource content>");
  • trunk/Source/WebCore/ChangeLog

    r116069 r116077  
     12012-05-03  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: createRawLocationByURL is too slow if a big number of evals happen.
     4        https://bugs.webkit.org/show_bug.cgi?id=85477
     5
     6        It iterates through all the _scripts even they have no url.
     7        We can keep a separate map of scripts with url.
     8
     9        Reviewed by Yury Semikhatsky.
     10
     11        * inspector/front-end/DebuggerModel.js:
     12        (WebInspector.DebuggerModel):
     13        (WebInspector.DebuggerModel.prototype._globalObjectCleared):
     14        (WebInspector.DebuggerModel.prototype._resetScriptsMap):
     15        (WebInspector.DebuggerModel.prototype._parsedScriptSource):
     16        (WebInspector.DebuggerModel.prototype.createRawLocationByURL):
     17
    1182012-05-03  David Barr  <davidbarr@chromium.org>
    219
  • trunk/Source/WebCore/inspector/front-end/DebuggerModel.js

    r115984 r116077  
    4040     */
    4141    this._scripts = {};
     42    this._scriptsBySourceURL = {};
    4243
    4344    this._canSetScriptSource = false;
     
    150151        // Adjust column if needed.
    151152        var minColumnNumber = 0;
    152         for (var id in this._scripts) {
    153             var script = this._scripts[id];
    154             if (url === script.sourceURL && lineNumber === script.lineOffset)
     153        var scripts = this._scriptsBySourceURL[url] || [];
     154        for (var i = 0, l = scripts.length; i < l; ++i) {
     155            var script = scripts[i];
     156            if (lineNumber === script.lineOffset)
    155157                minColumnNumber = minColumnNumber ? Math.min(minColumnNumber, script.columnOffset) : script.columnOffset;
    156158        }
     
    215217    {
    216218        this._setDebuggerPausedDetails(null);
     219        this._reset();
     220        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalObjectCleared);
     221    },
     222
     223    _reset: function()
     224    {
    217225        this._scripts = {};
    218         this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalObjectCleared);
     226        this._scriptsBySourceURL = {};
    219227    },
    220228
     
    323331    {
    324332        var script = new WebInspector.Script(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL);
    325         this._scripts[scriptId] = script;
     333        this._registerScript(script);
    326334        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
     335    },
     336
     337    /**
     338     * @param {WebInspector.Script} script
     339     */
     340    _registerScript: function(script)
     341    {
     342        this._scripts[script.scriptId] = script;
     343        if (script.sourceURL) {
     344            var scripts = this._scriptsBySourceURL[script.sourceURL];
     345            if (!scripts) {
     346                scripts = [];
     347                this._scriptsBySourceURL[script.sourceURL] = scripts;
     348            }
     349            scripts.push(script);
     350        }
    327351    },
    328352
     
    362386    {
    363387        var closestScript = null;
    364         for (var scriptId in this._scripts) {
    365             var script = this._scripts[scriptId];
    366             if (script.sourceURL !== sourceURL)
    367                 continue;
     388        var scripts = this._scriptsBySourceURL[sourceURL] || [];
     389        for (var i = 0, l = scripts.length; i < l; ++i) {
     390            var script = scripts[i];
    368391            if (!closestScript)
    369392                closestScript = script;
Note: See TracChangeset for help on using the changeset viewer.