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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory/isolate.dart

Issue 184233007: Refactor Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of observatory;
6
7
8 /// State for a running isolate.
9 class Isolate extends Observable {
10 static ObservatoryApplication _application;
11
12 @observable Profile profile;
13 @observable final Map<String, Script> scripts =
14 toObservable(new Map<String, Script>());
15 @observable final List<Code> codes = new List<Code>();
16 @observable String id;
17 @observable String name;
18 @observable String vmName;
19 @observable Map entry;
20 @observable String rootLib;
21 @observable final Map<String, double> timers =
22 toObservable(new Map<String, double>());
23
24 @observable int newHeapUsed = 0;
25 @observable int oldHeapUsed = 0;
26
27 @observable Map topFrame = null;
28 @observable String fileAndLine = null;
29
30 Isolate.fromId(this.id) : name = 'isolate' {}
31
32 Isolate.fromMap(Map map)
33 : id = map['id'], name = map['name'] {
34 }
35
36 Future refresh() {
37 var request = '/$id/';
38 return _application.requestManager.requestMap(request).then((map) {
39 update(map);
40 }).catchError((e, trace) {
41 Logger.root.severe('Error while updating isolate summary: $e\n$trace' );
42 });
43 }
44
45 void update(Map map) {
46 if (map['type'] != 'Isolate') {
47 Logger.root.severe('Unexpected message type in Isolate.update: ${map["type "]}');
48 return;
49 }
50 if (map['rootLib'] == null ||
51 map['timers'] == null ||
52 map['heap'] == null) {
53 Logger.root.severe("Malformed 'Isolate' response: $map");
54 return;
55 }
56 rootLib = map['rootLib']['id'];
57 vmName = map['name'];
58 if (map['entry'] != null) {
59 entry = map['entry'];
60 name = entry['name'];
61 } else {
62 // fred
63 name = 'root isolate';
64 }
65 if (map['topFrame'] != null) {
66 topFrame = map['topFrame'];
67 }
68
69 var timerMap = {};
70 map['timers'].forEach((timer) {
71 timerMap[timer['name']] = timer['time'];
72 });
73 timers['total'] = timerMap['time_total_runtime'];
74 timers['compile'] = timerMap['time_compilation'];
75 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM.
76 timers['init'] = (timerMap['time_script_loading'] +
77 timerMap['time_creating_snapshot'] +
78 timerMap['time_isolate_initialization'] +
79 timerMap['time_bootstrap']);
80 timers['dart'] = timerMap['time_dart_execution'];
81
82 newHeapUsed = map['heap']['usedNew'];
83 oldHeapUsed = map['heap']['usedOld'];
84 }
85
86 String toString() => '$id';
87
88 Code findCodeByAddress(int address) {
89 for (var i = 0; i < codes.length; i++) {
90 if (codes[i].contains(address)) {
91 return codes[i];
92 }
93 }
94 return null;
95 }
96
97 Code findCodeByName(String name) {
98 for (var i = 0; i < codes.length; i++) {
99 if (codes[i].name == name) {
100 return codes[i];
101 }
102 }
103 return null;
104 }
105
106 void resetCodeTicks() {
107 Logger.root.info('Reset all code ticks.');
108 for (var i = 0; i < codes.length; i++) {
109 codes[i].resetTicks();
110 }
111 }
112
113 void updateCoverage(List coverages) {
114 for (var coverage in coverages) {
115 var id = coverage['script']['id'];
116 var script = scripts[id];
117 if (script == null) {
118 script = new Script.fromMap(coverage['script']);
119 scripts[id] = script;
120 }
121 assert(script != null);
122 script._processCoverageHits(coverage['hits']);
123 }
124 }
125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698