Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: runtime/bin/vmservice/client/lib/src/service/object.dart

Issue 201213004: Use VM tag in profile and add stack trace trie (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 // The profile trie is serialized as a list of integers. Each node
152 // is recreated by consuming some portion of the list. The format is as
153 // follows:
154 // [0] index into codeTable of code object.
155 // [1] tick count (number of times this stack frame occured).
156 // [2] child node count
157 // Reading the trie is done by recursively reading the tree depth-first
158 // pre-order.
159 CodeTrieNode _processProfileTrie(List<int> data, List<Code> codeTable) {
160 // Setup state shared across calls to _readTrieNode.
161 _trieDataCursor = 0;
162 _trieData = data;
163 if (_trieData == null) {
164 return null;
165 }
166 if (_trieData.length < 3) {
167 // Not enough integers for 1 node.
168 return null;
169 }
170 // Read the tree, returns the root node.
171 return _readTrieNode(codeTable);
172 }
173 int _trieDataCursor;
174 List<int> _trieData;
175 CodeTrieNode _readTrieNode(List<Code> codeTable) {
176 // Read index into code table.
177 var index = _trieData[_trieDataCursor++];
178 // Lookup code object.
179 var code = codeTable[index];
180 // Frame counter.
181 var count = _trieData[_trieDataCursor++];
182 // Create node.
183 var node = new CodeTrieNode(code, count);
184 // Number of children.
185 var children = _trieData[_trieDataCursor++];
186 // Recursively read child nodes.
187 for (var i = 0; i < children; i++) {
188 var child = _readTrieNode(codeTable);
189 node.children.add(child);
190 node.summedChildCount += child.count;
191 }
192 return node;
193 }
145 } 194 }
146 195
147 // TODO(johnmccutchan): Make this into an IsolateCache. 196 // TODO(johnmccutchan): Make this into an IsolateCache.
148 class IsolateList extends ServiceObject { 197 class IsolateList extends ServiceObject {
149 final VM _vm; 198 final VM _vm;
150 VM get vm => _vm; 199 VM get vm => _vm;
151 @observable final isolates = new ObservableMap<String, Isolate>(); 200 @observable final isolates = new ObservableMap<String, Isolate>();
152 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { 201 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') {
153 name = 'IsolateList'; 202 name = 'IsolateList';
154 vmName = name; 203 vmName = name;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 492
444 static CodeKind fromString(String s) { 493 static CodeKind fromString(String s) {
445 if (s == 'Native') { 494 if (s == 'Native') {
446 return Native; 495 return Native;
447 } else if (s == 'Dart') { 496 } else if (s == 'Dart') {
448 return Dart; 497 return Dart;
449 } else if (s == 'Collected') { 498 } else if (s == 'Collected') {
450 return Collected; 499 return Collected;
451 } else if (s == 'Reused') { 500 } else if (s == 'Reused') {
452 return Reused; 501 return Reused;
502 } else if (s == 'Tag') {
503 return Tag;
453 } 504 }
454 Logger.root.warning('Unknown code kind $s'); 505 Logger.root.warning('Unknown code kind $s');
455 throw new FallThroughError(); 506 throw new FallThroughError();
456 } 507 }
457 static const Native = const CodeKind._internal('Native'); 508 static const Native = const CodeKind._internal('Native');
458 static const Dart = const CodeKind._internal('Dart'); 509 static const Dart = const CodeKind._internal('Dart');
459 static const Collected = const CodeKind._internal('Collected'); 510 static const Collected = const CodeKind._internal('Collected');
460 static const Reused = const CodeKind._internal('Reused'); 511 static const Reused = const CodeKind._internal('Reused');
512 static const Tag = const CodeKind._internal('Tag');
461 } 513 }
462 514
463 class CodeCallCount { 515 class CodeCallCount {
464 final Code code; 516 final Code code;
465 final int count; 517 final int count;
466 CodeCallCount(this.code, this.count); 518 CodeCallCount(this.code, this.count);
467 } 519 }
468 520
521 class CodeTrieNode {
522 final Code code;
523 final int count;
524 final children = new List<CodeTrieNode>();
525 int summedChildCount = 0;
526 CodeTrieNode(this.code, this.count);
527 }
528
469 class Code extends ServiceObject { 529 class Code extends ServiceObject {
470 @observable CodeKind kind; 530 @observable CodeKind kind;
471 @observable int totalSamplesInProfile = 0; 531 @observable int totalSamplesInProfile = 0;
472 @reflectable int exclusiveTicks = 0; 532 @reflectable int exclusiveTicks = 0;
473 @reflectable int inclusiveTicks = 0; 533 @reflectable int inclusiveTicks = 0;
474 @reflectable int startAddress = 0; 534 @reflectable int startAddress = 0;
475 @reflectable int endAddress = 0; 535 @reflectable int endAddress = 0;
476 @reflectable final callers = new List<CodeCallCount>(); 536 @reflectable final callers = new List<CodeCallCount>();
477 @reflectable final callees = new List<CodeCallCount>(); 537 @reflectable final callees = new List<CodeCallCount>();
478 @reflectable final instructions = new ObservableList<CodeInstruction>(); 538 @reflectable final instructions = new ObservableList<CodeInstruction>();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 689
630 int _callCount(List<CodeCallCount> calls, Code code) { 690 int _callCount(List<CodeCallCount> calls, Code code) {
631 for (CodeCallCount caller in calls) { 691 for (CodeCallCount caller in calls) {
632 if (caller.code == code) { 692 if (caller.code == code) {
633 return caller.count; 693 return caller.count;
634 } 694 }
635 } 695 }
636 return 0; 696 return 0;
637 } 697 }
638 } 698 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/service/cache.dart ('k') | runtime/bin/vmservice/client/lib/src/service/service.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698