| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  155   // As code and functions are in the same address space, |  155   // As code and functions are in the same address space, | 
|  156   // it is safe to put them in a single code map. |  156   // it is safe to put them in a single code map. | 
|  157   var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr); |  157   var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr); | 
|  158   if (!func) { |  158   if (!func) { | 
|  159     func = new Profile.FunctionEntry(name); |  159     func = new Profile.FunctionEntry(name); | 
|  160     this.codeMap_.addCode(funcAddr, func); |  160     this.codeMap_.addCode(funcAddr, func); | 
|  161   } else if (func.name !== name) { |  161   } else if (func.name !== name) { | 
|  162     // Function object has been overwritten with a new one. |  162     // Function object has been overwritten with a new one. | 
|  163     func.name = name; |  163     func.name = name; | 
|  164   } |  164   } | 
|  165   var entry = new Profile.DynamicFuncCodeEntry(size, type, func, state); |  165   var entry = this.codeMap_.findDynamicEntryByStartAddress(start); | 
|  166   this.codeMap_.addCode(start, entry); |  166   if (entry) { | 
 |  167     if (entry.size === size && entry.func === func) { | 
 |  168       // Entry state has changed. | 
 |  169       entry.state = state; | 
 |  170     } | 
 |  171   } else { | 
 |  172     entry = new Profile.DynamicFuncCodeEntry(size, type, func, state); | 
 |  173     this.codeMap_.addCode(start, entry); | 
 |  174   } | 
|  167   return entry; |  175   return entry; | 
|  168 }; |  176 }; | 
|  169  |  177  | 
|  170  |  178  | 
|  171 /** |  179 /** | 
|  172  * Reports about moving of a dynamic code entry. |  180  * Reports about moving of a dynamic code entry. | 
|  173  * |  181  * | 
|  174  * @param {number} from Current code entry address. |  182  * @param {number} from Current code entry address. | 
|  175  * @param {number} to New code entry address. |  183  * @param {number} to New code entry address. | 
|  176  */ |  184  */ | 
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  401 Profile.DynamicCodeEntry.prototype.getRawName = function() { |  409 Profile.DynamicCodeEntry.prototype.getRawName = function() { | 
|  402   return this.name; |  410   return this.name; | 
|  403 }; |  411 }; | 
|  404  |  412  | 
|  405  |  413  | 
|  406 Profile.DynamicCodeEntry.prototype.isJSFunction = function() { |  414 Profile.DynamicCodeEntry.prototype.isJSFunction = function() { | 
|  407   return false; |  415   return false; | 
|  408 }; |  416 }; | 
|  409  |  417  | 
|  410  |  418  | 
 |  419 Profile.DynamicCodeEntry.prototype.toString = function() { | 
 |  420   return this.getName() + ': ' + this.size.toString(16); | 
 |  421 }; | 
 |  422  | 
 |  423  | 
|  411 /** |  424 /** | 
|  412  * Creates a dynamic code entry. |  425  * Creates a dynamic code entry. | 
|  413  * |  426  * | 
|  414  * @param {number} size Code size. |  427  * @param {number} size Code size. | 
|  415  * @param {string} type Code type. |  428  * @param {string} type Code type. | 
|  416  * @param {Profile.FunctionEntry} func Shared function entry. |  429  * @param {Profile.FunctionEntry} func Shared function entry. | 
|  417  * @param {Profile.CodeState} state Code optimization state. |  430  * @param {Profile.CodeState} state Code optimization state. | 
|  418  * @constructor |  431  * @constructor | 
|  419  */ |  432  */ | 
|  420 Profile.DynamicFuncCodeEntry = function(size, type, func, state) { |  433 Profile.DynamicFuncCodeEntry = function(size, type, func, state) { | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  441 Profile.DynamicFuncCodeEntry.prototype.getRawName = function() { |  454 Profile.DynamicFuncCodeEntry.prototype.getRawName = function() { | 
|  442   return this.func.getName(); |  455   return this.func.getName(); | 
|  443 }; |  456 }; | 
|  444  |  457  | 
|  445  |  458  | 
|  446 Profile.DynamicFuncCodeEntry.prototype.isJSFunction = function() { |  459 Profile.DynamicFuncCodeEntry.prototype.isJSFunction = function() { | 
|  447   return true; |  460   return true; | 
|  448 }; |  461 }; | 
|  449  |  462  | 
|  450  |  463  | 
 |  464 Profile.DynamicFuncCodeEntry.prototype.toString = function() { | 
 |  465   return this.getName() + ': ' + this.size.toString(16); | 
 |  466 }; | 
 |  467  | 
 |  468  | 
|  451 /** |  469 /** | 
|  452  * Creates a shared function object entry. |  470  * Creates a shared function object entry. | 
|  453  * |  471  * | 
|  454  * @param {string} name Function name. |  472  * @param {string} name Function name. | 
|  455  * @constructor |  473  * @constructor | 
|  456  */ |  474  */ | 
|  457 Profile.FunctionEntry = function(name) { |  475 Profile.FunctionEntry = function(name) { | 
|  458   CodeMap.CodeEntry.call(this, 0, name); |  476   CodeMap.CodeEntry.call(this, 0, name); | 
|  459 }; |  477 }; | 
|  460  |  478  | 
|  461  |  479  | 
|  462 /** |  480 /** | 
|  463  * Returns node name. |  481  * Returns node name. | 
|  464  */ |  482  */ | 
|  465 Profile.FunctionEntry.prototype.getName = function() { |  483 Profile.FunctionEntry.prototype.getName = function() { | 
|  466   var name = this.name; |  484   var name = this.name; | 
|  467   if (name.length == 0) { |  485   if (name.length == 0) { | 
|  468     name = '<anonymous>'; |  486     name = '<anonymous>'; | 
|  469   } else if (name.charAt(0) == ' ') { |  487   } else if (name.charAt(0) == ' ') { | 
|  470     // An anonymous function with location: " aaa.js:10". |  488     // An anonymous function with location: " aaa.js:10". | 
|  471     name = '<anonymous>' + name; |  489     name = '<anonymous>' + name; | 
|  472   } |  490   } | 
|  473   return name; |  491   return name; | 
|  474 }; |  492 }; | 
|  475  |  493  | 
 |  494 Profile.FunctionEntry.prototype.toString = CodeMap.CodeEntry.prototype.toString; | 
|  476  |  495  | 
|  477 /** |  496 /** | 
|  478  * Constructs a call graph. |  497  * Constructs a call graph. | 
|  479  * |  498  * | 
|  480  * @constructor |  499  * @constructor | 
|  481  */ |  500  */ | 
|  482 function CallTree() { |  501 function CallTree() { | 
|  483   this.root_ = new CallTree.Node( |  502   this.root_ = new CallTree.Node( | 
|  484       CallTree.ROOT_NODE_LABEL); |  503       CallTree.ROOT_NODE_LABEL); | 
|  485 }; |  504 }; | 
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  742     labels, opt_f) { |  761     labels, opt_f) { | 
|  743   for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { |  762   for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { | 
|  744     var child = curr.findChild(labels[pos]); |  763     var child = curr.findChild(labels[pos]); | 
|  745     if (opt_f) { |  764     if (opt_f) { | 
|  746       opt_f(child, pos); |  765       opt_f(child, pos); | 
|  747     } |  766     } | 
|  748     curr = child; |  767     curr = child; | 
|  749   } |  768   } | 
|  750   return curr; |  769   return curr; | 
|  751 }; |  770 }; | 
| OLD | NEW |