| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 155 distortion, |
| 156 range) { | 156 range, |
| 157 sourceMap) { |
| 157 LogReader.call(this, { | 158 LogReader.call(this, { |
| 158 'shared-library': { parsers: [null, parseInt, parseInt], | 159 'shared-library': { parsers: [null, parseInt, parseInt], |
| 159 processor: this.processSharedLibrary }, | 160 processor: this.processSharedLibrary }, |
| 160 'code-creation': { | 161 'code-creation': { |
| 161 parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'], | 162 parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'], |
| 162 processor: this.processCodeCreation }, | 163 processor: this.processCodeCreation }, |
| 163 'code-move': { parsers: [parseInt, parseInt], | 164 'code-move': { parsers: [parseInt, parseInt], |
| 164 processor: this.processCodeMove }, | 165 processor: this.processCodeMove }, |
| 165 'code-delete': { parsers: [parseInt], | 166 'code-delete': { parsers: [parseInt], |
| 166 processor: this.processCodeDelete }, | 167 processor: this.processCodeDelete }, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 189 // Obsolete row types. | 190 // Obsolete row types. |
| 190 'code-allocate': null, | 191 'code-allocate': null, |
| 191 'begin-code-region': null, | 192 'begin-code-region': null, |
| 192 'end-code-region': null }); | 193 'end-code-region': null }); |
| 193 | 194 |
| 194 this.cppEntriesProvider_ = cppEntriesProvider; | 195 this.cppEntriesProvider_ = cppEntriesProvider; |
| 195 this.callGraphSize_ = callGraphSize; | 196 this.callGraphSize_ = callGraphSize; |
| 196 this.ignoreUnknown_ = ignoreUnknown; | 197 this.ignoreUnknown_ = ignoreUnknown; |
| 197 this.stateFilter_ = stateFilter; | 198 this.stateFilter_ = stateFilter; |
| 198 this.snapshotLogProcessor_ = snapshotLogProcessor; | 199 this.snapshotLogProcessor_ = snapshotLogProcessor; |
| 200 this.sourceMap = sourceMap; |
| 199 this.deserializedEntriesNames_ = []; | 201 this.deserializedEntriesNames_ = []; |
| 200 var ticks = this.ticks_ = | 202 var ticks = this.ticks_ = |
| 201 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; | 203 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; |
| 202 | 204 |
| 203 distortion = parseInt(distortion); | 205 distortion = parseInt(distortion); |
| 204 // Convert picoseconds to nanoseconds. | 206 // Convert picoseconds to nanoseconds. |
| 205 this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000); | 207 this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000); |
| 206 this.distortion = 0; | 208 this.distortion = 0; |
| 207 var rangelimits = range ? range.split(",") : []; | 209 var rangelimits = range ? range.split(",") : []; |
| 208 var range_start = parseInt(rangelimits[0]); | 210 var range_start = parseInt(rangelimits[0]); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 profile, filterP, func) { | 539 profile, filterP, func) { |
| 538 for (var i = 0, n = profile.length; i < n; ++i) { | 540 for (var i = 0, n = profile.length; i < n; ++i) { |
| 539 var rec = profile[i]; | 541 var rec = profile[i]; |
| 540 if (!filterP(rec.internalFuncName)) { | 542 if (!filterP(rec.internalFuncName)) { |
| 541 continue; | 543 continue; |
| 542 } | 544 } |
| 543 func(rec); | 545 func(rec); |
| 544 } | 546 } |
| 545 }; | 547 }; |
| 546 | 548 |
| 549 TickProcessor.prototype.getLineAndColumn = function(name) { |
| 550 var re = /:([0-9]+):([0-9]+)$/; |
| 551 var array = re.exec(name); |
| 552 if (!array) { |
| 553 return null; |
| 554 } |
| 555 return {line: array[1], column: array[2]}; |
| 556 } |
| 557 |
| 558 TickProcessor.prototype.hasSourceMap = function() { |
| 559 return this.sourceMap != null; |
| 560 }; |
| 561 |
| 562 |
| 563 TickProcessor.prototype.formatFunctionName = function(funcName) { |
| 564 if (!this.hasSourceMap()) { |
| 565 return funcName; |
| 566 } |
| 567 var lc = this.getLineAndColumn(funcName); |
| 568 if (lc == null) { |
| 569 return funcName; |
| 570 } |
| 571 // in source maps lines and columns are zero based |
| 572 var lineNumber = lc.line - 1; |
| 573 var column = lc.column - 1; |
| 574 var entry = this.sourceMap.findEntry(lineNumber, column); |
| 575 var sourceFile = entry[2]; |
| 576 var sourceLine = entry[3] + 1; |
| 577 var sourceColumn = entry[4] + 1; |
| 578 |
| 579 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName; |
| 580 }; |
| 547 | 581 |
| 548 TickProcessor.prototype.printEntries = function( | 582 TickProcessor.prototype.printEntries = function( |
| 549 profile, nonLibTicks, filterP) { | 583 profile, nonLibTicks, filterP) { |
| 584 var that = this; |
| 550 this.processProfile(profile, filterP, function (rec) { | 585 this.processProfile(profile, filterP, function (rec) { |
| 551 if (rec.selfTime == 0) return; | 586 if (rec.selfTime == 0) return; |
| 552 var nonLibPct = nonLibTicks != null ? | 587 var nonLibPct = nonLibTicks != null ? |
| 553 rec.selfTime * 100.0 / nonLibTicks : 0.0; | 588 rec.selfTime * 100.0 / nonLibTicks : 0.0; |
| 589 var funcName = that.formatFunctionName(rec.internalFuncName); |
| 590 |
| 554 print(' ' + padLeft(rec.selfTime, 5) + ' ' + | 591 print(' ' + padLeft(rec.selfTime, 5) + ' ' + |
| 555 padLeft(rec.selfPercent.toFixed(1), 5) + '% ' + | 592 padLeft(rec.selfPercent.toFixed(1), 5) + '% ' + |
| 556 padLeft(nonLibPct.toFixed(1), 5) + '% ' + | 593 padLeft(nonLibPct.toFixed(1), 5) + '% ' + |
| 557 rec.internalFuncName); | 594 funcName); |
| 558 }); | 595 }); |
| 559 }; | 596 }; |
| 560 | 597 |
| 561 | 598 |
| 562 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { | 599 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { |
| 563 var self = this; | 600 var self = this; |
| 564 var indent = opt_indent || 0; | 601 var indent = opt_indent || 0; |
| 565 var indentStr = padLeft('', indent); | 602 var indentStr = padLeft('', indent); |
| 566 this.processProfile(profile, function() { return true; }, function (rec) { | 603 this.processProfile(profile, function() { return true; }, function (rec) { |
| 567 // Cut off too infrequent callers. | 604 // Cut off too infrequent callers. |
| 568 if (rec.parentTotalPercent < TickProcessor.CALL_PROFILE_CUTOFF_PCT) return; | 605 if (rec.parentTotalPercent < TickProcessor.CALL_PROFILE_CUTOFF_PCT) return; |
| 606 var funcName = self.formatFunctionName(rec.internalFuncName); |
| 569 print(' ' + padLeft(rec.totalTime, 5) + ' ' + | 607 print(' ' + padLeft(rec.totalTime, 5) + ' ' + |
| 570 padLeft(rec.parentTotalPercent.toFixed(1), 5) + '% ' + | 608 padLeft(rec.parentTotalPercent.toFixed(1), 5) + '% ' + |
| 571 indentStr + rec.internalFuncName); | 609 indentStr + funcName); |
| 572 // Limit backtrace depth. | 610 // Limit backtrace depth. |
| 573 if (indent < 2 * self.callGraphSize_) { | 611 if (indent < 2 * self.callGraphSize_) { |
| 574 self.printHeavyProfile(rec.children, indent + 2); | 612 self.printHeavyProfile(rec.children, indent + 2); |
| 575 } | 613 } |
| 576 // Delimit top-level functions. | 614 // Delimit top-level functions. |
| 577 if (indent == 0) { | 615 if (indent == 0) { |
| 578 print(''); | 616 print(''); |
| 579 } | 617 } |
| 580 }); | 618 }); |
| 581 }; | 619 }; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 'Specify that we are running on Windows platform'], | 854 'Specify that we are running on Windows platform'], |
| 817 '--mac': ['platform', 'mac', | 855 '--mac': ['platform', 'mac', |
| 818 'Specify that we are running on Mac OS X platform'], | 856 'Specify that we are running on Mac OS X platform'], |
| 819 '--nm': ['nm', 'nm', | 857 '--nm': ['nm', 'nm', |
| 820 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'], | 858 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'], |
| 821 '--target': ['targetRootFS', '', | 859 '--target': ['targetRootFS', '', |
| 822 'Specify the target root directory for cross environment'], | 860 'Specify the target root directory for cross environment'], |
| 823 '--snapshot-log': ['snapshotLogFileName', 'snapshot.log', | 861 '--snapshot-log': ['snapshotLogFileName', 'snapshot.log', |
| 824 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'], | 862 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'], |
| 825 '--range': ['range', 'auto,auto', | 863 '--range': ['range', 'auto,auto', |
| 826 'Specify the range limit as [start],[end]'], | 864 'Specify the range limit as [start],[end]'], |
| 827 '--distortion': ['distortion', 0, | 865 '--distortion': ['distortion', 0, |
| 828 'Specify the logging overhead in picoseconds'] | 866 'Specify the logging overhead in picoseconds'], |
| 867 '--source-map': ['sourceMap', null, |
| 868 'Specify the source map that should be used for output'] |
| 829 }; | 869 }; |
| 830 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; | 870 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; |
| 831 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; | 871 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; |
| 832 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; | 872 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; |
| 833 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; | 873 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; |
| 834 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; | 874 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; |
| 835 }; | 875 }; |
| 836 | 876 |
| 837 | 877 |
| 838 ArgumentsProcessor.DEFAULTS = { | 878 ArgumentsProcessor.DEFAULTS = { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 944 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
| 905 synonims.push(synArg); | 945 synonims.push(synArg); |
| 906 delete this.argsDispatch_[synArg]; | 946 delete this.argsDispatch_[synArg]; |
| 907 } | 947 } |
| 908 } | 948 } |
| 909 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 949 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
| 910 } | 950 } |
| 911 quit(2); | 951 quit(2); |
| 912 }; | 952 }; |
| 913 | 953 |
| OLD | NEW |