Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 observatory; | 5 part of observatory; |
| 6 | 6 |
| 7 | |
| 7 /// State for a running isolate. | 8 /// State for a running isolate. |
| 8 class Isolate extends Observable { | 9 class Isolate extends Observable { |
| 10 static ObservatoryApplication _application; | |
| 11 | |
| 9 @observable Profile profile; | 12 @observable Profile profile; |
| 10 @observable final Map<String, Script> scripts = | 13 @observable final Map<String, Script> scripts = |
| 11 toObservable(new Map<String, Script>()); | 14 toObservable(new Map<String, Script>()); |
| 12 @observable final List<Code> codes = new List<Code>(); | 15 @observable final List<Code> codes = new List<Code>(); |
| 13 @observable String id; | 16 @observable String id; |
| 14 @observable String name; | 17 @observable String name; |
| 18 @observable Map entry; | |
| 19 @observable String rootLib; | |
| 20 @observable final Map<String, double> timers = | |
| 21 toObservable(new Map<String, double>()); | |
| 15 | 22 |
| 16 Isolate(this.id, this.name); | 23 @observable int newHeapUsed = 0; |
| 24 @observable int oldHeapUsed = 0; | |
| 17 | 25 |
| 18 String toString() => '$id $name'; | 26 @observable Map topFrame = null; |
| 27 @observable String fileAndLine = null; | |
| 28 | |
| 29 Isolate.fromId(this.id) : name = '$id' {} | |
| 30 | |
| 31 Isolate.fromMap(Map map) | |
| 32 : id = map['id'], name = map['name'] { | |
| 33 } | |
| 34 | |
| 35 void refresh() { | |
| 36 var request = '/$id/'; | |
| 37 _application.requestManager.requestMap(request).then((map) { | |
| 38 update(map); | |
| 39 }).catchError((e) { | |
| 40 Logger.root.severe('Error while updating isolate summary: $e'); | |
| 41 }); | |
| 42 } | |
| 43 | |
| 44 void update(Map map) { | |
| 45 if (map is! Map || map['type'] != 'Isolate') { | |
| 46 return; | |
| 47 } | |
| 48 if (map['name'] != null) { | |
| 49 name = map['name']; | |
| 50 } | |
| 51 if (map['rootLib'] != null) { | |
| 52 rootLib = map['rootLib']['id']; | |
| 53 } | |
| 54 if (map['entry'] != null) { | |
| 55 entry = map['entry']; | |
| 56 } | |
| 57 if (map['timers'] != null) { | |
| 58 var timerMap = {}; | |
| 59 map['timers'].forEach((timer) { | |
| 60 timerMap[timer['name']] = timer['time']; | |
| 61 }); | |
| 62 print(timerMap); | |
| 63 timers['total'] = timerMap['time_total_runtime']; | |
| 64 timers['compile'] = timerMap['time_compilation']; | |
| 65 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | |
| 66 timers['init'] = (timerMap['time_script_loading'] + | |
| 67 timerMap['time_creating_snapshot'] + | |
| 68 timerMap['time_isolate_initialization'] + | |
| 69 timerMap['time_bootstrap']); | |
| 70 timers['dart'] = timerMap['time_dart_execution']; | |
| 71 } | |
| 72 if (map['heap'] != null) { | |
|
Cutch
2014/01/28 19:32:51
Can we assert on these being present in the respon
turnidge
2014/01/28 23:18:55
I changed the code to detect the malformed respons
| |
| 73 newHeapUsed = map['heap']['usedNew']; | |
| 74 oldHeapUsed = map['heap']['usedOld']; | |
| 75 } | |
| 76 if (map['topFrame'] != null) { | |
| 77 topFrame = map['topFrame']; | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 String toString() => '$id'; | |
| 19 | 82 |
| 20 Code findCodeByAddress(int address) { | 83 Code findCodeByAddress(int address) { |
| 21 for (var i = 0; i < codes.length; i++) { | 84 for (var i = 0; i < codes.length; i++) { |
| 22 if (codes[i].contains(address)) { | 85 if (codes[i].contains(address)) { |
| 23 return codes[i]; | 86 return codes[i]; |
| 24 } | 87 } |
| 25 } | 88 } |
| 26 } | 89 } |
| 27 | 90 |
| 28 Code findCodeByName(String name) { | 91 Code findCodeByName(String name) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 46 var script = scripts[id]; | 109 var script = scripts[id]; |
| 47 if (script == null) { | 110 if (script == null) { |
| 48 script = new Script.fromMap(coverage['script']); | 111 script = new Script.fromMap(coverage['script']); |
| 49 scripts[id] = script; | 112 scripts[id] = script; |
| 50 } | 113 } |
| 51 assert(script != null); | 114 assert(script != null); |
| 52 script._processCoverageHits(coverage['hits']); | 115 script._processCoverageHits(coverage['hits']); |
| 53 } | 116 } |
| 54 } | 117 } |
| 55 } | 118 } |
| OLD | NEW |