Chromium Code Reviews| 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 /// Requests [serviceId] from [this]. Completes to a [ServiceObject]. | 70 /// Requests [serviceId] from [this]. Completes to a [ServiceObject]. |
| 67 /// Can return pre-existing, cached, [ServiceObject]s. | 71 /// Can return pre-existing, cached, [ServiceObject]s. |
| 68 Future<ServiceObject> get(String serviceId) { | 72 Future<ServiceObject> get(String serviceId) { |
| 69 if (_scripts.cachesId(serviceId)) { | 73 if (_scripts.cachesId(serviceId)) { |
| 70 return _scripts.get(serviceId); | 74 return _scripts.get(serviceId); |
| 71 } | 75 } |
| 72 if (_codes.cachesId(serviceId)) { | 76 if (_codes.cachesId(serviceId)) { |
| 73 return _codes.get(serviceId); | 77 return _codes.get(serviceId); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | 135 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. |
| 132 timers['init'] = (timerMap['time_script_loading'] + | 136 timers['init'] = (timerMap['time_script_loading'] + |
| 133 timerMap['time_creating_snapshot'] + | 137 timerMap['time_creating_snapshot'] + |
| 134 timerMap['time_isolate_initialization'] + | 138 timerMap['time_isolate_initialization'] + |
| 135 timerMap['time_bootstrap']); | 139 timerMap['time_bootstrap']); |
| 136 timers['dart'] = timerMap['time_dart_execution']; | 140 timers['dart'] = timerMap['time_dart_execution']; |
| 137 | 141 |
| 138 newHeapUsed = map['heap']['usedNew']; | 142 newHeapUsed = map['heap']['usedNew']; |
| 139 oldHeapUsed = map['heap']['usedOld']; | 143 oldHeapUsed = map['heap']['usedOld']; |
| 140 } | 144 } |
| 145 | |
| 146 @reflectable CodeTrieNode profileTrieRoot; | |
| 147 int _trieDataCursor; | |
| 148 List<int> _trieData; | |
| 149 CodeTrieNode _readTrieNode(List<Code> codeTable) { | |
|
turnidge
2014/03/17 21:19:31
Consider adding a comment describing the trie data
Cutch
2014/03/18 14:39:19
Done.
| |
| 150 var index = _trieData[_trieDataCursor++]; | |
| 151 var code = codeTable[index]; | |
| 152 var count = _trieData[_trieDataCursor++]; | |
| 153 var children = _trieData[_trieDataCursor++]; | |
| 154 var node = new CodeTrieNode(code, count); | |
| 155 for (var i = 0; i < children; i++) { | |
| 156 var child = _readTrieNode(codeTable); | |
| 157 node.children.add(child); | |
| 158 node.summedChildCount += child.count; | |
| 159 } | |
| 160 return node; | |
| 161 } | |
| 162 | |
| 163 CodeTrieNode _processProfileTrie(List<int> data, List<Code> codeTable) { | |
| 164 _trieDataCursor = 0; | |
| 165 _trieData = data; | |
| 166 if (_trieData == null) { | |
| 167 return null; | |
| 168 } | |
| 169 if (_trieData.length < 3) { | |
| 170 return null; | |
| 171 } | |
| 172 return _readTrieNode(codeTable); | |
| 173 } | |
| 141 } | 174 } |
| 142 | 175 |
| 143 // TODO(johnmccutchan): Make this into an IsolateCache. | 176 // TODO(johnmccutchan): Make this into an IsolateCache. |
| 144 class IsolateList extends ServiceObject { | 177 class IsolateList extends ServiceObject { |
| 145 final VM _vm; | 178 final VM _vm; |
| 146 VM get vm => _vm; | 179 VM get vm => _vm; |
| 147 @observable final isolates = new ObservableMap<String, Isolate>(); | 180 @observable final isolates = new ObservableMap<String, Isolate>(); |
| 148 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { | 181 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { |
| 149 name = 'IsolateList'; | 182 name = 'IsolateList'; |
| 150 vmName = name; | 183 vmName = name; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 472 |
| 440 static CodeKind fromString(String s) { | 473 static CodeKind fromString(String s) { |
| 441 if (s == 'Native') { | 474 if (s == 'Native') { |
| 442 return Native; | 475 return Native; |
| 443 } else if (s == 'Dart') { | 476 } else if (s == 'Dart') { |
| 444 return Dart; | 477 return Dart; |
| 445 } else if (s == 'Collected') { | 478 } else if (s == 'Collected') { |
| 446 return Collected; | 479 return Collected; |
| 447 } else if (s == 'Reused') { | 480 } else if (s == 'Reused') { |
| 448 return Reused; | 481 return Reused; |
| 482 } else if (s == 'Tag') { | |
| 483 return Tag; | |
| 449 } | 484 } |
| 450 Logger.root.warning('Unknown code kind $s'); | 485 Logger.root.warning('Unknown code kind $s'); |
| 451 throw new FallThroughError(); | 486 throw new FallThroughError(); |
| 452 } | 487 } |
| 453 static const Native = const CodeKind._internal('Native'); | 488 static const Native = const CodeKind._internal('Native'); |
| 454 static const Dart = const CodeKind._internal('Dart'); | 489 static const Dart = const CodeKind._internal('Dart'); |
| 455 static const Collected = const CodeKind._internal('Collected'); | 490 static const Collected = const CodeKind._internal('Collected'); |
| 456 static const Reused = const CodeKind._internal('Reused'); | 491 static const Reused = const CodeKind._internal('Reused'); |
| 492 static const Tag = const CodeKind._internal('Tag'); | |
| 457 } | 493 } |
| 458 | 494 |
| 459 class CodeCallCount { | 495 class CodeCallCount { |
| 460 final Code code; | 496 final Code code; |
| 461 final int count; | 497 final int count; |
| 462 CodeCallCount(this.code, this.count); | 498 CodeCallCount(this.code, this.count); |
| 463 } | 499 } |
| 464 | 500 |
| 501 class CodeTrieNode { | |
| 502 final Code code; | |
| 503 final int count; | |
| 504 final children = new List<CodeTrieNode>(); | |
| 505 int summedChildCount = 0; | |
| 506 CodeTrieNode(this.code, this.count); | |
| 507 } | |
| 508 | |
| 465 class Code extends ServiceObject { | 509 class Code extends ServiceObject { |
| 466 @observable CodeKind kind; | 510 @observable CodeKind kind; |
| 467 @observable int totalSamplesInProfile = 0; | 511 @observable int totalSamplesInProfile = 0; |
| 468 @reflectable int exclusiveTicks = 0; | 512 @reflectable int exclusiveTicks = 0; |
| 469 @reflectable int inclusiveTicks = 0; | 513 @reflectable int inclusiveTicks = 0; |
| 470 @reflectable int startAddress = 0; | 514 @reflectable int startAddress = 0; |
| 471 @reflectable int endAddress = 0; | 515 @reflectable int endAddress = 0; |
| 472 @reflectable final callers = new List<CodeCallCount>(); | 516 @reflectable final callers = new List<CodeCallCount>(); |
| 473 @reflectable final callees = new List<CodeCallCount>(); | 517 @reflectable final callees = new List<CodeCallCount>(); |
| 474 @reflectable final instructions = new ObservableList<CodeInstruction>(); | 518 @reflectable final instructions = new ObservableList<CodeInstruction>(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 | 669 |
| 626 int _callCount(List<CodeCallCount> calls, Code code) { | 670 int _callCount(List<CodeCallCount> calls, Code code) { |
| 627 for (CodeCallCount caller in calls) { | 671 for (CodeCallCount caller in calls) { |
| 628 if (caller.code == code) { | 672 if (caller.code == code) { |
| 629 return caller.count; | 673 return caller.count; |
| 630 } | 674 } |
| 631 } | 675 } |
| 632 return 0; | 676 return 0; |
| 633 } | 677 } |
| 634 } | 678 } |
| OLD | NEW |