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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 * @param {Array<number>} stack Stack sample. | 250 * @param {Array<number>} stack Stack sample. |
251 */ | 251 */ |
252 Profile.prototype.resolveAndFilterFuncs_ = function(stack) { | 252 Profile.prototype.resolveAndFilterFuncs_ = function(stack) { |
253 var result = []; | 253 var result = []; |
254 var last_seen_c_function = ''; | 254 var last_seen_c_function = ''; |
255 var look_for_first_c_function = false; | 255 var look_for_first_c_function = false; |
256 for (var i = 0; i < stack.length; ++i) { | 256 for (var i = 0; i < stack.length; ++i) { |
257 var entry = this.codeMap_.findEntry(stack[i]); | 257 var entry = this.codeMap_.findEntry(stack[i]); |
258 if (entry) { | 258 if (entry) { |
259 var name = entry.getName(); | 259 var name = entry.getName(); |
260 if (i == 0 && (entry.type == 'CPP' || entry.type == 'SHARED_LIB')) { | 260 if (i === 0 && (entry.type === 'CPP' || entry.type === 'SHARED_LIB')) { |
261 look_for_first_c_function = true; | 261 look_for_first_c_function = true; |
262 } | 262 } |
263 if (look_for_first_c_function) { | 263 if (look_for_first_c_function && entry.type === 'CPP') { |
264 if (entry.type == 'CPP') { | 264 last_seen_c_function = name; |
265 last_seen_c_function = name; | |
266 } else if (i > 0 && last_seen_c_function != '') { | |
267 if (this.c_entries_[last_seen_c_function] === undefined) { | |
268 this.c_entries_[last_seen_c_function] = 0; | |
269 } | |
270 this.c_entries_[last_seen_c_function]++; | |
271 look_for_first_c_function = false; // Found it, we're done. | |
272 } | |
273 } | 265 } |
274 if (!this.skipThisFunction(name)) { | 266 if (!this.skipThisFunction(name)) { |
275 result.push(name); | 267 result.push(name); |
276 } | 268 } |
277 } else { | 269 } else { |
278 this.handleUnknownCode( | 270 this.handleUnknownCode(Profile.Operation.TICK, stack[i], i); |
279 Profile.Operation.TICK, stack[i], i); | 271 if (i === 0) result.push("UNKNOWN"); |
| 272 } |
| 273 if (look_for_first_c_function && |
| 274 i > 0 && |
| 275 (!entry || entry.type !== 'CPP') && |
| 276 last_seen_c_function !== '') { |
| 277 if (this.c_entries_[last_seen_c_function] === undefined) { |
| 278 this.c_entries_[last_seen_c_function] = 0; |
| 279 } |
| 280 this.c_entries_[last_seen_c_function]++; |
| 281 look_for_first_c_function = false; // Found it, we're done. |
280 } | 282 } |
281 } | 283 } |
282 return result; | 284 return result; |
283 }; | 285 }; |
284 | 286 |
285 | 287 |
286 /** | 288 /** |
287 * Performs a BF traversal of the top down call graph. | 289 * Performs a BF traversal of the top down call graph. |
288 * | 290 * |
289 * @param {function(CallTree.Node)} f Visitor function. | 291 * @param {function(CallTree.Node)} f Visitor function. |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 labels, opt_f) { | 825 labels, opt_f) { |
824 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { | 826 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { |
825 var child = curr.findChild(labels[pos]); | 827 var child = curr.findChild(labels[pos]); |
826 if (opt_f) { | 828 if (opt_f) { |
827 opt_f(child, pos); | 829 opt_f(child, pos); |
828 } | 830 } |
829 curr = child; | 831 curr = child; |
830 } | 832 } |
831 return curr; | 833 return curr; |
832 }; | 834 }; |
OLD | NEW |