Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: Source/devtools/front_end/timeline/TimelineJSProfile.js

Issue 1204473005: DevTools: Tweak v8 code objects name parsing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/common/ParsedURL.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 WebInspector.TimelineJSProfileProcessor = { }; 6 WebInspector.TimelineJSProfileProcessor = { };
7 7
8 /** 8 /**
9 * @param {!ProfilerAgent.CPUProfile} jsProfile 9 * @param {!ProfilerAgent.CPUProfile} jsProfile
10 * @param {!WebInspector.TracingModel.Thread} thread 10 * @param {!WebInspector.TracingModel.Thread} thread
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 this._entries.splice(index, lastIndex - index, newEntry); 305 this._entries.splice(index, lastIndex - index, newEntry);
306 } 306 }
307 } 307 }
308 308
309 /** 309 /**
310 * @param {!Array<!WebInspector.TracingModel.Event>} events 310 * @param {!Array<!WebInspector.TracingModel.Event>} events
311 * @return {!Array<!WebInspector.TracingModel.Event>} 311 * @return {!Array<!WebInspector.TracingModel.Event>}
312 */ 312 */
313 WebInspector.TimelineJSProfileProcessor.processRawV8Samples = function(events) 313 WebInspector.TimelineJSProfileProcessor.processRawV8Samples = function(events)
314 { 314 {
315 var unknownFrame = { 315 var missingAddesses = new Set();
316 functionName: "(unknown)", 316
317 url: "", 317 /**
318 scriptId: "0", 318 * @param {string} functionName
319 lineNumber: 0, 319 * @param {string=} url
320 columnNumber: 0 320 * @param {string=} scriptId
321 }; 321 * @param {number=} line
322 * @param {number=} column
323 * @return {!ConsoleAgent.CallFrame}
324 */
325 function createFrame(functionName, url, scriptId, line, column)
326 {
327 return /** @type {!ConsoleAgent.CallFrame} */ ({
328 "functionName": functionName,
329 "url": url || "",
330 "scriptId": scriptId || "0",
331 "lineNumber": line || 0,
332 "columnNumber": column || 0
333 });
334 }
335
322 /** 336 /**
323 * @param {string} address 337 * @param {string} address
324 * @return {!ConsoleAgent.CallFrame} 338 * @return {!ConsoleAgent.CallFrame}
325 */ 339 */
326 function convertRawFrame(address) 340 function convertRawFrame(address)
327 { 341 {
328 return codeMap.lookupEntry(address) || unknownFrame; 342 var entry = codeMap.lookupEntry(address);
343 if (entry)
344 return entry;
345 if (!missingAddesses.has(address)) {
346 missingAddesses.add(address);
347 console.error("Address " + address + " has missing code entry");
348 }
349 return createFrame(address);
329 } 350 }
330 351
331 // Code states: 352 // Code states:
332 // (empty) -> compiled 353 // (empty) -> compiled
333 // ~ -> optimizable 354 // ~ -> optimizable
334 // * -> optimized 355 // * -> optimized
335 var reName = /^(\S*:)?[*~]?(\S*)(?: (\S*))?$/; 356 var rePrefix = /^(\w*:)?[*~]?(.*)$/m;
336 357
337 /** 358 /**
338 * @param {string} name 359 * @param {string} name
339 * @param {number} scriptId 360 * @param {number} scriptId
340 * @return {!ConsoleAgent.CallFrame} 361 * @return {!ConsoleAgent.CallFrame}
341 */ 362 */
342 function buildCallFrame(name, scriptId) 363 function buildCallFrame(name, scriptId)
343 { 364 {
344 var parsed = reName.exec(name); 365 var tokens = rePrefix.exec(name);
345 if (!parsed) 366 if (!tokens || tokens.length < 3) {
yurys 2015/06/23 17:09:56 This condition seems to always be false.
alph 2015/06/23 17:38:13 Done.
346 return unknownFrame; 367 console.error("Cannot parse function name " + name);
347 var functionName = parsed[2] || ""; 368 return createFrame(name);
348 var urlData = WebInspector.ParsedURL.splitLineAndColumn(parsed[3] || "") ; 369 }
349 var url = urlData && urlData.url || ""; 370 var prefix = tokens[1];
350 var line = urlData && urlData.lineNumber || 0; 371 var body = tokens[2];
351 var column = urlData && urlData.columnNumber || 0; 372 var rawName;
352 var frame = { 373 var rawUrl;
353 "functionName": functionName, 374 if (prefix === "Script:") {
354 "url": url, 375 rawName = "";
355 "scriptId": String(scriptId), 376 rawUrl = body;
356 "lineNumber": line, 377 } else {
357 "columnNumber": column 378 var spacePos = body.lastIndexOf(" ");
358 }; 379 rawName = spacePos !== -1 ? body.substr(0, spacePos) : body;
359 return frame; 380 rawUrl = spacePos !== -1 ? body.substr(spacePos + 1) : "";
381 }
382 var functionName = rawName;
383 var urlData = WebInspector.ParsedURL.splitLineAndColumn(rawUrl);
384 var url = urlData.url || "";
385 var line = urlData.lineNumber || 0;
386 var column = urlData.columnNumber || 0;
387 return createFrame(functionName, url, String(scriptId), line, column);
360 } 388 }
361 389
362 var recordTypes = WebInspector.TimelineModel.RecordType; 390 var recordTypes = WebInspector.TimelineModel.RecordType;
363 var samples = []; 391 var samples = [];
364 var codeMap = new WebInspector.TimelineJSProfileProcessor.CodeMap(); 392 var codeMap = new WebInspector.TimelineJSProfileProcessor.CodeMap();
365 for (var i = 0; i < events.length; ++i) { 393 for (var i = 0; i < events.length; ++i) {
366 var e = events[i]; 394 var e = events[i];
367 var data = e.args["data"]; 395 var data = e.args["data"];
368 switch (e.name) { 396 switch (e.name) {
369 case recordTypes.JitCodeAdded: 397 case recordTypes.JitCodeAdded:
(...skipping 15 matching lines...) Expand all
385 WebInspector.TracingModel.Phase.Instant, e.startTime, e.thread); 413 WebInspector.TracingModel.Phase.Instant, e.startTime, e.thread);
386 sampleEvent.ordinal = e.ordinal; 414 sampleEvent.ordinal = e.ordinal;
387 sampleEvent.args = {"data": {"stackTrace": stack }}; 415 sampleEvent.args = {"data": {"stackTrace": stack }};
388 samples.push(sampleEvent); 416 samples.push(sampleEvent);
389 break; 417 break;
390 } 418 }
391 } 419 }
392 420
393 return samples; 421 return samples;
394 } 422 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/common/ParsedURL.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698