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

Side by Side Diff: tools/tickprocessor.js

Issue 6551011: Fix CPU profiling for Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« tools/ll_prof.py ('K') | « tools/profile.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 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 function readFile(fileName) { 50 function readFile(fileName) {
51 try { 51 try {
52 return read(fileName); 52 return read(fileName);
53 } catch (e) { 53 } catch (e) {
54 print(fileName + ': ' + (e.message || e)); 54 print(fileName + ': ' + (e.message || e));
55 throw e; 55 throw e;
56 } 56 }
57 } 57 }
58 58
59 59
60 /**
61 * Parser for dynamic code optimization state.
62 */
63 function parseState(s) {
64 switch (s) {
65 case "": return Profile.CodeState.COMPILED;
66 case "~": return Profile.CodeState.OPTIMIZABLE;
67 case "*": return Profile.CodeState.OPTIMIZED;
68 }
69 throw new Error("unknown code state: " + s);
70 }
71
72
60 function SnapshotLogProcessor() { 73 function SnapshotLogProcessor() {
61 LogReader.call(this, { 74 LogReader.call(this, {
62 'code-creation': { 75 'code-creation': {
63 parsers: [null, parseInt, parseInt, null], 76 parsers: [null, parseInt, parseInt, null, 'var-args'],
64 processor: this.processCodeCreation }, 77 processor: this.processCodeCreation },
65 'code-move': { parsers: [parseInt, parseInt], 78 'code-move': { parsers: [parseInt, parseInt],
66 processor: this.processCodeMove }, 79 processor: this.processCodeMove },
67 'code-delete': { parsers: [parseInt], 80 'code-delete': { parsers: [parseInt],
68 processor: this.processCodeDelete }, 81 processor: this.processCodeDelete },
69 'function-creation': null, 82 'function-creation': null,
70 'function-move': null, 83 'function-move': null,
71 'function-delete': null, 84 'function-delete': null,
85 'sfi-move': null,
72 'snapshot-pos': { parsers: [parseInt, parseInt], 86 'snapshot-pos': { parsers: [parseInt, parseInt],
73 processor: this.processSnapshotPosition }}); 87 processor: this.processSnapshotPosition }});
74 88
75 V8Profile.prototype.handleUnknownCode = function(operation, addr) { 89 V8Profile.prototype.handleUnknownCode = function(operation, addr) {
76 var op = Profile.Operation; 90 var op = Profile.Operation;
77 switch (operation) { 91 switch (operation) {
78 case op.MOVE: 92 case op.MOVE:
79 print('Snapshot: Code move event for unknown code: 0x' + 93 print('Snapshot: Code move event for unknown code: 0x' +
80 addr.toString(16)); 94 addr.toString(16));
81 break; 95 break;
82 case op.DELETE: 96 case op.DELETE:
83 print('Snapshot: Code delete event for unknown code: 0x' + 97 print('Snapshot: Code delete event for unknown code: 0x' +
84 addr.toString(16)); 98 addr.toString(16));
85 break; 99 break;
86 } 100 }
87 }; 101 };
88 102
89 this.profile_ = new V8Profile(); 103 this.profile_ = new V8Profile();
90 this.serializedEntries_ = []; 104 this.serializedEntries_ = [];
91 } 105 }
92 inherits(SnapshotLogProcessor, LogReader); 106 inherits(SnapshotLogProcessor, LogReader);
93 107
94 108
95 SnapshotLogProcessor.prototype.processCodeCreation = function( 109 SnapshotLogProcessor.prototype.processCodeCreation = function(
96 type, start, size, name) { 110 type, start, size, name, maybe_func) {
97 var entry = this.profile_.addCode(type, name, start, size); 111 if (maybe_func.length) {
112 var funcAddr = parseInt(maybe_func[0]);
113 var state = parseState(maybe_func[1]);
114 this.profile_.addFuncCode(type, name, start, size, funcAddr, state);
115 } else {
116 this.profile_.addCode(type, name, start, size);
117 }
98 }; 118 };
99 119
100 120
101 SnapshotLogProcessor.prototype.processCodeMove = function(from, to) { 121 SnapshotLogProcessor.prototype.processCodeMove = function(from, to) {
102 this.profile_.moveCode(from, to); 122 this.profile_.moveCode(from, to);
103 }; 123 };
104 124
105 125
106 SnapshotLogProcessor.prototype.processCodeDelete = function(start) { 126 SnapshotLogProcessor.prototype.processCodeDelete = function(start) {
107 this.profile_.deleteCode(start); 127 this.profile_.deleteCode(start);
(...skipping 16 matching lines...) Expand all
124 return entry ? entry.getRawName() : null; 144 return entry ? entry.getRawName() : null;
125 }; 145 };
126 146
127 147
128 function TickProcessor( 148 function TickProcessor(
129 cppEntriesProvider, separateIc, ignoreUnknown, stateFilter, snapshotLogProce ssor) { 149 cppEntriesProvider, separateIc, ignoreUnknown, stateFilter, snapshotLogProce ssor) {
130 LogReader.call(this, { 150 LogReader.call(this, {
131 'shared-library': { parsers: [null, parseInt, parseInt], 151 'shared-library': { parsers: [null, parseInt, parseInt],
132 processor: this.processSharedLibrary }, 152 processor: this.processSharedLibrary },
133 'code-creation': { 153 'code-creation': {
134 parsers: [null, parseInt, parseInt, null], 154 parsers: [null, parseInt, parseInt, null, 'var-args'],
135 processor: this.processCodeCreation }, 155 processor: this.processCodeCreation },
136 'code-move': { parsers: [parseInt, parseInt], 156 'code-move': { parsers: [parseInt, parseInt],
137 processor: this.processCodeMove }, 157 processor: this.processCodeMove },
138 'code-delete': { parsers: [parseInt], 158 'code-delete': { parsers: [parseInt],
139 processor: this.processCodeDelete }, 159 processor: this.processCodeDelete },
140 'function-creation': { parsers: [parseInt, parseInt], 160 'sfi-move': { parsers: [parseInt, parseInt],
141 processor: this.processFunctionCreation },
142 'function-move': { parsers: [parseInt, parseInt],
143 processor: this.processFunctionMove }, 161 processor: this.processFunctionMove },
144 'function-delete': { parsers: [parseInt],
145 processor: this.processFunctionDelete },
146 'snapshot-pos': { parsers: [parseInt, parseInt], 162 'snapshot-pos': { parsers: [parseInt, parseInt],
147 processor: this.processSnapshotPosition }, 163 processor: this.processSnapshotPosition },
148 'tick': { parsers: [parseInt, parseInt, parseInt, parseInt, 'var-args'], 164 'tick': { parsers: [parseInt, parseInt, parseInt, parseInt, 'var-args'],
149 processor: this.processTick }, 165 processor: this.processTick },
150 'heap-sample-begin': { parsers: [null, null, parseInt], 166 'heap-sample-begin': { parsers: [null, null, parseInt],
151 processor: this.processHeapSampleBegin }, 167 processor: this.processHeapSampleBegin },
152 'heap-sample-end': { parsers: [null, null], 168 'heap-sample-end': { parsers: [null, null],
153 processor: this.processHeapSampleEnd }, 169 processor: this.processHeapSampleEnd },
154 'heap-js-prod-item': { parsers: [null, 'var-args'], 170 'heap-js-prod-item': { parsers: [null, 'var-args'],
155 processor: this.processJSProducer }, 171 processor: this.processJSProducer },
156 // Ignored events. 172 // Ignored events.
157 'profiler': null, 173 'profiler': null,
174 'function-creation': null,
175 'function-move': null,
176 'function-delete': null,
158 'heap-sample-stats': null, 177 'heap-sample-stats': null,
159 'heap-sample-item': null, 178 'heap-sample-item': null,
160 'heap-js-cons-item': null, 179 'heap-js-cons-item': null,
161 'heap-js-ret-item': null, 180 'heap-js-ret-item': null,
162 // Obsolete row types. 181 // Obsolete row types.
163 'code-allocate': null, 182 'code-allocate': null,
164 'begin-code-region': null, 183 'begin-code-region': null,
165 'end-code-region': null }); 184 'end-code-region': null });
166 185
167 this.cppEntriesProvider_ = cppEntriesProvider; 186 this.cppEntriesProvider_ = cppEntriesProvider;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 var self = this; 297 var self = this;
279 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( 298 var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
280 name, startAddr, endAddr, function(fName, fStart, fEnd) { 299 name, startAddr, endAddr, function(fName, fStart, fEnd) {
281 self.profile_.addStaticCode(fName, fStart, fEnd); 300 self.profile_.addStaticCode(fName, fStart, fEnd);
282 self.setCodeType(fName, 'CPP'); 301 self.setCodeType(fName, 'CPP');
283 }); 302 });
284 }; 303 };
285 304
286 305
287 TickProcessor.prototype.processCodeCreation = function( 306 TickProcessor.prototype.processCodeCreation = function(
288 type, start, size, name) { 307 type, start, size, name, maybe_func) {
289 name = this.deserializedEntriesNames_[start] || name; 308 name = this.deserializedEntriesNames_[start] || name;
290 var entry = this.profile_.addCode(type, name, start, size); 309 if (maybe_func.length) {
310 var funcAddr = parseInt(maybe_func[0]);
311 var state = parseState(maybe_func[1]);
312 this.profile_.addFuncCode(type, name, start, size, funcAddr, state);
313 } else {
314 this.profile_.addCode(type, name, start, size);
315 }
291 }; 316 };
292 317
293 318
294 TickProcessor.prototype.processCodeMove = function(from, to) { 319 TickProcessor.prototype.processCodeMove = function(from, to) {
295 this.profile_.moveCode(from, to); 320 this.profile_.moveCode(from, to);
296 }; 321 };
297 322
298 323
299 TickProcessor.prototype.processCodeDelete = function(start) { 324 TickProcessor.prototype.processCodeDelete = function(start) {
300 this.profile_.deleteCode(start); 325 this.profile_.deleteCode(start);
301 }; 326 };
302 327
303 328
304 TickProcessor.prototype.processFunctionCreation = function(
305 functionAddr, codeAddr) {
306 this.profile_.addCodeAlias(functionAddr, codeAddr);
307 };
308
309
310 TickProcessor.prototype.processFunctionMove = function(from, to) { 329 TickProcessor.prototype.processFunctionMove = function(from, to) {
311 this.profile_.safeMoveDynamicCode(from, to); 330 this.profile_.moveFunc(from, to);
312 }; 331 };
313 332
314 333
315 TickProcessor.prototype.processFunctionDelete = function(start) {
316 this.profile_.safeDeleteDynamicCode(start);
317 };
318
319
320 TickProcessor.prototype.processSnapshotPosition = function(addr, pos) { 334 TickProcessor.prototype.processSnapshotPosition = function(addr, pos) {
321 if (this.snapshotLogProcessor_) { 335 if (this.snapshotLogProcessor_) {
322 this.deserializedEntriesNames_[addr] = 336 this.deserializedEntriesNames_[addr] =
323 this.snapshotLogProcessor_.getSerializedEntryName(pos); 337 this.snapshotLogProcessor_.getSerializedEntryName(pos);
324 } 338 }
325 }; 339 };
326 340
327 341
328 TickProcessor.prototype.includeTick = function(vmState) { 342 TickProcessor.prototype.includeTick = function(vmState) {
329 return this.stateFilter_ == null || this.stateFilter_ == vmState; 343 return this.stateFilter_ == null || this.stateFilter_ == vmState;
330 }; 344 };
331 345
332 346
333 TickProcessor.prototype.processTick = function(pc, sp, func, vmState, stack) { 347 TickProcessor.prototype.processTick = function(pc, sp, func, vmState, stack) {
334 this.ticks_.total++; 348 this.ticks_.total++;
335 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; 349 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
336 if (!this.includeTick(vmState)) { 350 if (!this.includeTick(vmState)) {
337 this.ticks_.excluded++; 351 this.ticks_.excluded++;
338 return; 352 return;
339 } 353 }
340 354
341 if (func) { 355 if (func) {
342 var funcEntry = this.profile_.findEntry(func); 356 var funcEntry = this.profile_.findEntry(func);
343 if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) { 357 if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) {
344 func = 0; 358 func = 0;
345 } else {
346 var currEntry = this.profile_.findEntry(pc);
347 if (!currEntry || !currEntry.isJSFunction || currEntry.isJSFunction()) {
348 func = 0;
349 }
350 } 359 }
351 } 360 }
352 361
353 this.profile_.recordTick(this.processStack(pc, func, stack)); 362 this.profile_.recordTick(this.processStack(pc, func, stack));
354 }; 363 };
355 364
356 365
357 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) { 366 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
358 if (space != 'Heap') return; 367 if (space != 'Heap') return;
359 this.currentProducerProfile_ = new CallTree(); 368 this.currentProducerProfile_ = new CallTree();
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { 854 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
846 synonims.push(synArg); 855 synonims.push(synArg);
847 delete this.argsDispatch_[synArg]; 856 delete this.argsDispatch_[synArg];
848 } 857 }
849 } 858 }
850 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); 859 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]);
851 } 860 }
852 quit(2); 861 quit(2);
853 }; 862 };
854 863
OLDNEW
« tools/ll_prof.py ('K') | « tools/profile.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698