OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return entry ? entry.getRawName() : null; | 144 return entry ? entry.getRawName() : null; |
145 }; | 145 }; |
146 | 146 |
147 | 147 |
148 function TickProcessor( | 148 function TickProcessor( |
149 cppEntriesProvider, | 149 cppEntriesProvider, |
150 separateIc, | 150 separateIc, |
151 callGraphSize, | 151 callGraphSize, |
152 ignoreUnknown, | 152 ignoreUnknown, |
153 stateFilter, | 153 stateFilter, |
154 snapshotLogProcessor) { | 154 snapshotLogProcessor, |
| 155 distortion, |
| 156 range) { |
155 LogReader.call(this, { | 157 LogReader.call(this, { |
156 'shared-library': { parsers: [null, parseInt, parseInt], | 158 'shared-library': { parsers: [null, parseInt, parseInt], |
157 processor: this.processSharedLibrary }, | 159 processor: this.processSharedLibrary }, |
158 'code-creation': { | 160 'code-creation': { |
159 parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'], | 161 parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'], |
160 processor: this.processCodeCreation }, | 162 processor: this.processCodeCreation }, |
161 'code-move': { parsers: [parseInt, parseInt], | 163 'code-move': { parsers: [parseInt, parseInt], |
162 processor: this.processCodeMove }, | 164 processor: this.processCodeMove }, |
163 'code-delete': { parsers: [parseInt], | 165 'code-delete': { parsers: [parseInt], |
164 processor: this.processCodeDelete }, | 166 processor: this.processCodeDelete }, |
165 'sfi-move': { parsers: [parseInt, parseInt], | 167 'sfi-move': { parsers: [parseInt, parseInt], |
166 processor: this.processFunctionMove }, | 168 processor: this.processFunctionMove }, |
167 'snapshot-pos': { parsers: [parseInt, parseInt], | 169 'snapshot-pos': { parsers: [parseInt, parseInt], |
168 processor: this.processSnapshotPosition }, | 170 processor: this.processSnapshotPosition }, |
169 'tick': { | 171 'tick': { |
170 parsers: [parseInt, parseInt, parseInt, parseInt, | 172 parsers: [parseInt, parseInt, parseInt, parseInt, |
171 parseInt, parseInt, 'var-args'], | 173 parseInt, parseInt, 'var-args'], |
172 processor: this.processTick }, | 174 processor: this.processTick }, |
173 'heap-sample-begin': { parsers: [null, null, parseInt], | 175 'heap-sample-begin': { parsers: [null, null, parseInt], |
174 processor: this.processHeapSampleBegin }, | 176 processor: this.processHeapSampleBegin }, |
175 'heap-sample-end': { parsers: [null, null], | 177 'heap-sample-end': { parsers: [null, null], |
176 processor: this.processHeapSampleEnd }, | 178 processor: this.processHeapSampleEnd }, |
| 179 'timer-event-start' : { parsers: [null, null, null], |
| 180 processor: this.advanceDistortion }, |
| 181 'timer-event-end' : { parsers: [null, null, null], |
| 182 processor: this.advanceDistortion }, |
177 // Ignored events. | 183 // Ignored events. |
178 'profiler': null, | 184 'profiler': null, |
179 'function-creation': null, | 185 'function-creation': null, |
180 'function-move': null, | 186 'function-move': null, |
181 'function-delete': null, | 187 'function-delete': null, |
182 'heap-sample-item': null, | 188 'heap-sample-item': null, |
183 // Obsolete row types. | 189 // Obsolete row types. |
184 'code-allocate': null, | 190 'code-allocate': null, |
185 'begin-code-region': null, | 191 'begin-code-region': null, |
186 'end-code-region': null }); | 192 'end-code-region': null }); |
187 | 193 |
188 this.cppEntriesProvider_ = cppEntriesProvider; | 194 this.cppEntriesProvider_ = cppEntriesProvider; |
189 this.callGraphSize_ = callGraphSize; | 195 this.callGraphSize_ = callGraphSize; |
190 this.ignoreUnknown_ = ignoreUnknown; | 196 this.ignoreUnknown_ = ignoreUnknown; |
191 this.stateFilter_ = stateFilter; | 197 this.stateFilter_ = stateFilter; |
192 this.snapshotLogProcessor_ = snapshotLogProcessor; | 198 this.snapshotLogProcessor_ = snapshotLogProcessor; |
193 this.deserializedEntriesNames_ = []; | 199 this.deserializedEntriesNames_ = []; |
194 var ticks = this.ticks_ = | 200 var ticks = this.ticks_ = |
195 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; | 201 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; |
196 | 202 |
| 203 distortion = parseInt(distortion); |
| 204 // Convert picoseconds to nanoseconds. |
| 205 this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000); |
| 206 this.distortion = 0; |
| 207 var rangelimits = range.split(","); |
| 208 var range_start = parseInt(rangelimits[0]); |
| 209 var range_end = parseInt(rangelimits[1]); |
| 210 // Convert milliseconds to nanoseconds. |
| 211 this.range_start = isNaN(range_start) ? -Infinity : (range_start * 1000); |
| 212 this.range_end = isNaN(range_end) ? Infinity : (range_end * 1000) |
| 213 |
197 V8Profile.prototype.handleUnknownCode = function( | 214 V8Profile.prototype.handleUnknownCode = function( |
198 operation, addr, opt_stackPos) { | 215 operation, addr, opt_stackPos) { |
199 var op = Profile.Operation; | 216 var op = Profile.Operation; |
200 switch (operation) { | 217 switch (operation) { |
201 case op.MOVE: | 218 case op.MOVE: |
202 print('Code move event for unknown code: 0x' + addr.toString(16)); | 219 print('Code move event for unknown code: 0x' + addr.toString(16)); |
203 break; | 220 break; |
204 case op.DELETE: | 221 case op.DELETE: |
205 print('Code delete event for unknown code: 0x' + addr.toString(16)); | 222 print('Code delete event for unknown code: 0x' + addr.toString(16)); |
206 break; | 223 break; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return this.stateFilter_ == null || this.stateFilter_ == vmState; | 365 return this.stateFilter_ == null || this.stateFilter_ == vmState; |
349 }; | 366 }; |
350 | 367 |
351 TickProcessor.prototype.processTick = function(pc, | 368 TickProcessor.prototype.processTick = function(pc, |
352 sp, | 369 sp, |
353 ns_since_start, | 370 ns_since_start, |
354 is_external_callback, | 371 is_external_callback, |
355 tos_or_external_callback, | 372 tos_or_external_callback, |
356 vmState, | 373 vmState, |
357 stack) { | 374 stack) { |
| 375 this.distortion += this.distortion_per_entry; |
| 376 ns_since_start -= this.distortion; |
| 377 if (ns_since_start < this.range_start || ns_since_start > this.range_end) { |
| 378 return; |
| 379 } |
358 this.ticks_.total++; | 380 this.ticks_.total++; |
359 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; | 381 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; |
360 if (!this.includeTick(vmState)) { | 382 if (!this.includeTick(vmState)) { |
361 this.ticks_.excluded++; | 383 this.ticks_.excluded++; |
362 return; | 384 return; |
363 } | 385 } |
364 if (is_external_callback) { | 386 if (is_external_callback) { |
365 // Don't use PC when in external callback code, as it can point | 387 // Don't use PC when in external callback code, as it can point |
366 // inside callback's code, and we will erroneously report | 388 // inside callback's code, and we will erroneously report |
367 // that a callback calls itself. Instead we use tos_or_external_callback, | 389 // that a callback calls itself. Instead we use tos_or_external_callback, |
368 // as simply resetting PC will produce unaccounted ticks. | 390 // as simply resetting PC will produce unaccounted ticks. |
369 pc = tos_or_external_callback; | 391 pc = tos_or_external_callback; |
370 tos_or_external_callback = 0; | 392 tos_or_external_callback = 0; |
371 } else if (tos_or_external_callback) { | 393 } else if (tos_or_external_callback) { |
372 // Find out, if top of stack was pointing inside a JS function | 394 // Find out, if top of stack was pointing inside a JS function |
373 // meaning that we have encountered a frameless invocation. | 395 // meaning that we have encountered a frameless invocation. |
374 var funcEntry = this.profile_.findEntry(tos_or_external_callback); | 396 var funcEntry = this.profile_.findEntry(tos_or_external_callback); |
375 if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) { | 397 if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) { |
376 tos_or_external_callback = 0; | 398 tos_or_external_callback = 0; |
377 } | 399 } |
378 } | 400 } |
379 | 401 |
380 this.profile_.recordTick(this.processStack(pc, tos_or_external_callback, stack
)); | 402 this.profile_.recordTick(this.processStack(pc, tos_or_external_callback, stack
)); |
381 }; | 403 }; |
382 | 404 |
383 | 405 |
| 406 TickProcessor.prototype.advanceDistortion = function() { |
| 407 this.distortion += this.distortion_per_entry; |
| 408 } |
| 409 |
| 410 |
384 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) { | 411 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) { |
385 if (space != 'Heap') return; | 412 if (space != 'Heap') return; |
386 this.currentProducerProfile_ = new CallTree(); | 413 this.currentProducerProfile_ = new CallTree(); |
387 }; | 414 }; |
388 | 415 |
389 | 416 |
390 TickProcessor.prototype.processHeapSampleEnd = function(space, state) { | 417 TickProcessor.prototype.processHeapSampleEnd = function(space, state) { |
391 if (space != 'Heap' || !this.currentProducerProfile_) return; | 418 if (space != 'Heap' || !this.currentProducerProfile_) return; |
392 | 419 |
393 print('Generation ' + this.generation_ + ':'); | 420 print('Generation ' + this.generation_ + ':'); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 'Specify that we are running on *nix platform'], | 815 'Specify that we are running on *nix platform'], |
789 '--windows': ['platform', 'windows', | 816 '--windows': ['platform', 'windows', |
790 'Specify that we are running on Windows platform'], | 817 'Specify that we are running on Windows platform'], |
791 '--mac': ['platform', 'mac', | 818 '--mac': ['platform', 'mac', |
792 'Specify that we are running on Mac OS X platform'], | 819 'Specify that we are running on Mac OS X platform'], |
793 '--nm': ['nm', 'nm', | 820 '--nm': ['nm', 'nm', |
794 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'], | 821 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'], |
795 '--target': ['targetRootFS', '', | 822 '--target': ['targetRootFS', '', |
796 'Specify the target root directory for cross environment'], | 823 'Specify the target root directory for cross environment'], |
797 '--snapshot-log': ['snapshotLogFileName', 'snapshot.log', | 824 '--snapshot-log': ['snapshotLogFileName', 'snapshot.log', |
798 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'] | 825 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'], |
| 826 '--range': ['range', 'auto,auto', |
| 827 'Specify the range limit as [start],[end]'], |
| 828 '--distortion': ['distortion', 0, |
| 829 'Specify the logging overhead in picoseconds'] |
799 }; | 830 }; |
800 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; | 831 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; |
801 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; | 832 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; |
802 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; | 833 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; |
803 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; | 834 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; |
804 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; | 835 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; |
805 }; | 836 }; |
806 | 837 |
807 | 838 |
808 ArgumentsProcessor.DEFAULTS = { | 839 ArgumentsProcessor.DEFAULTS = { |
809 logFileName: 'v8.log', | 840 logFileName: 'v8.log', |
810 snapshotLogFileName: null, | 841 snapshotLogFileName: null, |
811 platform: 'unix', | 842 platform: 'unix', |
812 stateFilter: null, | 843 stateFilter: null, |
813 callGraphSize: 5, | 844 callGraphSize: 5, |
814 ignoreUnknown: false, | 845 ignoreUnknown: false, |
815 separateIc: false, | 846 separateIc: false, |
816 targetRootFS: '', | 847 targetRootFS: '', |
817 nm: 'nm' | 848 nm: 'nm', |
| 849 range: 'auto,auto', |
| 850 distortion: 0 |
818 }; | 851 }; |
819 | 852 |
820 | 853 |
821 ArgumentsProcessor.prototype.parse = function() { | 854 ArgumentsProcessor.prototype.parse = function() { |
822 while (this.args_.length) { | 855 while (this.args_.length) { |
823 var arg = this.args_[0]; | 856 var arg = this.args_[0]; |
824 if (arg.charAt(0) != '-') { | 857 if (arg.charAt(0) != '-') { |
825 break; | 858 break; |
826 } | 859 } |
827 this.args_.shift(); | 860 this.args_.shift(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 905 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
873 synonims.push(synArg); | 906 synonims.push(synArg); |
874 delete this.argsDispatch_[synArg]; | 907 delete this.argsDispatch_[synArg]; |
875 } | 908 } |
876 } | 909 } |
877 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 910 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
878 } | 911 } |
879 quit(2); | 912 quit(2); |
880 }; | 913 }; |
881 | 914 |
OLD | NEW |