| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of cpu_profiler; | 5 part of cpu_profiler; |
| 6 | 6 |
| 7 abstract class CallTreeNode { | 7 abstract class CallTreeNode { |
| 8 final List<CallTreeNode> children; | 8 final List<CallTreeNode> children; |
| 9 final int count; | 9 final int count; |
| 10 double get percentage => _percentage; | 10 double get percentage => _percentage; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Does this function have an unoptimized version of itself? | 129 // Does this function have an unoptimized version of itself? |
| 130 bool hasUnoptimizedCode() { | 130 bool hasUnoptimizedCode() { |
| 131 for (var nodeCode in codes) { | 131 for (var nodeCode in codes) { |
| 132 var profileCode = nodeCode.code; | 132 var profileCode = nodeCode.code; |
| 133 if (!profileCode.code.isDartCode) { | 133 if (!profileCode.code.isDartCode) { |
| 134 continue; | 134 continue; |
| 135 } | 135 } |
| 136 if (profileCode.code.kind == CodeKind.Stub) { | 136 if (profileCode.code.kind == M.CodeKind.stub) { |
| 137 continue; | 137 continue; |
| 138 } | 138 } |
| 139 if (!profileCode.code.isOptimized) { | 139 if (!profileCode.code.isOptimized) { |
| 140 return true; | 140 return true; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Has this function been inlined in another function? | 146 // Has this function been inlined in another function? |
| 147 bool isInlined() { | 147 bool isInlined() { |
| 148 for (var nodeCode in codes) { | 148 for (var nodeCode in codes) { |
| 149 var profileCode = nodeCode.code; | 149 var profileCode = nodeCode.code; |
| 150 if (!profileCode.code.isDartCode) { | 150 if (!profileCode.code.isDartCode) { |
| 151 continue; | 151 continue; |
| 152 } | 152 } |
| 153 if (profileCode.code.kind == CodeKind.Stub) { | 153 if (profileCode.code.kind == M.CodeKind.stub) { |
| 154 continue; | 154 continue; |
| 155 } | 155 } |
| 156 // If the code's function isn't this function. | 156 // If the code's function isn't this function. |
| 157 if (profileCode.code.function != profileFunction.function) { | 157 if (profileCode.code.function != profileFunction.function) { |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 | 163 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 | 414 |
| 415 ProfileCode.fromMap(this.profile, this.code, Map data) { | 415 ProfileCode.fromMap(this.profile, this.code, Map data) { |
| 416 assert(profile != null); | 416 assert(profile != null); |
| 417 assert(code != null); | 417 assert(code != null); |
| 418 | 418 |
| 419 code.profile = this; | 419 code.profile = this; |
| 420 | 420 |
| 421 if (code.kind == CodeKind.Stub) { | 421 if (code.kind == M.CodeKind.stub) { |
| 422 attributes.add('stub'); | 422 attributes.add('stub'); |
| 423 } else if (code.kind == CodeKind.Dart) { | 423 } else if (code.kind == M.CodeKind.dart) { |
| 424 if (code.isNative) { | 424 if (code.isNative) { |
| 425 attributes.add('ffi'); // Not to be confused with a C function. | 425 attributes.add('ffi'); // Not to be confused with a C function. |
| 426 } else { | 426 } else { |
| 427 attributes.add('dart'); | 427 attributes.add('dart'); |
| 428 } | 428 } |
| 429 if (code.hasIntrinsic) { | 429 if (code.hasIntrinsic) { |
| 430 attributes.add('intrinsic'); | 430 attributes.add('intrinsic'); |
| 431 } | 431 } |
| 432 if (code.isOptimized) { | 432 if (code.isOptimized) { |
| 433 attributes.add('optimized'); | 433 attributes.add('optimized'); |
| 434 } else { | 434 } else { |
| 435 attributes.add('unoptimized'); | 435 attributes.add('unoptimized'); |
| 436 } | 436 } |
| 437 } else if (code.kind == CodeKind.Tag) { | 437 } else if (code.kind == M.CodeKind.tag) { |
| 438 attributes.add('tag'); | 438 attributes.add('tag'); |
| 439 } else if (code.kind == CodeKind.Native) { | 439 } else if (code.kind == M.CodeKind.native) { |
| 440 attributes.add('native'); | 440 attributes.add('native'); |
| 441 } | 441 } |
| 442 inclusiveTicks = int.parse(data['inclusiveTicks']); | 442 inclusiveTicks = int.parse(data['inclusiveTicks']); |
| 443 exclusiveTicks = int.parse(data['exclusiveTicks']); | 443 exclusiveTicks = int.parse(data['exclusiveTicks']); |
| 444 | 444 |
| 445 normalizedExclusiveTicks = exclusiveTicks / profile.sampleCount; | 445 normalizedExclusiveTicks = exclusiveTicks / profile.sampleCount; |
| 446 | 446 |
| 447 normalizedInclusiveTicks = inclusiveTicks / profile.sampleCount; | 447 normalizedInclusiveTicks = inclusiveTicks / profile.sampleCount; |
| 448 | 448 |
| 449 var ticks = data['ticks']; | 449 var ticks = data['ticks']; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 if (profileCode.code.isOptimized) { | 530 if (profileCode.code.isOptimized) { |
| 531 return true; | 531 return true; |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 return false; | 534 return false; |
| 535 } | 535 } |
| 536 | 536 |
| 537 // Does this function have an unoptimized version of itself? | 537 // Does this function have an unoptimized version of itself? |
| 538 bool hasUnoptimizedCode() { | 538 bool hasUnoptimizedCode() { |
| 539 for (var profileCode in profileCodes) { | 539 for (var profileCode in profileCodes) { |
| 540 if (profileCode.code.kind == CodeKind.Stub) { | 540 if (profileCode.code.kind == M.CodeKind.stub) { |
| 541 continue; | 541 continue; |
| 542 } | 542 } |
| 543 if (!profileCode.code.isDartCode) { | 543 if (!profileCode.code.isDartCode) { |
| 544 continue; | 544 continue; |
| 545 } | 545 } |
| 546 if (!profileCode.code.isOptimized) { | 546 if (!profileCode.code.isOptimized) { |
| 547 return true; | 547 return true; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 return false; | 550 return false; |
| 551 } | 551 } |
| 552 | 552 |
| 553 // Has this function been inlined in another function? | 553 // Has this function been inlined in another function? |
| 554 bool isInlined() { | 554 bool isInlined() { |
| 555 for (var profileCode in profileCodes) { | 555 for (var profileCode in profileCodes) { |
| 556 if (profileCode.code.kind == CodeKind.Stub) { | 556 if (profileCode.code.kind == M.CodeKind.stub) { |
| 557 continue; | 557 continue; |
| 558 } | 558 } |
| 559 if (!profileCode.code.isDartCode) { | 559 if (!profileCode.code.isDartCode) { |
| 560 continue; | 560 continue; |
| 561 } | 561 } |
| 562 // If the code's function isn't this function. | 562 // If the code's function isn't this function. |
| 563 if (profileCode.code.function != function) { | 563 if (profileCode.code.function != function) { |
| 564 return true; | 564 return true; |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 return false; | 567 return false; |
| 568 } | 568 } |
| 569 | 569 |
| 570 void _addKindBasedAttributes(Set<String> attribs) { | 570 void _addKindBasedAttributes(Set<String> attribs) { |
| 571 if (function.kind == FunctionKind.kTag) { | 571 if (function.kind == M.FunctionKind.tag) { |
| 572 attribs.add('tag'); | 572 attribs.add('tag'); |
| 573 } else if (function.kind == FunctionKind.kStub) { | 573 } else if (function.kind == M.FunctionKind.stub) { |
| 574 attribs.add('stub'); | 574 attribs.add('stub'); |
| 575 } else if (function.kind == FunctionKind.kNative) { | 575 } else if (function.kind == M.FunctionKind.native) { |
| 576 attribs.add('native'); | 576 attribs.add('native'); |
| 577 } else if (function.kind.isSynthetic()) { | 577 } else if (M.isSyntheticFunction(function.kind)) { |
| 578 attribs.add('synthetic'); | 578 attribs.add('synthetic'); |
| 579 } else if (function.isNative) { | 579 } else if (function.isNative) { |
| 580 attribs.add('ffi'); // Not to be confused with a C function. | 580 attribs.add('ffi'); // Not to be confused with a C function. |
| 581 } else { | 581 } else { |
| 582 attribs.add('dart'); | 582 attribs.add('dart'); |
| 583 } | 583 } |
| 584 if (function.hasIntrinsic == true) { | 584 if (function.hasIntrinsic == true) { |
| 585 attribs.add('intrinsic'); | 585 attribs.add('intrinsic'); |
| 586 } | 586 } |
| 587 } | 587 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 int approximateMillisecondsForCount(count) { | 920 int approximateMillisecondsForCount(count) { |
| 921 var MICROSECONDS_PER_MILLISECOND = 1000.0; | 921 var MICROSECONDS_PER_MILLISECOND = 1000.0; |
| 922 return (count * samplePeriod) ~/ MICROSECONDS_PER_MILLISECOND; | 922 return (count * samplePeriod) ~/ MICROSECONDS_PER_MILLISECOND; |
| 923 } | 923 } |
| 924 | 924 |
| 925 double approximateSecondsForCount(count) { | 925 double approximateSecondsForCount(count) { |
| 926 var MICROSECONDS_PER_SECOND = 1000000.0; | 926 var MICROSECONDS_PER_SECOND = 1000000.0; |
| 927 return (count * samplePeriod) / MICROSECONDS_PER_SECOND; | 927 return (count * samplePeriod) / MICROSECONDS_PER_SECOND; |
| 928 } | 928 } |
| 929 } | 929 } |
| OLD | NEW |