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

Side by Side Diff: tools/logreader.js

Issue 574015: Profiler tick processor: exploit d8's readline to avoid reading (Closed)
Patch Set: Re-upload Created 10 years, 10 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
« no previous file with comments | « tools/linux-tick-processor ('k') | tools/tickprocessor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 * @type {Object} 69 * @type {Object}
70 */ 70 */
71 this.backRefsCommands_ = {}; 71 this.backRefsCommands_ = {};
72 this.initBackRefsCommands_(); 72 this.initBackRefsCommands_();
73 73
74 /** 74 /**
75 * Back references for decompression. 75 * Back references for decompression.
76 * @type {Array.<string>} 76 * @type {Array.<string>}
77 */ 77 */
78 this.backRefs_ = []; 78 this.backRefs_ = [];
79
80 /**
81 * Current line.
82 * @type {number}
83 */
84 this.lineNum_ = 0;
85
86 /**
87 * CSV lines parser.
88 * @type {devtools.profiler.CsvParser}
89 */
90 this.csvParser_ = new devtools.profiler.CsvParser();
79 }; 91 };
80 92
81 93
82 /** 94 /**
83 * Creates a parser for an address entry. 95 * Creates a parser for an address entry.
84 * 96 *
85 * @param {string} addressTag Address tag to perform offset decoding. 97 * @param {string} addressTag Address tag to perform offset decoding.
86 * @return {function(string):number} Address parser. 98 * @return {function(string):number} Address parser.
87 */ 99 */
88 devtools.profiler.LogReader.prototype.createAddressParser = function( 100 devtools.profiler.LogReader.prototype.createAddressParser = function(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 * Processes a portion of V8 profiler event log. 141 * Processes a portion of V8 profiler event log.
130 * 142 *
131 * @param {string} chunk A portion of log. 143 * @param {string} chunk A portion of log.
132 */ 144 */
133 devtools.profiler.LogReader.prototype.processLogChunk = function(chunk) { 145 devtools.profiler.LogReader.prototype.processLogChunk = function(chunk) {
134 this.processLog_(chunk.split('\n')); 146 this.processLog_(chunk.split('\n'));
135 }; 147 };
136 148
137 149
138 /** 150 /**
151 * Processes a line of V8 profiler event log.
152 *
153 * @param {string} line A line of log.
154 */
155 devtools.profiler.LogReader.prototype.processLogLine = function(line) {
156 this.processLog_([line]);
157 };
158
159
160 /**
139 * Processes stack record. 161 * Processes stack record.
140 * 162 *
141 * @param {number} pc Program counter. 163 * @param {number} pc Program counter.
142 * @param {number} func JS Function. 164 * @param {number} func JS Function.
143 * @param {Array.<string>} stack String representation of a stack. 165 * @param {Array.<string>} stack String representation of a stack.
144 * @return {Array.<number>} Processed stack. 166 * @return {Array.<number>} Processed stack.
145 */ 167 */
146 devtools.profiler.LogReader.prototype.processStack = function(pc, func, stack) { 168 devtools.profiler.LogReader.prototype.processStack = function(pc, func, stack) {
147 var fullStack = func ? [pc, func] : [pc]; 169 var fullStack = func ? [pc, func] : [pc];
148 var prevFrame = pc; 170 var prevFrame = pc;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 }; 295 };
274 296
275 297
276 /** 298 /**
277 * Processes log lines. 299 * Processes log lines.
278 * 300 *
279 * @param {Array.<string>} lines Log lines. 301 * @param {Array.<string>} lines Log lines.
280 * @private 302 * @private
281 */ 303 */
282 devtools.profiler.LogReader.prototype.processLog_ = function(lines) { 304 devtools.profiler.LogReader.prototype.processLog_ = function(lines) {
283 var csvParser = new devtools.profiler.CsvParser(); 305 for (var i = 0, n = lines.length; i < n; ++i, ++this.lineNum_) {
284 try { 306 var line = lines[i];
285 for (var i = 0, n = lines.length; i < n; ++i) { 307 if (!line) {
286 var line = lines[i]; 308 continue;
287 if (!line) { 309 }
288 continue; 310 try {
289 }
290 if (line.charAt(0) == '#' || 311 if (line.charAt(0) == '#' ||
291 line.substr(0, line.indexOf(',')) in this.backRefsCommands_) { 312 line.substr(0, line.indexOf(',')) in this.backRefsCommands_) {
292 line = this.expandBackRef_(line); 313 line = this.expandBackRef_(line);
293 } 314 }
294 var fields = csvParser.parseLine(line); 315 var fields = this.csvParser_.parseLine(line);
295 this.dispatchLogRow_(fields); 316 this.dispatchLogRow_(fields);
296 } 317 } catch (e) {
297 } catch (e) { 318 this.printError('line ' + (this.lineNum_ + 1) + ': ' + (e.message || e));
298 // An error on the last line is acceptable since log file can be truncated.
299 if (i < n - 1) {
300 this.printError('line ' + (i + 1) + ': ' + (e.message || e));
301 throw e;
302 } 319 }
303 } 320 }
304 }; 321 };
305 322
306 323
307 /** 324 /**
308 * Processes repeat log record. Expands it according to calls count and 325 * Processes repeat log record. Expands it according to calls count and
309 * invokes processing. 326 * invokes processing.
310 * 327 *
311 * @param {number} count Count. 328 * @param {number} count Count.
312 * @param {Array.<string>} cmd Parsed command. 329 * @param {Array.<string>} cmd Parsed command.
313 * @private 330 * @private
314 */ 331 */
315 devtools.profiler.LogReader.prototype.processRepeat_ = function(count, cmd) { 332 devtools.profiler.LogReader.prototype.processRepeat_ = function(count, cmd) {
316 // Replace the repeat-prefixed command from backrefs list with a non-prefixed. 333 // Replace the repeat-prefixed command from backrefs list with a non-prefixed.
317 this.backRefs_[0] = cmd.join(','); 334 this.backRefs_[0] = cmd.join(',');
318 for (var i = 0; i < count; ++i) { 335 for (var i = 0; i < count; ++i) {
319 this.dispatchLogRow_(cmd); 336 this.dispatchLogRow_(cmd);
320 } 337 }
321 }; 338 };
OLDNEW
« no previous file with comments | « tools/linux-tick-processor ('k') | tools/tickprocessor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698