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 /// 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 String pid = ''; | 193 @observable String pid = ''; |
| 194 @observable DateTime lastUpdate; | |
| 194 | 195 |
| 195 VM() : super._empty(null) { | 196 VM() : super._empty(null) { |
| 196 name = 'vm'; | 197 name = 'vm'; |
| 197 vmName = 'vm'; | 198 vmName = 'vm'; |
| 198 _cache['vm'] = this; | 199 _cache['vm'] = this; |
| 199 update(toObservable({'id':'vm', 'type':'@VM'})); | 200 update(toObservable({'id':'vm', 'type':'@VM'})); |
| 200 } | 201 } |
| 201 | 202 |
| 202 final StreamController<ServiceException> exceptions = | 203 final StreamController<ServiceException> exceptions = |
| 203 new StreamController.broadcast(); | 204 new StreamController.broadcast(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 Future<String> getString(String id); | 368 Future<String> getString(String id); |
| 368 | 369 |
| 369 void _update(ObservableMap map, bool mapIsRef) { | 370 void _update(ObservableMap map, bool mapIsRef) { |
| 370 if (mapIsRef) { | 371 if (mapIsRef) { |
| 371 return; | 372 return; |
| 372 } | 373 } |
| 373 _loaded = true; | 374 _loaded = true; |
| 374 version = map['version']; | 375 version = map['version']; |
| 375 architecture = map['architecture']; | 376 architecture = map['architecture']; |
| 376 uptime = map['uptime']; | 377 uptime = map['uptime']; |
| 378 var dateInMillis = int.parse(map['date']); | |
| 379 lastUpdate = new DateTime.fromMillisecondsSinceEpoch(dateInMillis); | |
| 377 assertsEnabled = map['assertsEnabled']; | 380 assertsEnabled = map['assertsEnabled']; |
| 378 pid = map['pid']; | 381 pid = map['pid']; |
| 379 typeChecksEnabled = map['typeChecksEnabled']; | 382 typeChecksEnabled = map['typeChecksEnabled']; |
| 380 _updateIsolates(map['isolates']); | 383 _updateIsolates(map['isolates']); |
| 381 } | 384 } |
| 382 | 385 |
| 383 void _updateIsolates(List newIsolates) { | 386 void _updateIsolates(List newIsolates) { |
| 384 var oldIsolateCache = _isolateCache; | 387 var oldIsolateCache = _isolateCache; |
| 385 var newIsolateCache = new Map<String,Isolate>(); | 388 var newIsolateCache = new Map<String,Isolate>(); |
| 386 for (var isolateMap in newIsolates) { | 389 for (var isolateMap in newIsolates) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 snapshot.delta(counters, _maxSnapshot.counters); | 482 snapshot.delta(counters, _maxSnapshot.counters); |
| 480 _maxSnapshot.max(counters); | 483 _maxSnapshot.max(counters); |
| 481 snapshots.add(snapshot); | 484 snapshots.add(snapshot); |
| 482 // Only keep _historySize snapshots. | 485 // Only keep _historySize snapshots. |
| 483 if (snapshots.length > _historySize) { | 486 if (snapshots.length > _historySize) { |
| 484 snapshots.removeAt(0); | 487 snapshots.removeAt(0); |
| 485 } | 488 } |
| 486 } | 489 } |
| 487 } | 490 } |
| 488 | 491 |
| 492 class IsolateHeap extends Observable { | |
|
koda
2014/06/18 17:04:02
To nit, I think either "space" or "generation" wou
Cutch
2014/06/18 17:13:04
Done. HeapSpace.
| |
| 493 @observable int used = 0; | |
| 494 @observable int capacity = 0; | |
| 495 @observable int external = 0; | |
| 496 @observable int collections = 0; | |
| 497 @observable double totalCollectionTimeInSeconds = 0.0; | |
| 498 | |
| 499 void update(Map heapMap) { | |
| 500 used = heapMap['used']; | |
| 501 capacity = heapMap['capacity']; | |
| 502 external = heapMap['external']; | |
| 503 collections = heapMap['collections']; | |
| 504 totalCollectionTimeInSeconds = heapMap['time']; | |
| 505 } | |
| 506 } | |
| 507 | |
| 489 /// State for a running isolate. | 508 /// State for a running isolate. |
| 490 class Isolate extends ServiceObjectOwner { | 509 class Isolate extends ServiceObjectOwner { |
| 491 @reflectable VM get vm => owner; | 510 @reflectable VM get vm => owner; |
| 492 @reflectable Isolate get isolate => this; | 511 @reflectable Isolate get isolate => this; |
| 493 @observable ObservableMap counters = new ObservableMap(); | 512 @observable ObservableMap counters = new ObservableMap(); |
| 494 | 513 |
| 495 String get link => '/${_id}'; | 514 String get link => '/${_id}'; |
| 496 | 515 |
| 497 @observable ServiceMap pauseEvent = null; | 516 @observable ServiceMap pauseEvent = null; |
| 498 bool get _isPaused => pauseEvent != null; | 517 bool get _isPaused => pauseEvent != null; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 @observable ObservableMap topFrame; | 673 @observable ObservableMap topFrame; |
| 655 | 674 |
| 656 @observable String name; | 675 @observable String name; |
| 657 @observable String vmName; | 676 @observable String vmName; |
| 658 @observable String mainPort; | 677 @observable String mainPort; |
| 659 @observable Map entry; | 678 @observable Map entry; |
| 660 | 679 |
| 661 @observable final Map<String, double> timers = | 680 @observable final Map<String, double> timers = |
| 662 toObservable(new Map<String, double>()); | 681 toObservable(new Map<String, double>()); |
| 663 | 682 |
| 664 @observable int newHeapUsed = 0; | 683 final IsolateHeap newSpace = new IsolateHeap(); |
| 665 @observable int oldHeapUsed = 0; | 684 final IsolateHeap oldSpace = new IsolateHeap(); |
| 666 @observable int newHeapCapacity = 0; | |
| 667 @observable int oldHeapCapacity = 0; | |
| 668 | 685 |
| 669 @observable String fileAndLine; | 686 @observable String fileAndLine; |
| 670 | 687 |
| 671 @observable DartError error; | 688 @observable DartError error; |
| 672 | 689 |
| 690 void updateHeapsFromMap(ObservableMap map) { | |
| 691 newSpace.update(map['new']); | |
| 692 oldSpace.update(map['old']); | |
| 693 } | |
| 694 | |
| 673 void _update(ObservableMap map, bool mapIsRef) { | 695 void _update(ObservableMap map, bool mapIsRef) { |
| 674 mainPort = map['mainPort']; | 696 mainPort = map['mainPort']; |
| 675 name = map['name']; | 697 name = map['name']; |
| 676 vmName = map['name']; | 698 vmName = map['name']; |
| 677 if (mapIsRef) { | 699 if (mapIsRef) { |
| 678 return; | 700 return; |
| 679 } | 701 } |
| 680 _loaded = true; | 702 _loaded = true; |
| 681 loading = false; | 703 loading = false; |
| 682 _upgradeCollection(map, isolate); | 704 _upgradeCollection(map, isolate); |
| 683 if (map['rootLib'] == null || | 705 if (map['rootLib'] == null || |
| 684 map['timers'] == null || | 706 map['timers'] == null || |
| 685 map['heap'] == null) { | 707 map['heaps'] == null) { |
| 686 Logger.root.severe("Malformed 'Isolate' response: $map"); | 708 Logger.root.severe("Malformed 'Isolate' response: $map"); |
| 687 return; | 709 return; |
| 688 } | 710 } |
| 689 rootLib = map['rootLib']; | 711 rootLib = map['rootLib']; |
| 690 if (map['entry'] != null) { | 712 if (map['entry'] != null) { |
| 691 entry = map['entry']; | 713 entry = map['entry']; |
| 692 } | 714 } |
| 693 if (map['topFrame'] != null) { | 715 if (map['topFrame'] != null) { |
| 694 topFrame = map['topFrame']; | 716 topFrame = map['topFrame']; |
| 695 } else { | 717 } else { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 724 }); | 746 }); |
| 725 timers['total'] = timerMap['time_total_runtime']; | 747 timers['total'] = timerMap['time_total_runtime']; |
| 726 timers['compile'] = timerMap['time_compilation']; | 748 timers['compile'] = timerMap['time_compilation']; |
| 727 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | 749 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. |
| 728 timers['init'] = (timerMap['time_script_loading'] + | 750 timers['init'] = (timerMap['time_script_loading'] + |
| 729 timerMap['time_creating_snapshot'] + | 751 timerMap['time_creating_snapshot'] + |
| 730 timerMap['time_isolate_initialization'] + | 752 timerMap['time_isolate_initialization'] + |
| 731 timerMap['time_bootstrap']); | 753 timerMap['time_bootstrap']); |
| 732 timers['dart'] = timerMap['time_dart_execution']; | 754 timers['dart'] = timerMap['time_dart_execution']; |
| 733 | 755 |
| 734 newHeapUsed = map['heap']['usedNew']; | 756 updateHeapsFromMap(map['heaps']); |
| 735 oldHeapUsed = map['heap']['usedOld']; | |
| 736 newHeapCapacity = map['heap']['capacityNew']; | |
| 737 oldHeapCapacity = map['heap']['capacityOld']; | |
| 738 | 757 |
| 739 List features = map['features']; | 758 List features = map['features']; |
| 740 if (features != null) { | 759 if (features != null) { |
| 741 for (var feature in features) { | 760 for (var feature in features) { |
| 742 if (feature == 'io') { | 761 if (feature == 'io') { |
| 743 ioEnabled = true; | 762 ioEnabled = true; |
| 744 } | 763 } |
| 745 } | 764 } |
| 746 } | 765 } |
| 747 // Isolate status | 766 // Isolate status |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 scripts.addAll(map['scripts']); | 986 scripts.addAll(map['scripts']); |
| 968 classes.clear(); | 987 classes.clear(); |
| 969 classes.addAll(map['classes']); | 988 classes.addAll(map['classes']); |
| 970 variables.clear(); | 989 variables.clear(); |
| 971 variables.addAll(map['variables']); | 990 variables.addAll(map['variables']); |
| 972 functions.clear(); | 991 functions.clear(); |
| 973 functions.addAll(map['functions']); | 992 functions.addAll(map['functions']); |
| 974 } | 993 } |
| 975 } | 994 } |
| 976 | 995 |
| 996 class AllocationCount extends Observable { | |
| 997 @observable int instances = 0; | |
| 998 @observable int bytes = 0; | |
| 999 | |
| 1000 void reset() { | |
| 1001 instances = 0; | |
| 1002 bytes = 0; | |
| 1003 } | |
| 1004 | |
| 1005 bool get empty => (instances == 0) && (bytes == 0); | |
| 1006 } | |
| 1007 | |
| 1008 class Allocations { | |
| 1009 // Indexes into VM provided array. (see vm/class_table.h). | |
| 1010 static const ALLOCATED_BEFORE_GC = 0; | |
| 1011 static const ALLOCATED_BEFORE_GC_SIZE = 1; | |
| 1012 static const LIVE_AFTER_GC = 2; | |
| 1013 static const LIVE_AFTER_GC_SIZE = 3; | |
| 1014 static const ALLOCATED_SINCE_GC = 4; | |
| 1015 static const ALLOCATED_SINCE_GC_SIZE = 5; | |
| 1016 static const ACCUMULATED = 6; | |
| 1017 static const ACCUMULATED_SIZE = 7; | |
| 1018 | |
| 1019 final AllocationCount accumulated = new AllocationCount(); | |
| 1020 final AllocationCount current = new AllocationCount(); | |
| 1021 | |
| 1022 void update(List stats) { | |
| 1023 accumulated.instances = stats[ACCUMULATED]; | |
| 1024 accumulated.bytes = stats[ACCUMULATED_SIZE]; | |
| 1025 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC]; | |
| 1026 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE]; | |
| 1027 } | |
| 1028 | |
| 1029 bool get empty => accumulated.empty && current.empty; | |
| 1030 } | |
| 1031 | |
| 977 class Class extends ServiceObject { | 1032 class Class extends ServiceObject { |
| 978 @observable Library library; | 1033 @observable Library library; |
| 979 @observable Script script; | 1034 @observable Script script; |
| 980 @observable Class superClass; | 1035 @observable Class superClass; |
| 981 | 1036 |
| 982 @observable bool isAbstract; | 1037 @observable bool isAbstract; |
| 983 @observable bool isConst; | 1038 @observable bool isConst; |
| 984 @observable bool isFinalized; | 1039 @observable bool isFinalized; |
| 985 @observable bool isPatch; | 1040 @observable bool isPatch; |
| 986 @observable bool isImplemented; | 1041 @observable bool isImplemented; |
| 987 | 1042 |
| 988 @observable int tokenPos; | 1043 @observable int tokenPos; |
| 989 | 1044 |
| 990 @observable ServiceMap error; | 1045 @observable ServiceMap error; |
| 991 | 1046 |
| 1047 final Allocations newSpace = new Allocations(); | |
| 1048 final Allocations oldSpace = new Allocations(); | |
| 1049 | |
| 1050 bool get hasNoAllocations => newSpace.empty && oldSpace.empty; | |
| 1051 | |
| 992 @reflectable final children = new ObservableList<Class>(); | 1052 @reflectable final children = new ObservableList<Class>(); |
| 993 @reflectable final subClasses = new ObservableList<Class>(); | 1053 @reflectable final subClasses = new ObservableList<Class>(); |
| 994 @reflectable final fields = new ObservableList<ServiceMap>(); | 1054 @reflectable final fields = new ObservableList<ServiceMap>(); |
| 995 @reflectable final functions = new ObservableList<ServiceMap>(); | 1055 @reflectable final functions = new ObservableList<ServiceMap>(); |
| 996 @reflectable final interfaces = new ObservableList<Class>(); | 1056 @reflectable final interfaces = new ObservableList<Class>(); |
| 997 | 1057 |
| 998 bool get canCache => true; | 1058 bool get canCache => true; |
| 999 bool get immutable => false; | 1059 bool get immutable => false; |
| 1000 | 1060 |
| 1001 Class._empty(ServiceObjectOwner owner) : super._empty(owner); | 1061 Class._empty(ServiceObjectOwner owner) : super._empty(owner); |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1740 var v = list[i]; | 1800 var v = list[i]; |
| 1741 if ((v is ObservableMap) && _isServiceMap(v)) { | 1801 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 1742 list[i] = owner.getFromMap(v); | 1802 list[i] = owner.getFromMap(v); |
| 1743 } else if (v is ObservableList) { | 1803 } else if (v is ObservableList) { |
| 1744 _upgradeObservableList(v, owner); | 1804 _upgradeObservableList(v, owner); |
| 1745 } else if (v is ObservableMap) { | 1805 } else if (v is ObservableMap) { |
| 1746 _upgradeObservableMap(v, owner); | 1806 _upgradeObservableMap(v, owner); |
| 1747 } | 1807 } |
| 1748 } | 1808 } |
| 1749 } | 1809 } |
| OLD | NEW |