| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 service; | 5 part of service; |
| 6 | 6 |
| 7 /// State for a running isolate. | 7 /// State for a running isolate. |
| 8 class Isolate extends ServiceObject { | 8 class Isolate extends ServiceObject { |
| 9 final VM vm; | 9 final VM vm; |
| 10 String get link => _id; | 10 String get link => _id; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 assert(profile.serviceType == 'Profile'); | 54 assert(profile.serviceType == 'Profile'); |
| 55 var codeTable = new List<Code>(); | 55 var codeTable = new List<Code>(); |
| 56 var codeRegions = profile['codes']; | 56 var codeRegions = profile['codes']; |
| 57 for (var codeRegion in codeRegions) { | 57 for (var codeRegion in codeRegions) { |
| 58 Code code = codeRegion['code']; | 58 Code code = codeRegion['code']; |
| 59 assert(code != null); | 59 assert(code != null); |
| 60 codeTable.add(code); | 60 codeTable.add(code); |
| 61 } | 61 } |
| 62 _codes._resetProfileData(); | 62 _codes._resetProfileData(); |
| 63 _codes._updateProfileData(profile, codeTable); | 63 _codes._updateProfileData(profile, codeTable); |
| 64 var exclusiveTrie = profile['exclusive_trie']; |
| 65 if (exclusiveTrie != null) { |
| 66 profileTrieRoot = _processProfileTrie(exclusiveTrie, codeTable); |
| 67 } |
| 64 } | 68 } |
| 65 | 69 |
| 66 Future<ServiceObject> getDirect(String serviceId) { | 70 Future<ServiceObject> getDirect(String serviceId) { |
| 67 return vm.getAsMap(relativeLink(serviceId)).then((ObservableMap m) { | 71 return vm.getAsMap(relativeLink(serviceId)).then((ObservableMap m) { |
| 68 return _upgradeToServiceObject(vm, this, m); | 72 return _upgradeToServiceObject(vm, this, m); |
| 69 }); | 73 }); |
| 70 } | 74 } |
| 71 | 75 |
| 72 /// Requests [serviceId] from [this]. Completes to a [ServiceObject]. | 76 /// Requests [serviceId] from [this]. Completes to a [ServiceObject]. |
| 73 /// Can return pre-existing, cached, [ServiceObject]s. | 77 /// Can return pre-existing, cached, [ServiceObject]s. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | 139 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. |
| 136 timers['init'] = (timerMap['time_script_loading'] + | 140 timers['init'] = (timerMap['time_script_loading'] + |
| 137 timerMap['time_creating_snapshot'] + | 141 timerMap['time_creating_snapshot'] + |
| 138 timerMap['time_isolate_initialization'] + | 142 timerMap['time_isolate_initialization'] + |
| 139 timerMap['time_bootstrap']); | 143 timerMap['time_bootstrap']); |
| 140 timers['dart'] = timerMap['time_dart_execution']; | 144 timers['dart'] = timerMap['time_dart_execution']; |
| 141 | 145 |
| 142 newHeapUsed = map['heap']['usedNew']; | 146 newHeapUsed = map['heap']['usedNew']; |
| 143 oldHeapUsed = map['heap']['usedOld']; | 147 oldHeapUsed = map['heap']['usedOld']; |
| 144 } | 148 } |
| 149 |
| 150 @reflectable CodeTrieNode profileTrieRoot; |
| 151 int _trieDataCursor; |
| 152 List<int> _trieData; |
| 153 CodeTrieNode _readTrieNode(List<Code> codeTable) { |
| 154 var index = _trieData[_trieDataCursor++]; |
| 155 var code = codeTable[index]; |
| 156 var count = _trieData[_trieDataCursor++]; |
| 157 var children = _trieData[_trieDataCursor++]; |
| 158 var node = new CodeTrieNode(code, count); |
| 159 for (var i = 0; i < children; i++) { |
| 160 var child = _readTrieNode(codeTable); |
| 161 node.children.add(child); |
| 162 node.summedChildCount += child.count; |
| 163 } |
| 164 return node; |
| 165 } |
| 166 |
| 167 CodeTrieNode _processProfileTrie(List<int> data, List<Code> codeTable) { |
| 168 _trieDataCursor = 0; |
| 169 _trieData = data; |
| 170 if (_trieData == null) { |
| 171 return null; |
| 172 } |
| 173 if (_trieData.length < 3) { |
| 174 return null; |
| 175 } |
| 176 return _readTrieNode(codeTable); |
| 177 } |
| 145 } | 178 } |
| 146 | 179 |
| 147 // TODO(johnmccutchan): Make this into an IsolateCache. | 180 // TODO(johnmccutchan): Make this into an IsolateCache. |
| 148 class IsolateList extends ServiceObject { | 181 class IsolateList extends ServiceObject { |
| 149 final VM _vm; | 182 final VM _vm; |
| 150 VM get vm => _vm; | 183 VM get vm => _vm; |
| 151 @observable final isolates = new ObservableMap<String, Isolate>(); | 184 @observable final isolates = new ObservableMap<String, Isolate>(); |
| 152 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { | 185 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { |
| 153 name = 'IsolateList'; | 186 name = 'IsolateList'; |
| 154 vmName = name; | 187 vmName = name; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 476 |
| 444 static CodeKind fromString(String s) { | 477 static CodeKind fromString(String s) { |
| 445 if (s == 'Native') { | 478 if (s == 'Native') { |
| 446 return Native; | 479 return Native; |
| 447 } else if (s == 'Dart') { | 480 } else if (s == 'Dart') { |
| 448 return Dart; | 481 return Dart; |
| 449 } else if (s == 'Collected') { | 482 } else if (s == 'Collected') { |
| 450 return Collected; | 483 return Collected; |
| 451 } else if (s == 'Reused') { | 484 } else if (s == 'Reused') { |
| 452 return Reused; | 485 return Reused; |
| 486 } else if (s == 'Tag') { |
| 487 return Tag; |
| 453 } | 488 } |
| 454 Logger.root.warning('Unknown code kind $s'); | 489 Logger.root.warning('Unknown code kind $s'); |
| 455 throw new FallThroughError(); | 490 throw new FallThroughError(); |
| 456 } | 491 } |
| 457 static const Native = const CodeKind._internal('Native'); | 492 static const Native = const CodeKind._internal('Native'); |
| 458 static const Dart = const CodeKind._internal('Dart'); | 493 static const Dart = const CodeKind._internal('Dart'); |
| 459 static const Collected = const CodeKind._internal('Collected'); | 494 static const Collected = const CodeKind._internal('Collected'); |
| 460 static const Reused = const CodeKind._internal('Reused'); | 495 static const Reused = const CodeKind._internal('Reused'); |
| 496 static const Tag = const CodeKind._internal('Tag'); |
| 461 } | 497 } |
| 462 | 498 |
| 463 class CodeCallCount { | 499 class CodeCallCount { |
| 464 final Code code; | 500 final Code code; |
| 465 final int count; | 501 final int count; |
| 466 CodeCallCount(this.code, this.count); | 502 CodeCallCount(this.code, this.count); |
| 467 } | 503 } |
| 468 | 504 |
| 505 class CodeTrieNode { |
| 506 final Code code; |
| 507 final int count; |
| 508 final children = new List<CodeTrieNode>(); |
| 509 int summedChildCount = 0; |
| 510 CodeTrieNode(this.code, this.count); |
| 511 } |
| 512 |
| 469 class Code extends ServiceObject { | 513 class Code extends ServiceObject { |
| 470 @observable CodeKind kind; | 514 @observable CodeKind kind; |
| 471 @observable int totalSamplesInProfile = 0; | 515 @observable int totalSamplesInProfile = 0; |
| 472 @reflectable int exclusiveTicks = 0; | 516 @reflectable int exclusiveTicks = 0; |
| 473 @reflectable int inclusiveTicks = 0; | 517 @reflectable int inclusiveTicks = 0; |
| 474 @reflectable int startAddress = 0; | 518 @reflectable int startAddress = 0; |
| 475 @reflectable int endAddress = 0; | 519 @reflectable int endAddress = 0; |
| 476 @reflectable final callers = new List<CodeCallCount>(); | 520 @reflectable final callers = new List<CodeCallCount>(); |
| 477 @reflectable final callees = new List<CodeCallCount>(); | 521 @reflectable final callees = new List<CodeCallCount>(); |
| 478 @reflectable final instructions = new ObservableList<CodeInstruction>(); | 522 @reflectable final instructions = new ObservableList<CodeInstruction>(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 673 |
| 630 int _callCount(List<CodeCallCount> calls, Code code) { | 674 int _callCount(List<CodeCallCount> calls, Code code) { |
| 631 for (CodeCallCount caller in calls) { | 675 for (CodeCallCount caller in calls) { |
| 632 if (caller.code == code) { | 676 if (caller.code == code) { |
| 633 return caller.count; | 677 return caller.count; |
| 634 } | 678 } |
| 635 } | 679 } |
| 636 return 0; | 680 return 0; |
| 637 } | 681 } |
| 638 } | 682 } |
| OLD | NEW |