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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 2574643003: Added ability to request zone memory information for all isolates through the VM service and added … (Closed)
Patch Set: Created dart objects for thread and zone and added threads field to isolate. Created 4 years 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
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
Cutch 2016/12/16 22:55:44 we usually don't add new whitespace
bkonyi 2016/12/16 22:59:57 This was accidental. Removed.
7 // Some value smaller than the object ring, so requesting a large array 8 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 9 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 10 // object ring.
10 const int kDefaultFieldLimit = 100; 11 const int kDefaultFieldLimit = 100;
11 12
12 /// Helper function for canceling a Future<StreamSubscription>. 13 /// Helper function for canceling a Future<StreamSubscription>.
13 Future cancelFutureSubscription( 14 Future cancelFutureSubscription(
14 Future<StreamSubscription> subscriptionFuture) async { 15 Future<StreamSubscription> subscriptionFuture) async {
15 if (subscriptionFuture != null) { 16 if (subscriptionFuture != null) {
16 var subscription = await subscriptionFuture; 17 var subscription = await subscriptionFuture;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 break; 232 break;
232 case 'Library': 233 case 'Library':
233 obj = new Library._empty(owner); 234 obj = new Library._empty(owner);
234 break; 235 break;
235 case 'Message': 236 case 'Message':
236 obj = new ServiceMessage._empty(owner); 237 obj = new ServiceMessage._empty(owner);
237 break; 238 break;
238 case 'SourceLocation': 239 case 'SourceLocation':
239 obj = new SourceLocation._empty(owner); 240 obj = new SourceLocation._empty(owner);
240 break; 241 break;
242 case '_Thread':
243 obj = new Thread._empty(owner);
244 break;
241 case 'UnresolvedSourceLocation': 245 case 'UnresolvedSourceLocation':
242 obj = new UnresolvedSourceLocation._empty(owner); 246 obj = new UnresolvedSourceLocation._empty(owner);
243 break; 247 break;
244 case 'Object': 248 case 'Object':
245 switch (vmType) { 249 switch (vmType) {
246 case 'ICData': 250 case 'ICData':
247 obj = new ICData._empty(owner); 251 obj = new ICData._empty(owner);
248 break; 252 break;
249 case 'LocalVarDescriptors': 253 case 'LocalVarDescriptors':
250 obj = new LocalVarDescriptors._empty(owner); 254 obj = new LocalVarDescriptors._empty(owner);
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 final HeapSpace newSpace = new HeapSpace(); 1498 final HeapSpace newSpace = new HeapSpace();
1495 final HeapSpace oldSpace = new HeapSpace(); 1499 final HeapSpace oldSpace = new HeapSpace();
1496 1500
1497 String fileAndLine; 1501 String fileAndLine;
1498 1502
1499 DartError error; 1503 DartError error;
1500 StreamController _snapshotFetch; 1504 StreamController _snapshotFetch;
1501 1505
1502 List<ByteData> _chunksInProgress; 1506 List<ByteData> _chunksInProgress;
1503 1507
1508 List<Thread> get threads => _threads;
1509 List<Thread> _threads = new List<Thread>();
Cutch 2016/12/16 22:55:43 final List<Thread> _threads ...
bkonyi 2016/12/19 16:40:20 Done.
1510
1504 void _loadHeapSnapshot(ServiceEvent event) { 1511 void _loadHeapSnapshot(ServiceEvent event) {
1505 if (_snapshotFetch == null || _snapshotFetch.isClosed) { 1512 if (_snapshotFetch == null || _snapshotFetch.isClosed) {
1506 // No outstanding snapshot request. Presumably another client asked for a 1513 // No outstanding snapshot request. Presumably another client asked for a
1507 // snapshot. 1514 // snapshot.
1508 Logger.root.info("Dropping unsolicited heap snapshot chunk"); 1515 Logger.root.info("Dropping unsolicited heap snapshot chunk");
1509 return; 1516 return;
1510 } 1517 }
1511 1518
1512 // Occasionally these actually arrive out of order. 1519 // Occasionally these actually arrive out of order.
1513 var chunkIndex = event.chunkIndex; 1520 var chunkIndex = event.chunkIndex;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 libraries.addAll(map['libraries']); 1624 libraries.addAll(map['libraries']);
1618 libraries.sort(ServiceObject.LexicalSortName); 1625 libraries.sort(ServiceObject.LexicalSortName);
1619 if (savedStartTime == null) { 1626 if (savedStartTime == null) {
1620 vm._buildIsolateList(); 1627 vm._buildIsolateList();
1621 } 1628 }
1622 1629
1623 extensionRPCs.clear(); 1630 extensionRPCs.clear();
1624 if (map['extensionRPCs'] != null) { 1631 if (map['extensionRPCs'] != null) {
1625 extensionRPCs.addAll(map['extensionRPCs']); 1632 extensionRPCs.addAll(map['extensionRPCs']);
1626 } 1633 }
1634
1635 List threadsList = map['threads'];
Cutch 2016/12/16 22:55:43 follow the pattern from above: threads.clear(); i
bkonyi 2016/12/19 16:40:20 Done.
1636 threadsList.forEach((thread) {
1637 threads.add(thread);
1638 });
1627 } 1639 }
1628 1640
1629 Future<TagProfile> updateTagProfile() { 1641 Future<TagProfile> updateTagProfile() {
1630 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then((Map map) { 1642 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then((Map map) {
1631 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; 1643 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0;
1632 tagProfile._processTagProfile(seconds, map); 1644 tagProfile._processTagProfile(seconds, map);
1633 return tagProfile; 1645 return tagProfile;
1634 }); 1646 });
1635 } 1647 }
1636 1648
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 3061
3050 kind = stringToSentinelKind(map['kind']); 3062 kind = stringToSentinelKind(map['kind']);
3051 valueAsString = map['valueAsString']; 3063 valueAsString = map['valueAsString'];
3052 _loaded = true; 3064 _loaded = true;
3053 } 3065 }
3054 3066
3055 String toString() => 'Sentinel($kind)'; 3067 String toString() => 'Sentinel($kind)';
3056 String get shortName => valueAsString; 3068 String get shortName => valueAsString;
3057 } 3069 }
3058 3070
3071 class Thread extends ServiceObject implements M.Thread {
3072 M.ThreadKind get kind => _kind;
3073 M.ThreadKind _kind;
3074 List<Zone> get zones => _zones;
3075 List<Zone> _zones = new List<Zone>();
Cutch 2016/12/16 22:55:44 final List<Zone> ...
bkonyi 2016/12/19 16:40:20 Done.
3076
3077 Thread._empty(ServiceObjectOwner owner) : super._empty(owner);
3078
3079 void _update(Map map, bool mapIsRef) {
3080 String kindString = map['kind'];
3081 List zoneList = map['zones'];
3082
3083 switch(kindString) {
Cutch 2016/12/16 22:55:44 is everything guaranteed to be sent even when this
bkonyi 2016/12/16 22:59:58 Currently Thread doesn't have a ref version. Shoul
3084 case "kUnknownTask":
3085 _kind = M.ThreadKind.kUnknownTask;
3086 break;
3087 case "kMutatorTask":
3088 _kind = M.ThreadKind.kMutatorTask;
3089 break;
3090 case "kCompilerTask":
3091 _kind = M.ThreadKind.kCompilerTask;
3092 break;
3093 case "kSweeperTask":
3094 _kind = M.ThreadKind.kSweeperTask;
3095 break;
3096 case "kMarkerTask":
3097 _kind = M.ThreadKind.kMarkerTask;
3098 break;
3099 case "kFinalizerTask":
3100 _kind = M.ThreadKind.kFinalizerTask;
3101 break;
3102 default:
3103 assert(false);
3104 }
3105 zoneList.forEach((zone) {
3106 num capacity = zone['capacity'];
Cutch 2016/12/16 22:55:43 int here and elsewhere
bkonyi 2016/12/16 22:59:58 Right, done.
3107 num used = zone['used'];
3108 zones.add(new Zone(capacity, used));
3109 });
3110 }
3111 }
3112
3113 class Zone implements M.Zone {
3114 num get capacity => _capacity;
3115 num _capacity;
3116 num get used => _used;
3117 num _used;
3118
3119 Zone(this._capacity, this._used);
3120 }
3121
3059 class Field extends HeapObject implements M.Field { 3122 class Field extends HeapObject implements M.Field {
3060 // Library or Class. 3123 // Library or Class.
3061 HeapObject dartOwner; 3124 HeapObject dartOwner;
3062 Library library; 3125 Library library;
3063 Instance declaredType; 3126 Instance declaredType;
3064 bool isStatic; 3127 bool isStatic;
3065 bool isFinal; 3128 bool isFinal;
3066 bool isConst; 3129 bool isConst;
3067 Instance staticValue; 3130 Instance staticValue;
3068 String name; 3131 String name;
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
4420 var v = list[i]; 4483 var v = list[i];
4421 if ((v is Map) && _isServiceMap(v)) { 4484 if ((v is Map) && _isServiceMap(v)) {
4422 list[i] = owner.getFromMap(v); 4485 list[i] = owner.getFromMap(v);
4423 } else if (v is List) { 4486 } else if (v is List) {
4424 _upgradeList(v, owner); 4487 _upgradeList(v, owner);
4425 } else if (v is Map) { 4488 } else if (v is Map) {
4426 _upgradeMap(v, owner); 4489 _upgradeMap(v, owner);
4427 } 4490 }
4428 } 4491 }
4429 } 4492 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698