| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 Future<ServiceObject> getDirect(String serviceId) { | 66 Future<ServiceObject> getDirect(String serviceId) { |
| 67 return vm.getAsMap(relativeLink(serviceId)).then((ObservableMap m) { | 67 return vm.getAsMap(relativeLink(serviceId)).then((ObservableMap m) { |
| 68 return _upgradeToServiceObject(vm, this, m); | 68 return _upgradeToServiceObject(vm, this, m); |
| 69 }); | 69 }); |
| 70 } | 70 } |
| 71 | 71 |
| 72 /// Requests [serviceId] from [this]. Completes to a [ServiceObject]. | 72 /// Requests [serviceId] from [this]. Completes to a [ServiceObject]. |
| 73 /// Can return pre-existing, cached, [ServiceObject]s. | 73 /// Can return pre-existing, cached, [ServiceObject]s. |
| 74 Future<ServiceObject> get(String serviceId) { | 74 Future<ServiceObject> get(String serviceId) { |
| 75 if (serviceId == '') { |
| 76 return reload(); |
| 77 } |
| 75 if (_scripts.cachesId(serviceId)) { | 78 if (_scripts.cachesId(serviceId)) { |
| 76 return _scripts.get(serviceId); | 79 return _scripts.get(serviceId); |
| 77 } | 80 } |
| 78 if (_codes.cachesId(serviceId)) { | 81 if (_codes.cachesId(serviceId)) { |
| 79 return _codes.get(serviceId); | 82 return _codes.get(serviceId); |
| 80 } | 83 } |
| 81 if (_classes.cachesId(serviceId)) { | 84 if (_classes.cachesId(serviceId)) { |
| 82 return _classes.get(serviceId); | 85 return _classes.get(serviceId); |
| 83 } | 86 } |
| 84 if (_functions.cachesId(serviceId)) { | 87 if (_functions.cachesId(serviceId)) { |
| 85 return _functions.get(serviceId); | 88 return _functions.get(serviceId); |
| 86 } | 89 } |
| 87 return getDirect(serviceId); | 90 return getDirect(serviceId); |
| 88 } | 91 } |
| 89 | 92 |
| 90 @observable ServiceMap rootLib; | 93 @observable ServiceMap rootLib; |
| 91 @observable ObservableMap topFrame; | 94 @observable ObservableMap topFrame; |
| 92 | 95 |
| 93 @observable String name; | 96 @observable String name; |
| 94 @observable String vmName; | 97 @observable String vmName; |
| 95 @observable Map entry; | 98 @observable Map entry; |
| 96 | 99 |
| 97 @observable final Map<String, double> timers = | 100 @observable final Map<String, double> timers = |
| 98 toObservable(new Map<String, double>()); | 101 toObservable(new Map<String, double>()); |
| 99 | 102 |
| 100 @observable int newHeapUsed = 0; | 103 @observable int newHeapUsed = 0; |
| 101 @observable int oldHeapUsed = 0; | 104 @observable int oldHeapUsed = 0; |
| 105 @observable int newHeapCapacity = 0; |
| 106 @observable int oldHeapCapacity = 0; |
| 102 | 107 |
| 103 @observable String fileAndLine; | 108 @observable String fileAndLine; |
| 104 | 109 |
| 105 void _update(ObservableMap map) { | 110 void _update(ObservableMap map) { |
| 106 upgradeCollection(map, vm, this); | 111 upgradeCollection(map, vm, this); |
| 107 _ref = false; | 112 _ref = false; |
| 108 if (map['rootLib'] == null || | 113 if (map['rootLib'] == null || |
| 109 map['timers'] == null || | 114 map['timers'] == null || |
| 110 map['heap'] == null) { | 115 map['heap'] == null) { |
| 111 Logger.root.severe("Malformed 'Isolate' response: $map"); | 116 Logger.root.severe("Malformed 'Isolate' response: $map"); |
| 112 return; | 117 return; |
| 113 } | 118 } |
| 114 rootLib = map['rootLib']; | 119 rootLib = map['rootLib']; |
| 115 vmName = map['name']; | 120 vmName = map['name']; |
| 116 if (map['entry'] != null) { | 121 if (map['entry'] != null) { |
| 117 entry = map['entry']; | 122 entry = map['entry']; |
| 118 name = entry['name']; | 123 name = entry['name']; |
| 119 } else { | 124 } else { |
| 120 // fred | 125 // fred |
| 121 name = 'root isolate'; | 126 name = 'root'; |
| 122 } | 127 } |
| 123 if (map['topFrame'] != null) { | 128 if (map['topFrame'] != null) { |
| 124 topFrame = map['topFrame']; | 129 topFrame = map['topFrame']; |
| 125 } else { | 130 } else { |
| 126 topFrame = null ; | 131 topFrame = null ; |
| 127 } | 132 } |
| 128 | 133 |
| 129 var timerMap = {}; | 134 var timerMap = {}; |
| 130 map['timers'].forEach((timer) { | 135 map['timers'].forEach((timer) { |
| 131 timerMap[timer['name']] = timer['time']; | 136 timerMap[timer['name']] = timer['time']; |
| 132 }); | 137 }); |
| 133 timers['total'] = timerMap['time_total_runtime']; | 138 timers['total'] = timerMap['time_total_runtime']; |
| 134 timers['compile'] = timerMap['time_compilation']; | 139 timers['compile'] = timerMap['time_compilation']; |
| 135 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | 140 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. |
| 136 timers['init'] = (timerMap['time_script_loading'] + | 141 timers['init'] = (timerMap['time_script_loading'] + |
| 137 timerMap['time_creating_snapshot'] + | 142 timerMap['time_creating_snapshot'] + |
| 138 timerMap['time_isolate_initialization'] + | 143 timerMap['time_isolate_initialization'] + |
| 139 timerMap['time_bootstrap']); | 144 timerMap['time_bootstrap']); |
| 140 timers['dart'] = timerMap['time_dart_execution']; | 145 timers['dart'] = timerMap['time_dart_execution']; |
| 141 | 146 |
| 142 newHeapUsed = map['heap']['usedNew']; | 147 newHeapUsed = map['heap']['usedNew']; |
| 143 oldHeapUsed = map['heap']['usedOld']; | 148 oldHeapUsed = map['heap']['usedOld']; |
| 149 newHeapCapacity = map['heap']['capacityNew']; |
| 150 oldHeapCapacity = map['heap']['capacityOld']; |
| 144 } | 151 } |
| 145 } | 152 } |
| 146 | 153 |
| 147 // TODO(johnmccutchan): Make this into an IsolateCache. | 154 // TODO(johnmccutchan): Make this into an IsolateCache. |
| 148 class IsolateList extends ServiceObject { | 155 class IsolateList extends ServiceObject { |
| 149 final VM _vm; | 156 final VM _vm; |
| 150 VM get vm => _vm; | 157 VM get vm => _vm; |
| 151 @observable final isolates = new ObservableMap<String, Isolate>(); | 158 @observable final isolates = new ObservableMap<String, Isolate>(); |
| 152 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { | 159 IsolateList(this._vm) : super(null, 'isolates', 'IsolateList') { |
| 153 name = 'IsolateList'; | 160 name = 'IsolateList'; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 636 |
| 630 int _callCount(List<CodeCallCount> calls, Code code) { | 637 int _callCount(List<CodeCallCount> calls, Code code) { |
| 631 for (CodeCallCount caller in calls) { | 638 for (CodeCallCount caller in calls) { |
| 632 if (caller.code == code) { | 639 if (caller.code == code) { |
| 633 return caller.count; | 640 return caller.count; |
| 634 } | 641 } |
| 635 } | 642 } |
| 636 return 0; | 643 return 0; |
| 637 } | 644 } |
| 638 } | 645 } |
| OLD | NEW |