| 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 18 matching lines...) Expand all Loading... |
| 29 /** | 29 /** |
| 30 * Creates a profile object for processing profiling-related events | 30 * Creates a profile object for processing profiling-related events |
| 31 * and calculating function execution times. | 31 * and calculating function execution times. |
| 32 * | 32 * |
| 33 * @constructor | 33 * @constructor |
| 34 */ | 34 */ |
| 35 function Profile() { | 35 function Profile() { |
| 36 this.codeMap_ = new CodeMap(); | 36 this.codeMap_ = new CodeMap(); |
| 37 this.topDownTree_ = new CallTree(); | 37 this.topDownTree_ = new CallTree(); |
| 38 this.bottomUpTree_ = new CallTree(); | 38 this.bottomUpTree_ = new CallTree(); |
| 39 this.generatedCode = 0; |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 | 42 |
| 42 /** | 43 /** |
| 43 * Returns whether a function with the specified name must be skipped. | 44 * Returns whether a function with the specified name must be skipped. |
| 44 * Should be overriden by subclasses. | 45 * Should be overriden by subclasses. |
| 45 * | 46 * |
| 46 * @param {string} name Function name. | 47 * @param {string} name Function name. |
| 47 */ | 48 */ |
| 48 Profile.prototype.skipThisFunction = function(name) { | 49 Profile.prototype.skipThisFunction = function(name) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 /** | 128 /** |
| 128 * Registers dynamic (JIT-compiled) code entry. | 129 * Registers dynamic (JIT-compiled) code entry. |
| 129 * | 130 * |
| 130 * @param {string} type Code entry type. | 131 * @param {string} type Code entry type. |
| 131 * @param {string} name Code entry name. | 132 * @param {string} name Code entry name. |
| 132 * @param {number} start Starting address. | 133 * @param {number} start Starting address. |
| 133 * @param {number} size Code entry size. | 134 * @param {number} size Code entry size. |
| 134 */ | 135 */ |
| 135 Profile.prototype.addCode = function( | 136 Profile.prototype.addCode = function( |
| 136 type, name, start, size) { | 137 type, name, start, size) { |
| 138 this.generatedCode += size; |
| 137 var entry = new Profile.DynamicCodeEntry(size, type, name); | 139 var entry = new Profile.DynamicCodeEntry(size, type, name); |
| 138 this.codeMap_.addCode(start, entry); | 140 this.codeMap_.addCode(start, entry); |
| 139 return entry; | 141 return entry; |
| 140 }; | 142 }; |
| 141 | 143 |
| 142 | 144 |
| 143 /** | 145 /** |
| 144 * Registers dynamic (JIT-compiled) code entry. | 146 * Registers dynamic (JIT-compiled) code entry. |
| 145 * | 147 * |
| 146 * @param {string} type Code entry type. | 148 * @param {string} type Code entry type. |
| 147 * @param {string} name Code entry name. | 149 * @param {string} name Code entry name. |
| 148 * @param {number} start Starting address. | 150 * @param {number} start Starting address. |
| 149 * @param {number} size Code entry size. | 151 * @param {number} size Code entry size. |
| 150 * @param {number} funcAddr Shared function object address. | 152 * @param {number} funcAddr Shared function object address. |
| 151 * @param {Profile.CodeState} state Optimization state. | 153 * @param {Profile.CodeState} state Optimization state. |
| 152 */ | 154 */ |
| 153 Profile.prototype.addFuncCode = function( | 155 Profile.prototype.addFuncCode = function( |
| 154 type, name, start, size, funcAddr, state) { | 156 type, name, start, size, funcAddr, state) { |
| 155 // As code and functions are in the same address space, | 157 // As code and functions are in the same address space, |
| 156 // it is safe to put them in a single code map. | 158 // it is safe to put them in a single code map. |
| 159 this.generatedCode += size; |
| 157 var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr); | 160 var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr); |
| 158 if (!func) { | 161 if (!func) { |
| 159 func = new Profile.FunctionEntry(name); | 162 func = new Profile.FunctionEntry(name); |
| 160 this.codeMap_.addCode(funcAddr, func); | 163 this.codeMap_.addCode(funcAddr, func); |
| 161 } else if (func.name !== name) { | 164 } else if (func.name !== name) { |
| 162 // Function object has been overwritten with a new one. | 165 // Function object has been overwritten with a new one. |
| 163 func.name = name; | 166 func.name = name; |
| 164 } | 167 } |
| 165 var entry = this.codeMap_.findDynamicEntryByStartAddress(start); | 168 var entry = this.codeMap_.findDynamicEntryByStartAddress(start); |
| 166 if (entry) { | 169 if (entry) { |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 labels, opt_f) { | 789 labels, opt_f) { |
| 787 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { | 790 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { |
| 788 var child = curr.findChild(labels[pos]); | 791 var child = curr.findChild(labels[pos]); |
| 789 if (opt_f) { | 792 if (opt_f) { |
| 790 opt_f(child, pos); | 793 opt_f(child, pos); |
| 791 } | 794 } |
| 792 curr = child; | 795 curr = child; |
| 793 } | 796 } |
| 794 return curr; | 797 return curr; |
| 795 }; | 798 }; |
| OLD | NEW |