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 /// A [ServiceObject] is an object known to the VM service and is tied | 7 /// A [ServiceObject] is an object known to the VM service and is tied |
8 /// to an owning [Isolate]. | 8 /// to an owning [Isolate]. |
9 abstract class ServiceObject extends Observable { | 9 abstract class ServiceObject extends Observable { |
10 /// The owner of this [ServiceObject]. This can be an [Isolate], a | 10 /// The owner of this [ServiceObject]. This can be an [Isolate], a |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 @reflectable Iterable<Isolate> get isolates => _isolateCache.values; | 183 @reflectable Iterable<Isolate> get isolates => _isolateCache.values; |
184 | 184 |
185 @reflectable String get link => '$id'; | 185 @reflectable String get link => '$id'; |
186 @reflectable String relativeLink(String id) => '$id'; | 186 @reflectable String relativeLink(String id) => '$id'; |
187 | 187 |
188 @observable String version = 'unknown'; | 188 @observable String version = 'unknown'; |
189 @observable String architecture = 'unknown'; | 189 @observable String architecture = 'unknown'; |
190 @observable double uptime = 0.0; | 190 @observable double uptime = 0.0; |
191 @observable bool assertsEnabled = false; | 191 @observable bool assertsEnabled = false; |
192 @observable bool typeChecksEnabled = false; | 192 @observable bool typeChecksEnabled = false; |
193 @observable DateTime date; | |
koda
2014/06/17 21:04:07
Please choose a more descriptive name. lastUpdated
Cutch
2014/06/18 14:35:03
Done.
| |
193 | 194 |
194 VM() : super._empty(null) { | 195 VM() : super._empty(null) { |
195 name = 'vm'; | 196 name = 'vm'; |
196 vmName = 'vm'; | 197 vmName = 'vm'; |
197 _cache['vm'] = this; | 198 _cache['vm'] = this; |
198 update(toObservable({'id':'vm', 'type':'@VM'})); | 199 update(toObservable({'id':'vm', 'type':'@VM'})); |
199 } | 200 } |
200 | 201 |
201 final StreamController<ServiceException> exceptions = | 202 final StreamController<ServiceException> exceptions = |
202 new StreamController.broadcast(); | 203 new StreamController.broadcast(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 Future<String> getString(String id); | 367 Future<String> getString(String id); |
367 | 368 |
368 void _update(ObservableMap map, bool mapIsRef) { | 369 void _update(ObservableMap map, bool mapIsRef) { |
369 if (mapIsRef) { | 370 if (mapIsRef) { |
370 return; | 371 return; |
371 } | 372 } |
372 _loaded = true; | 373 _loaded = true; |
373 version = map['version']; | 374 version = map['version']; |
374 architecture = map['architecture']; | 375 architecture = map['architecture']; |
375 uptime = map['uptime']; | 376 uptime = map['uptime']; |
377 var dateInMillis = int.parse(map['date']); | |
378 date = new DateTime.fromMillisecondsSinceEpoch(dateInMillis); | |
376 assertsEnabled = map['assertsEnabled']; | 379 assertsEnabled = map['assertsEnabled']; |
377 typeChecksEnabled = map['typeChecksEnabled']; | 380 typeChecksEnabled = map['typeChecksEnabled']; |
378 _updateIsolates(map['isolates']); | 381 _updateIsolates(map['isolates']); |
379 } | 382 } |
380 | 383 |
381 void _updateIsolates(List newIsolates) { | 384 void _updateIsolates(List newIsolates) { |
382 var oldIsolateCache = _isolateCache; | 385 var oldIsolateCache = _isolateCache; |
383 var newIsolateCache = new Map<String,Isolate>(); | 386 var newIsolateCache = new Map<String,Isolate>(); |
384 for (var isolateMap in newIsolates) { | 387 for (var isolateMap in newIsolates) { |
385 var isolateId = isolateMap['id']; | 388 var isolateId = isolateMap['id']; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 @observable ObservableMap topFrame; | 655 @observable ObservableMap topFrame; |
653 | 656 |
654 @observable String name; | 657 @observable String name; |
655 @observable String vmName; | 658 @observable String vmName; |
656 @observable String mainPort; | 659 @observable String mainPort; |
657 @observable Map entry; | 660 @observable Map entry; |
658 | 661 |
659 @observable final Map<String, double> timers = | 662 @observable final Map<String, double> timers = |
660 toObservable(new Map<String, double>()); | 663 toObservable(new Map<String, double>()); |
661 | 664 |
662 @observable int newHeapUsed = 0; | 665 @observable int newHeapUsed = 0; |
koda
2014/06/17 21:04:06
The same three fields are repeated for new and old
Cutch
2014/06/18 14:35:03
Done.
| |
666 @observable int newHeapCapacity = 0; | |
667 @observable int newExternal = 0; | |
663 @observable int oldHeapUsed = 0; | 668 @observable int oldHeapUsed = 0; |
664 @observable int newHeapCapacity = 0; | |
665 @observable int oldHeapCapacity = 0; | 669 @observable int oldHeapCapacity = 0; |
670 @observable int oldExternal = 0; | |
666 | 671 |
667 @observable String fileAndLine; | 672 @observable String fileAndLine; |
668 | 673 |
669 @observable DartError error; | 674 @observable DartError error; |
670 | 675 |
676 void updateHeapsFromMap(ObservableMap map) { | |
677 newHeapUsed = map['new']['used']; | |
678 newHeapCapacity = map['new']['capacity']; | |
679 newExternal = map['new']['external']; | |
680 oldHeapUsed = map['old']['used']; | |
681 oldHeapCapacity = map['old']['capacity']; | |
682 oldExternal = map['old']['external']; | |
683 } | |
684 | |
671 void _update(ObservableMap map, bool mapIsRef) { | 685 void _update(ObservableMap map, bool mapIsRef) { |
672 mainPort = map['mainPort']; | 686 mainPort = map['mainPort']; |
673 name = map['name']; | 687 name = map['name']; |
674 vmName = map['name']; | 688 vmName = map['name']; |
675 if (mapIsRef) { | 689 if (mapIsRef) { |
676 return; | 690 return; |
677 } | 691 } |
678 _loaded = true; | 692 _loaded = true; |
679 loading = false; | 693 loading = false; |
680 _upgradeCollection(map, isolate); | 694 _upgradeCollection(map, isolate); |
681 if (map['rootLib'] == null || | 695 if (map['rootLib'] == null || |
682 map['timers'] == null || | 696 map['timers'] == null || |
683 map['heap'] == null) { | 697 map['heaps'] == null) { |
684 Logger.root.severe("Malformed 'Isolate' response: $map"); | 698 Logger.root.severe("Malformed 'Isolate' response: $map"); |
685 return; | 699 return; |
686 } | 700 } |
687 rootLib = map['rootLib']; | 701 rootLib = map['rootLib']; |
688 if (map['entry'] != null) { | 702 if (map['entry'] != null) { |
689 entry = map['entry']; | 703 entry = map['entry']; |
690 } | 704 } |
691 if (map['topFrame'] != null) { | 705 if (map['topFrame'] != null) { |
692 topFrame = map['topFrame']; | 706 topFrame = map['topFrame']; |
693 } else { | 707 } else { |
(...skipping 28 matching lines...) Expand all Loading... | |
722 }); | 736 }); |
723 timers['total'] = timerMap['time_total_runtime']; | 737 timers['total'] = timerMap['time_total_runtime']; |
724 timers['compile'] = timerMap['time_compilation']; | 738 timers['compile'] = timerMap['time_compilation']; |
725 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | 739 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. |
726 timers['init'] = (timerMap['time_script_loading'] + | 740 timers['init'] = (timerMap['time_script_loading'] + |
727 timerMap['time_creating_snapshot'] + | 741 timerMap['time_creating_snapshot'] + |
728 timerMap['time_isolate_initialization'] + | 742 timerMap['time_isolate_initialization'] + |
729 timerMap['time_bootstrap']); | 743 timerMap['time_bootstrap']); |
730 timers['dart'] = timerMap['time_dart_execution']; | 744 timers['dart'] = timerMap['time_dart_execution']; |
731 | 745 |
732 newHeapUsed = map['heap']['usedNew']; | 746 updateHeapsFromMap(map['heaps']); |
733 oldHeapUsed = map['heap']['usedOld']; | |
734 newHeapCapacity = map['heap']['capacityNew']; | |
735 oldHeapCapacity = map['heap']['capacityOld']; | |
736 | 747 |
737 List features = map['features']; | 748 List features = map['features']; |
738 if (features != null) { | 749 if (features != null) { |
739 for (var feature in features) { | 750 for (var feature in features) { |
740 if (feature == 'io') { | 751 if (feature == 'io') { |
741 ioEnabled = true; | 752 ioEnabled = true; |
742 } | 753 } |
743 } | 754 } |
744 } | 755 } |
745 // Isolate status | 756 // Isolate status |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
965 scripts.addAll(map['scripts']); | 976 scripts.addAll(map['scripts']); |
966 classes.clear(); | 977 classes.clear(); |
967 classes.addAll(map['classes']); | 978 classes.addAll(map['classes']); |
968 variables.clear(); | 979 variables.clear(); |
969 variables.addAll(map['variables']); | 980 variables.addAll(map['variables']); |
970 functions.clear(); | 981 functions.clear(); |
971 functions.addAll(map['functions']); | 982 functions.addAll(map['functions']); |
972 } | 983 } |
973 } | 984 } |
974 | 985 |
986 class AllocationStat extends Observable { | |
koda
2014/06/17 21:04:06
Consider adding pointer to the C++ counterpart in
Cutch
2014/06/18 14:35:03
Done.
| |
987 @observable int instances = 0; | |
988 @observable int bytes = 0; | |
989 | |
990 void reset() { | |
991 instances = 0; | |
992 bytes = 0; | |
993 } | |
994 | |
995 bool get empty => (instances == 0) && (bytes == 0); | |
996 } | |
997 | |
975 class Class extends ServiceObject { | 998 class Class extends ServiceObject { |
976 @observable Library library; | 999 @observable Library library; |
977 @observable Script script; | 1000 @observable Script script; |
978 @observable Class superClass; | 1001 @observable Class superClass; |
979 | 1002 |
980 @observable bool isAbstract; | 1003 @observable bool isAbstract; |
981 @observable bool isConst; | 1004 @observable bool isConst; |
982 @observable bool isFinalized; | 1005 @observable bool isFinalized; |
983 @observable bool isPatch; | 1006 @observable bool isPatch; |
984 @observable bool isImplemented; | 1007 @observable bool isImplemented; |
985 | 1008 |
986 @observable int tokenPos; | 1009 @observable int tokenPos; |
987 | 1010 |
988 @observable ServiceMap error; | 1011 @observable ServiceMap error; |
989 | 1012 |
1013 final AllocationStat accumulatedNewSpace = new AllocationStat(); | |
1014 final AllocationStat accumulatedOldSpace = new AllocationStat(); | |
1015 final AllocationStat currentNewSpace = new AllocationStat(); | |
1016 final AllocationStat currentOldSpace = new AllocationStat(); | |
1017 | |
1018 bool get hasNoAllocations { | |
1019 return accumulatedNewSpace.empty && | |
1020 accumulatedOldSpace.empty && | |
1021 currentNewSpace.empty && | |
1022 currentOldSpace.empty; | |
1023 } | |
1024 | |
990 @reflectable final children = new ObservableList<Class>(); | 1025 @reflectable final children = new ObservableList<Class>(); |
991 @reflectable final subClasses = new ObservableList<Class>(); | 1026 @reflectable final subClasses = new ObservableList<Class>(); |
992 @reflectable final fields = new ObservableList<ServiceMap>(); | 1027 @reflectable final fields = new ObservableList<ServiceMap>(); |
993 @reflectable final functions = new ObservableList<ServiceMap>(); | 1028 @reflectable final functions = new ObservableList<ServiceMap>(); |
994 @reflectable final interfaces = new ObservableList<Class>(); | 1029 @reflectable final interfaces = new ObservableList<Class>(); |
995 | 1030 |
996 bool get canCache => true; | 1031 bool get canCache => true; |
997 bool get immutable => false; | 1032 bool get immutable => false; |
998 | 1033 |
999 Class._empty(ServiceObjectOwner owner) : super._empty(owner); | 1034 Class._empty(ServiceObjectOwner owner) : super._empty(owner); |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1738 var v = list[i]; | 1773 var v = list[i]; |
1739 if ((v is ObservableMap) && _isServiceMap(v)) { | 1774 if ((v is ObservableMap) && _isServiceMap(v)) { |
1740 list[i] = owner.getFromMap(v); | 1775 list[i] = owner.getFromMap(v); |
1741 } else if (v is ObservableList) { | 1776 } else if (v is ObservableList) { |
1742 _upgradeObservableList(v, owner); | 1777 _upgradeObservableList(v, owner); |
1743 } else if (v is ObservableMap) { | 1778 } else if (v is ObservableMap) { |
1744 _upgradeObservableMap(v, owner); | 1779 _upgradeObservableMap(v, owner); |
1745 } | 1780 } |
1746 } | 1781 } |
1747 } | 1782 } |
OLD | NEW |