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 25 matching lines...) Expand all Loading... |
36 * and calculating function execution times. | 36 * and calculating function execution times. |
37 * | 37 * |
38 * @constructor | 38 * @constructor |
39 */ | 39 */ |
40 devtools.profiler.Profile = function() { | 40 devtools.profiler.Profile = function() { |
41 this.codeMap_ = new devtools.profiler.CodeMap(); | 41 this.codeMap_ = new devtools.profiler.CodeMap(); |
42 this.topDownTree_ = new devtools.profiler.CallTree(); | 42 this.topDownTree_ = new devtools.profiler.CallTree(); |
43 this.bottomUpTree_ = new devtools.profiler.CallTree(); | 43 this.bottomUpTree_ = new devtools.profiler.CallTree(); |
44 }; | 44 }; |
45 | 45 |
| 46 /** |
| 47 * Version of profiler log. |
| 48 */ |
| 49 devtools.profiler.Profile.VERSION = 2; |
| 50 |
46 | 51 |
47 /** | 52 /** |
48 * Returns whether a function with the specified name must be skipped. | 53 * Returns whether a function with the specified name must be skipped. |
49 * Should be overriden by subclasses. | 54 * Should be overriden by subclasses. |
50 * | 55 * |
51 * @param {string} name Function name. | 56 * @param {string} name Function name. |
52 */ | 57 */ |
53 devtools.profiler.Profile.prototype.skipThisFunction = function(name) { | 58 devtools.profiler.Profile.prototype.skipThisFunction = function(name) { |
54 return false; | 59 return false; |
55 }; | 60 }; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 */ | 132 */ |
128 devtools.profiler.Profile.prototype.addCode = function( | 133 devtools.profiler.Profile.prototype.addCode = function( |
129 type, name, start, size) { | 134 type, name, start, size) { |
130 var entry = new devtools.profiler.Profile.DynamicCodeEntry(size, type, name); | 135 var entry = new devtools.profiler.Profile.DynamicCodeEntry(size, type, name); |
131 this.codeMap_.addCode(start, entry); | 136 this.codeMap_.addCode(start, entry); |
132 return entry; | 137 return entry; |
133 }; | 138 }; |
134 | 139 |
135 | 140 |
136 /** | 141 /** |
| 142 * Creates an alias entry for a code entry. |
| 143 * |
| 144 * @param {number} aliasAddr Alias address. |
| 145 * @param {number} addr Code entry address. |
| 146 */ |
| 147 devtools.profiler.Profile.prototype.addCodeAlias = function( |
| 148 aliasAddr, addr) { |
| 149 var entry = this.codeMap_.findEntry(addr); |
| 150 if (entry) { |
| 151 this.codeMap_.addCode(aliasAddr, entry); |
| 152 } |
| 153 }; |
| 154 |
| 155 |
| 156 /** |
137 * Reports about moving of a dynamic code entry. | 157 * Reports about moving of a dynamic code entry. |
138 * | 158 * |
139 * @param {number} from Current code entry address. | 159 * @param {number} from Current code entry address. |
140 * @param {number} to New code entry address. | 160 * @param {number} to New code entry address. |
141 */ | 161 */ |
142 devtools.profiler.Profile.prototype.moveCode = function(from, to) { | 162 devtools.profiler.Profile.prototype.moveCode = function(from, to) { |
143 try { | 163 try { |
144 this.codeMap_.moveCode(from, to); | 164 this.codeMap_.moveCode(from, to); |
145 } catch (e) { | 165 } catch (e) { |
146 this.handleUnknownCode(devtools.profiler.Profile.Operation.MOVE, from); | 166 this.handleUnknownCode(devtools.profiler.Profile.Operation.MOVE, from); |
147 } | 167 } |
148 }; | 168 }; |
149 | 169 |
150 | 170 |
151 /** | 171 /** |
152 * Reports about deletion of a dynamic code entry. | 172 * Reports about deletion of a dynamic code entry. |
153 * | 173 * |
154 * @param {number} start Starting address. | 174 * @param {number} start Starting address. |
155 */ | 175 */ |
156 devtools.profiler.Profile.prototype.deleteCode = function(start) { | 176 devtools.profiler.Profile.prototype.deleteCode = function(start) { |
157 try { | 177 try { |
158 this.codeMap_.deleteCode(start); | 178 this.codeMap_.deleteCode(start); |
159 } catch (e) { | 179 } catch (e) { |
160 this.handleUnknownCode(devtools.profiler.Profile.Operation.DELETE, start); | 180 this.handleUnknownCode(devtools.profiler.Profile.Operation.DELETE, start); |
161 } | 181 } |
162 }; | 182 }; |
163 | 183 |
164 | 184 |
165 /** | 185 /** |
| 186 * Reports about moving of a dynamic code entry. |
| 187 * |
| 188 * @param {number} from Current code entry address. |
| 189 * @param {number} to New code entry address. |
| 190 */ |
| 191 devtools.profiler.Profile.prototype.safeMoveDynamicCode = function(from, to) { |
| 192 if (this.codeMap_.findDynamicEntryByStartAddress(from)) { |
| 193 this.codeMap_.moveCode(from, to); |
| 194 } |
| 195 }; |
| 196 |
| 197 |
| 198 /** |
| 199 * Reports about deletion of a dynamic code entry. |
| 200 * |
| 201 * @param {number} start Starting address. |
| 202 */ |
| 203 devtools.profiler.Profile.prototype.safeDeleteDynamicCode = function(start) { |
| 204 if (this.codeMap_.findDynamicEntryByStartAddress(start)) { |
| 205 this.codeMap_.deleteCode(start); |
| 206 } |
| 207 }; |
| 208 |
| 209 |
| 210 /** |
166 * Retrieves a code entry by an address. | 211 * Retrieves a code entry by an address. |
167 * | 212 * |
168 * @param {number} addr Entry address. | 213 * @param {number} addr Entry address. |
169 */ | 214 */ |
170 devtools.profiler.Profile.prototype.findEntry = function(addr) { | 215 devtools.profiler.Profile.prototype.findEntry = function(addr) { |
171 return this.codeMap_.findEntry(addr); | 216 return this.codeMap_.findEntry(addr); |
172 }; | 217 }; |
173 | 218 |
174 | 219 |
175 /** | 220 /** |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 400 |
356 | 401 |
357 /** | 402 /** |
358 * Returns raw node name (without type decoration). | 403 * Returns raw node name (without type decoration). |
359 */ | 404 */ |
360 devtools.profiler.Profile.DynamicCodeEntry.prototype.getRawName = function() { | 405 devtools.profiler.Profile.DynamicCodeEntry.prototype.getRawName = function() { |
361 return this.name; | 406 return this.name; |
362 }; | 407 }; |
363 | 408 |
364 | 409 |
| 410 devtools.profiler.Profile.DynamicCodeEntry.prototype.isJSFunction = function() { |
| 411 return this.type == "Function" || |
| 412 this.type == "LazyCompile" || |
| 413 this.type == "Script"; |
| 414 }; |
| 415 |
| 416 |
365 /** | 417 /** |
366 * Constructs a call graph. | 418 * Constructs a call graph. |
367 * | 419 * |
368 * @constructor | 420 * @constructor |
369 */ | 421 */ |
370 devtools.profiler.CallTree = function() { | 422 devtools.profiler.CallTree = function() { |
371 this.root_ = new devtools.profiler.CallTree.Node( | 423 this.root_ = new devtools.profiler.CallTree.Node( |
372 devtools.profiler.CallTree.ROOT_NODE_LABEL); | 424 devtools.profiler.CallTree.ROOT_NODE_LABEL); |
373 }; | 425 }; |
374 | 426 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 labels, opt_f) { | 682 labels, opt_f) { |
631 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { | 683 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { |
632 var child = curr.findChild(labels[pos]); | 684 var child = curr.findChild(labels[pos]); |
633 if (opt_f) { | 685 if (opt_f) { |
634 opt_f(child, pos); | 686 opt_f(child, pos); |
635 } | 687 } |
636 curr = child; | 688 curr = child; |
637 } | 689 } |
638 return curr; | 690 return curr; |
639 }; | 691 }; |
OLD | NEW |