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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/service/cache.dart

Issue 206213004: Add a VM page to the 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
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 /// Abstract [ServiceObjectCache]. 7 /// Abstract [ServiceObjectCache].
8 abstract class ServiceObjectCache<T extends ServiceObject> { 8 abstract class ServiceObjectCache<T extends ServiceObject> {
9 final Isolate isolate; 9 final Isolate isolate;
10 final _cache = new ObservableMap<String, T>(); 10 final _cache = new ObservableMap<String, T>();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 this[so.id] = so; 67 this[so.id] = so;
68 return so; 68 return so;
69 } 69 }
70 } 70 }
71 71
72 class ScriptCache extends ServiceObjectCache<Script> { 72 class ScriptCache extends ServiceObjectCache<Script> {
73 ScriptCache(Isolate isolate) : super(isolate); 73 ScriptCache(Isolate isolate) : super(isolate);
74 74
75 bool cachesId(String id) => _matcher.hasMatch(id); 75 bool cachesId(String id) => _matcher.hasMatch(id);
76 Script _upgrade(ObservableMap obj) => new Script.fromMap(isolate, obj); 76 Script _upgrade(ObservableMap obj) => new Script.fromMap(isolate, obj);
77 static final RegExp _matcher = new RegExp(r'scripts/.+'); 77 static final RegExp _matcher = new RegExp(r'^scripts/.+');
78 78
79 void _processCoverage(ServiceMap coverage) { 79 void _processCoverage(ServiceMap coverage) {
80 assert(coverage.serviceType == 'CodeCoverage'); 80 assert(coverage.serviceType == 'CodeCoverage');
81 var coverageList = coverage['coverage']; 81 var coverageList = coverage['coverage'];
82 assert(coverageList != null); 82 assert(coverageList != null);
83 coverageList.forEach((scriptCoverage) { 83 coverageList.forEach((scriptCoverage) {
84 _processScriptCoverage(scriptCoverage); 84 _processScriptCoverage(scriptCoverage);
85 }); 85 });
86 } 86 }
87 87
88 void _processScriptCoverage(ObservableMap scriptCoverage) { 88 void _processScriptCoverage(ObservableMap scriptCoverage) {
89 // Because the coverage data was upgraded into a ServiceObject, 89 // Because the coverage data was upgraded into a ServiceObject,
90 // the script can be directly accessed. 90 // the script can be directly accessed.
91 Script script = scriptCoverage['script']; 91 Script script = scriptCoverage['script'];
92 script._processHits(scriptCoverage['hits']); 92 script._processHits(scriptCoverage['hits']);
93 } 93 }
94 } 94 }
95 95
96 class CodeCache extends ServiceObjectCache<Code> { 96 class CodeCache extends ServiceObjectCache<Code> {
97 CodeCache(Isolate isolate) : super(isolate); 97 CodeCache(Isolate isolate) : super(isolate);
98 98
99 bool cachesId(String id) => _matcher.hasMatch(id); 99 bool cachesId(String id) => _matcher.hasMatch(id);
100 Code _upgrade(ObservableMap obj) => new Code.fromMap(isolate, obj); 100 Code _upgrade(ObservableMap obj) => new Code.fromMap(isolate, obj);
101 101
102 static final RegExp _matcher = new RegExp(r'code/.+'); 102 static final RegExp _matcher = new RegExp(r'^code/.+');
103 103
104 List<Code> topExclusive(int count) { 104 List<Code> topExclusive(int count) {
105 var codeList = _cache.values.toList(); 105 var codeList = _cache.values.toList();
106 codeList.sort((Code a, Code b) { 106 codeList.sort((Code a, Code b) {
107 return b.exclusiveTicks - a.exclusiveTicks; 107 return b.exclusiveTicks - a.exclusiveTicks;
108 }); 108 });
109 if (codeList.length < count) { 109 if (codeList.length < count) {
110 return codeList; 110 return codeList;
111 } 111 }
112 codeList.length = count; 112 codeList.length = count;
(...skipping 24 matching lines...) Expand all
137 } 137 }
138 138
139 class ClassCache extends ServiceObjectCache<ServiceMap> { 139 class ClassCache extends ServiceObjectCache<ServiceMap> {
140 ClassCache(Isolate isolate) : super(isolate); 140 ClassCache(Isolate isolate) : super(isolate);
141 141
142 bool cachesId(String id) => _matcher.hasMatch(id); 142 bool cachesId(String id) => _matcher.hasMatch(id);
143 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Class'; 143 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Class';
144 ServiceMap _upgrade(ObservableMap obj) => 144 ServiceMap _upgrade(ObservableMap obj) =>
145 new ServiceMap.fromMap(isolate, obj); 145 new ServiceMap.fromMap(isolate, obj);
146 146
147 static final RegExp _matcher = new RegExp(r'classes/\d+$'); 147 static final RegExp _matcher = new RegExp(r'^classes/\d+$');
148 } 148 }
149 149
150 class FunctionCache extends ServiceObjectCache<ServiceMap> { 150 class FunctionCache extends ServiceObjectCache<ServiceMap> {
151 FunctionCache(Isolate isolate) : super(isolate); 151 FunctionCache(Isolate isolate) : super(isolate);
152 152
153 bool cachesId(String id) => _matcher.hasMatch(id); 153 bool cachesId(String id) => _matcher.hasMatch(id);
154 154
155 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Function'; 155 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Function';
156 ServiceMap _upgrade(ObservableMap obj) => 156 ServiceMap _upgrade(ObservableMap obj) =>
157 new ServiceMap.fromMap(isolate, obj); 157 new ServiceMap.fromMap(isolate, obj);
158 158
159 static final RegExp _matcher = 159 static final RegExp _matcher =
160 new RegExp(r'^functions/native-.+|' 160 new RegExp(r'^functions/native-.+|'
161 r'^functions/collected-.+|' 161 r'^functions/collected-.+|'
162 r'^functions/reused-.+|' 162 r'^functions/reused-.+|'
163 r'^functions/stub-.+|' 163 r'^functions/stub-.+|'
164 r'^functions/tag-.+|' 164 r'^functions/tag-.+|'
165 r'^classes/\d+/functions/.+|' 165 r'^classes/\d+/functions/.+|'
166 r'^classes/\d+/closures/.+|' 166 r'^classes/\d+/closures/.+|'
167 r'^classes/\d+/implicit_closures/.+|' 167 r'^classes/\d+/implicit_closures/.+|'
168 r'^classes/\d+/dispatchers/.+'); 168 r'^classes/\d+/dispatchers/.+');
169 } 169 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/vm_view.html ('k') | runtime/bin/vmservice/client/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698