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

Side by Side Diff: tools/tickprocessor.js

Issue 551062: Fix issue 571: display descriptive names for code objects from snapshot. (Closed)
Patch Set: Created 10 years, 11 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 try { 46 try {
47 return read(fileName); 47 return read(fileName);
48 } catch (e) { 48 } catch (e) {
49 print(fileName + ': ' + (e.message || e)); 49 print(fileName + ': ' + (e.message || e));
50 throw e; 50 throw e;
51 } 51 }
52 } 52 }
53 53
54 54
55 function inherits(childCtor, parentCtor) { 55 function inherits(childCtor, parentCtor) {
56 function tempCtor() {}; 56 childCtor.prototype.__proto__ = parentCtor.prototype;
57 tempCtor.prototype = parentCtor.prototype; 57 };
58 childCtor.prototype = new tempCtor(); 58
59
60 function SnapshotLogProcessor() {
61 devtools.profiler.LogReader.call(this, {
62 'code-creation': {
63 parsers: [null, this.createAddressParser('code'), parseInt, null],
64 processor: this.processCodeCreation, backrefs: true },
65 'code-move': { parsers: [this.createAddressParser('code'),
66 this.createAddressParser('code-move-to')],
67 processor: this.processCodeMove, backrefs: true },
68 'code-delete': { parsers: [this.createAddressParser('code')],
69 processor: this.processCodeDelete, backrefs: true },
70 'snapshot-pos': { parsers: [this.createAddressParser('code'), parseInt],
71 processor: this.processSnapshotPosition, backrefs: true }});
72
73 Profile.prototype.handleUnknownCode = function(operation, addr) {
74 var op = devtools.profiler.Profile.Operation;
75 switch (operation) {
76 case op.MOVE:
77 print('Snapshot: Code move event for unknown code: 0x' +
78 addr.toString(16));
79 break;
80 case op.DELETE:
81 print('Snapshot: Code delete event for unknown code: 0x' +
82 addr.toString(16));
83 break;
84 }
85 };
86
87 this.profile_ = new Profile();
88 this.serializedEntries_ = [];
89 }
90 inherits(SnapshotLogProcessor, devtools.profiler.LogReader);
91
92
93 SnapshotLogProcessor.prototype.processCodeCreation = function(
94 type, start, size, name) {
95 var entry = this.profile_.addCode(
96 this.expandAlias(type), name, start, size);
97 };
98
99
100 SnapshotLogProcessor.prototype.processCodeMove = function(from, to) {
101 this.profile_.moveCode(from, to);
102 };
103
104
105 SnapshotLogProcessor.prototype.processCodeDelete = function(start) {
106 this.profile_.deleteCode(start);
107 };
108
109
110 SnapshotLogProcessor.prototype.processSnapshotPosition = function(addr, pos) {
111 this.serializedEntries_[pos] = this.profile_.findEntry(addr);
112 };
113
114
115 SnapshotLogProcessor.prototype.processLogFile = function(fileName) {
116 var contents = readFile(fileName);
117 this.processLogChunk(contents);
118 };
119
120
121 SnapshotLogProcessor.prototype.getSerializedEntryName = function(pos) {
122 var entry = this.serializedEntries_[pos];
123 return entry ? entry.getRawName() : null;
59 }; 124 };
60 125
61 126
62 function TickProcessor( 127 function TickProcessor(
63 cppEntriesProvider, separateIc, ignoreUnknown, stateFilter) { 128 cppEntriesProvider, separateIc, ignoreUnknown, stateFilter, snapshotLogProce ssor) {
64 devtools.profiler.LogReader.call(this, { 129 devtools.profiler.LogReader.call(this, {
65 'shared-library': { parsers: [null, parseInt, parseInt], 130 'shared-library': { parsers: [null, parseInt, parseInt],
66 processor: this.processSharedLibrary }, 131 processor: this.processSharedLibrary },
67 'code-creation': { 132 'code-creation': {
68 parsers: [null, this.createAddressParser('code'), parseInt, null], 133 parsers: [null, this.createAddressParser('code'), parseInt, null],
69 processor: this.processCodeCreation, backrefs: true }, 134 processor: this.processCodeCreation, backrefs: true },
70 'code-move': { parsers: [this.createAddressParser('code'), 135 'code-move': { parsers: [this.createAddressParser('code'),
71 this.createAddressParser('code-move-to')], 136 this.createAddressParser('code-move-to')],
72 processor: this.processCodeMove, backrefs: true }, 137 processor: this.processCodeMove, backrefs: true },
73 'code-delete': { parsers: [this.createAddressParser('code')], 138 'code-delete': { parsers: [this.createAddressParser('code')],
74 processor: this.processCodeDelete, backrefs: true }, 139 processor: this.processCodeDelete, backrefs: true },
140 'snapshot-pos': { parsers: [this.createAddressParser('code'), parseInt],
141 processor: this.processSnapshotPosition, backrefs: true },
75 'tick': { parsers: [this.createAddressParser('code'), 142 'tick': { parsers: [this.createAddressParser('code'),
76 this.createAddressParser('stack'), parseInt, 'var-args'], 143 this.createAddressParser('stack'), parseInt, 'var-args'],
77 processor: this.processTick, backrefs: true }, 144 processor: this.processTick, backrefs: true },
78 'heap-sample-begin': { parsers: [null, null, parseInt], 145 'heap-sample-begin': { parsers: [null, null, parseInt],
79 processor: this.processHeapSampleBegin }, 146 processor: this.processHeapSampleBegin },
80 'heap-sample-end': { parsers: [null, null], 147 'heap-sample-end': { parsers: [null, null],
81 processor: this.processHeapSampleEnd }, 148 processor: this.processHeapSampleEnd },
82 'heap-js-prod-item': { parsers: [null, 'var-args'], 149 'heap-js-prod-item': { parsers: [null, 'var-args'],
83 processor: this.processJSProducer, backrefs: true }, 150 processor: this.processJSProducer, backrefs: true },
84 // Ignored events. 151 // Ignored events.
85 'profiler': null, 152 'profiler': null,
86 'heap-sample-stats': null, 153 'heap-sample-stats': null,
87 'heap-sample-item': null, 154 'heap-sample-item': null,
88 'heap-js-cons-item': null, 155 'heap-js-cons-item': null,
89 'heap-js-ret-item': null, 156 'heap-js-ret-item': null,
90 // Obsolete row types. 157 // Obsolete row types.
91 'code-allocate': null, 158 'code-allocate': null,
92 'begin-code-region': null, 159 'begin-code-region': null,
93 'end-code-region': null }); 160 'end-code-region': null });
94 161
95 this.cppEntriesProvider_ = cppEntriesProvider; 162 this.cppEntriesProvider_ = cppEntriesProvider;
96 this.ignoreUnknown_ = ignoreUnknown; 163 this.ignoreUnknown_ = ignoreUnknown;
97 this.stateFilter_ = stateFilter; 164 this.stateFilter_ = stateFilter;
165 this.snapshotLogProcessor_ = snapshotLogProcessor;
166 this.deserializedEntriesNames_ = [];
98 var ticks = this.ticks_ = 167 var ticks = this.ticks_ =
99 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; 168 { total: 0, unaccounted: 0, excluded: 0, gc: 0 };
100 169
101 Profile.prototype.handleUnknownCode = function( 170 Profile.prototype.handleUnknownCode = function(
102 operation, addr, opt_stackPos) { 171 operation, addr, opt_stackPos) {
103 var op = devtools.profiler.Profile.Operation; 172 var op = devtools.profiler.Profile.Operation;
104 switch (operation) { 173 switch (operation) {
105 case op.MOVE: 174 case op.MOVE:
106 print('Code move event for unknown code: 0x' + addr.toString(16)); 175 print('Code move event for unknown code: 0x' + addr.toString(16));
107 break; 176 break;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( 264 var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
196 name, startAddr, endAddr, function(fName, fStart, fEnd) { 265 name, startAddr, endAddr, function(fName, fStart, fEnd) {
197 self.profile_.addStaticCode(fName, fStart, fEnd); 266 self.profile_.addStaticCode(fName, fStart, fEnd);
198 self.setCodeType(fName, 'CPP'); 267 self.setCodeType(fName, 'CPP');
199 }); 268 });
200 }; 269 };
201 270
202 271
203 TickProcessor.prototype.processCodeCreation = function( 272 TickProcessor.prototype.processCodeCreation = function(
204 type, start, size, name) { 273 type, start, size, name) {
274 name = this.deserializedEntriesNames_[start] || name;
205 var entry = this.profile_.addCode( 275 var entry = this.profile_.addCode(
206 this.expandAlias(type), name, start, size); 276 this.expandAlias(type), name, start, size);
207 }; 277 };
208 278
209 279
210 TickProcessor.prototype.processCodeMove = function(from, to) { 280 TickProcessor.prototype.processCodeMove = function(from, to) {
211 this.profile_.moveCode(from, to); 281 this.profile_.moveCode(from, to);
212 }; 282 };
213 283
214 284
215 TickProcessor.prototype.processCodeDelete = function(start) { 285 TickProcessor.prototype.processCodeDelete = function(start) {
216 this.profile_.deleteCode(start); 286 this.profile_.deleteCode(start);
217 }; 287 };
218 288
219 289
290 TickProcessor.prototype.processSnapshotPosition = function(addr, pos) {
291 if (this.snapshotLogProcessor_) {
292 this.deserializedEntriesNames_[addr] =
293 this.snapshotLogProcessor_.getSerializedEntryName(pos);
294 }
295 };
296
297
220 TickProcessor.prototype.includeTick = function(vmState) { 298 TickProcessor.prototype.includeTick = function(vmState) {
221 return this.stateFilter_ == null || this.stateFilter_ == vmState; 299 return this.stateFilter_ == null || this.stateFilter_ == vmState;
222 }; 300 };
223 301
224 302
225 TickProcessor.prototype.processTick = function(pc, sp, vmState, stack) { 303 TickProcessor.prototype.processTick = function(pc, sp, vmState, stack) {
226 this.ticks_.total++; 304 this.ticks_.total++;
227 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; 305 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
228 if (!this.includeTick(vmState)) { 306 if (!this.includeTick(vmState)) {
229 this.ticks_.excluded++; 307 this.ticks_.excluded++;
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 'Exclude ticks of unknown code entries from processing'], 719 'Exclude ticks of unknown code entries from processing'],
642 '--separate-ic': ['separateIc', true, 720 '--separate-ic': ['separateIc', true,
643 'Separate IC entries'], 721 'Separate IC entries'],
644 '--unix': ['platform', 'unix', 722 '--unix': ['platform', 'unix',
645 'Specify that we are running on *nix platform'], 723 'Specify that we are running on *nix platform'],
646 '--windows': ['platform', 'windows', 724 '--windows': ['platform', 'windows',
647 'Specify that we are running on Windows platform'], 725 'Specify that we are running on Windows platform'],
648 '--mac': ['platform', 'mac', 726 '--mac': ['platform', 'mac',
649 'Specify that we are running on Mac OS X platform'], 727 'Specify that we are running on Mac OS X platform'],
650 '--nm': ['nm', 'nm', 728 '--nm': ['nm', 'nm',
651 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'] 729 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'],
730 '--snapshot-log': ['snapshotLogFileName', 'snapshot.log',
731 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)']
652 }; 732 };
653 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; 733 this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
654 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; 734 this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
655 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; 735 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c'];
656 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; 736 this.argsDispatch_['--other'] = this.argsDispatch_['-o'];
657 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; 737 this.argsDispatch_['--external'] = this.argsDispatch_['-e'];
658 }; 738 };
659 739
660 740
661 ArgumentsProcessor.DEFAULTS = { 741 ArgumentsProcessor.DEFAULTS = {
662 logFileName: 'v8.log', 742 logFileName: 'v8.log',
743 snapshotLogFileName: null,
663 platform: 'unix', 744 platform: 'unix',
664 stateFilter: null, 745 stateFilter: null,
665 ignoreUnknown: false, 746 ignoreUnknown: false,
666 separateIc: false, 747 separateIc: false,
667 nm: 'nm' 748 nm: 'nm'
668 }; 749 };
669 750
670 751
671 ArgumentsProcessor.prototype.parse = function() { 752 ArgumentsProcessor.prototype.parse = function() {
672 while (this.args_.length) { 753 while (this.args_.length) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { 803 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
723 synonims.push(synArg); 804 synonims.push(synArg);
724 delete this.argsDispatch_[synArg]; 805 delete this.argsDispatch_[synArg];
725 } 806 }
726 } 807 }
727 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); 808 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]);
728 } 809 }
729 quit(2); 810 quit(2);
730 }; 811 };
731 812
OLDNEW
« src/serialize.cc ('K') | « tools/profile.js ('k') | tools/tickprocessor-driver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698