OLD | NEW |
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 parsers: [null, this.createAddressParser('code'), parseInt, null], | 68 parsers: [null, this.createAddressParser('code'), parseInt, null], |
69 processor: this.processCodeCreation, backrefs: true }, | 69 processor: this.processCodeCreation, backrefs: true }, |
70 'code-move': { parsers: [this.createAddressParser('code'), | 70 'code-move': { parsers: [this.createAddressParser('code'), |
71 this.createAddressParser('code-move-to')], | 71 this.createAddressParser('code-move-to')], |
72 processor: this.processCodeMove, backrefs: true }, | 72 processor: this.processCodeMove, backrefs: true }, |
73 'code-delete': { parsers: [this.createAddressParser('code')], | 73 'code-delete': { parsers: [this.createAddressParser('code')], |
74 processor: this.processCodeDelete, backrefs: true }, | 74 processor: this.processCodeDelete, backrefs: true }, |
75 'tick': { parsers: [this.createAddressParser('code'), | 75 'tick': { parsers: [this.createAddressParser('code'), |
76 this.createAddressParser('stack'), parseInt, 'var-args'], | 76 this.createAddressParser('stack'), parseInt, 'var-args'], |
77 processor: this.processTick, backrefs: true }, | 77 processor: this.processTick, backrefs: true }, |
| 78 'heap-sample-begin': { parsers: [null, null, parseInt], |
| 79 processor: this.processHeapSampleBegin }, |
| 80 'heap-sample-end': { parsers: [null, null], |
| 81 processor: this.processHeapSampleEnd }, |
| 82 'heap-js-prod-item': { parsers: [null, 'var-args'], |
| 83 processor: this.processJSProducer, backrefs: true }, |
| 84 // Ignored events. |
78 'profiler': null, | 85 'profiler': null, |
| 86 'heap-sample-stats': null, |
| 87 'heap-sample-item': null, |
| 88 'heap-js-cons-item': null, |
| 89 'heap-js-ret-item': null, |
79 // Obsolete row types. | 90 // Obsolete row types. |
80 'code-allocate': null, | 91 'code-allocate': null, |
81 'begin-code-region': null, | 92 'begin-code-region': null, |
82 'end-code-region': null }); | 93 'end-code-region': null }); |
83 | 94 |
84 this.cppEntriesProvider_ = cppEntriesProvider; | 95 this.cppEntriesProvider_ = cppEntriesProvider; |
85 this.ignoreUnknown_ = ignoreUnknown; | 96 this.ignoreUnknown_ = ignoreUnknown; |
86 this.stateFilter_ = stateFilter; | 97 this.stateFilter_ = stateFilter; |
87 var ticks = this.ticks_ = | 98 var ticks = this.ticks_ = |
88 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; | 99 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; |
(...skipping 17 matching lines...) Expand all Loading... |
106 } | 117 } |
107 break; | 118 break; |
108 } | 119 } |
109 }; | 120 }; |
110 | 121 |
111 this.profile_ = new Profile(separateIc); | 122 this.profile_ = new Profile(separateIc); |
112 this.codeTypes_ = {}; | 123 this.codeTypes_ = {}; |
113 // Count each tick as a time unit. | 124 // Count each tick as a time unit. |
114 this.viewBuilder_ = new devtools.profiler.ViewBuilder(1); | 125 this.viewBuilder_ = new devtools.profiler.ViewBuilder(1); |
115 this.lastLogFileName_ = null; | 126 this.lastLogFileName_ = null; |
| 127 |
| 128 this.generation_ = 1; |
| 129 this.currentProducerProfile_ = null; |
116 }; | 130 }; |
117 inherits(TickProcessor, devtools.profiler.LogReader); | 131 inherits(TickProcessor, devtools.profiler.LogReader); |
118 | 132 |
119 | 133 |
120 TickProcessor.VmStates = { | 134 TickProcessor.VmStates = { |
121 JS: 0, | 135 JS: 0, |
122 GC: 1, | 136 GC: 1, |
123 COMPILER: 2, | 137 COMPILER: 2, |
124 OTHER: 3, | 138 OTHER: 3, |
125 EXTERNAL: 4 | 139 EXTERNAL: 4 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; | 227 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; |
214 if (!this.includeTick(vmState)) { | 228 if (!this.includeTick(vmState)) { |
215 this.ticks_.excluded++; | 229 this.ticks_.excluded++; |
216 return; | 230 return; |
217 } | 231 } |
218 | 232 |
219 this.profile_.recordTick(this.processStack(pc, stack)); | 233 this.profile_.recordTick(this.processStack(pc, stack)); |
220 }; | 234 }; |
221 | 235 |
222 | 236 |
| 237 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) { |
| 238 if (space != 'Heap') return; |
| 239 this.currentProducerProfile_ = new devtools.profiler.CallTree(); |
| 240 }; |
| 241 |
| 242 |
| 243 TickProcessor.prototype.processHeapSampleEnd = function(space, state) { |
| 244 if (space != 'Heap' || !this.currentProducerProfile_) return; |
| 245 |
| 246 print('Generation ' + this.generation_ + ':'); |
| 247 var tree = this.currentProducerProfile_; |
| 248 tree.computeTotalWeights(); |
| 249 var producersView = this.viewBuilder_.buildView(tree); |
| 250 // Sort by total time, desc, then by name, desc. |
| 251 producersView.sort(function(rec1, rec2) { |
| 252 return rec2.totalTime - rec1.totalTime || |
| 253 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
| 254 this.printHeavyProfile(producersView.head.children); |
| 255 |
| 256 this.currentProducerProfile_ = null; |
| 257 this.generation_++; |
| 258 }; |
| 259 |
| 260 |
| 261 TickProcessor.prototype.processJSProducer = function(constructor, stack) { |
| 262 if (!this.currentProducerProfile_) return; |
| 263 if (stack.length == 0) return; |
| 264 var first = stack.shift(); |
| 265 var processedStack = |
| 266 this.profile_.resolveAndFilterFuncs_(this.processStack(first, stack)); |
| 267 processedStack.unshift(constructor); |
| 268 this.currentProducerProfile_.addPath(processedStack); |
| 269 }; |
| 270 |
| 271 |
223 TickProcessor.prototype.printStatistics = function() { | 272 TickProcessor.prototype.printStatistics = function() { |
224 print('Statistical profiling result from ' + this.lastLogFileName_ + | 273 print('Statistical profiling result from ' + this.lastLogFileName_ + |
225 ', (' + this.ticks_.total + | 274 ', (' + this.ticks_.total + |
226 ' ticks, ' + this.ticks_.unaccounted + ' unaccounted, ' + | 275 ' ticks, ' + this.ticks_.unaccounted + ' unaccounted, ' + |
227 this.ticks_.excluded + ' excluded).'); | 276 this.ticks_.excluded + ' excluded).'); |
228 | 277 |
229 if (this.ticks_.total == 0) return; | 278 if (this.ticks_.total == 0) return; |
230 | 279 |
231 // Print the unknown ticks percentage if they are not ignored. | 280 // Print the unknown ticks percentage if they are not ignored. |
232 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { | 281 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 722 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
674 synonims.push(synArg); | 723 synonims.push(synArg); |
675 delete this.argsDispatch_[synArg]; | 724 delete this.argsDispatch_[synArg]; |
676 } | 725 } |
677 } | 726 } |
678 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 727 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
679 } | 728 } |
680 quit(2); | 729 quit(2); |
681 }; | 730 }; |
682 | 731 |
OLD | NEW |