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

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

Issue 197803004: Add dead CodeRegionTable for tracking overwritten Dart code (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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 return isolate.get(id).then(_addToCache); 47 return isolate.get(id).then(_addToCache);
48 } 48 }
49 49
50 /// If [obj] is cached, return the cached object. Otherwise, upgrades [obj] 50 /// If [obj] is cached, return the cached object. Otherwise, upgrades [obj]
51 /// and adds the upgraded value to the cache. 51 /// and adds the upgraded value to the cache.
52 T putIfAbsent(ObservableMap obj) { 52 T putIfAbsent(ObservableMap obj) {
53 assert(ServiceObject.isServiceMap(obj)); 53 assert(ServiceObject.isServiceMap(obj));
54 String id = obj['id']; 54 String id = obj['id'];
55 var type = obj['type']; 55 var type = obj['type'];
56 if (!cachesId(id)) {
57 Logger.root.warning('Cache does not cache this id: $id');
58 }
56 assert(cachesId(id)); 59 assert(cachesId(id));
57 if (contains(id)) { 60 if (contains(id)) {
58 return this[id]; 61 return this[id];
59 } 62 }
60 return _addToCache(_upgrade(obj)); 63 return _addToCache(_upgrade(obj));
61 } 64 }
62 65
63 T _addToCache(T so) { 66 T _addToCache(T so) {
64 this[so.id] = so; 67 this[so.id] = so;
65 return so; 68 return so;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return codeList; 113 return codeList;
111 } 114 }
112 115
113 void _resetProfileData() { 116 void _resetProfileData() {
114 _cache.forEach((k, Code code) { 117 _cache.forEach((k, Code code) {
115 code.resetProfileData(); 118 code.resetProfileData();
116 }); 119 });
117 } 120 }
118 121
119 void _updateProfileData(ServiceMap profile, List<Code> codeTable) { 122 void _updateProfileData(ServiceMap profile, List<Code> codeTable) {
120 var codes = profile['codes']; 123 var codeRegions = profile['codes'];
121 var sampleCount = profile['samples']; 124 var sampleCount = profile['samples'];
122 for (var profileCode in codes) { 125 for (var codeRegion in codeRegions) {
123 Code code = profileCode['code']; 126 Code code = codeRegion['code'];
124 code.updateProfileData(profileCode, codeTable, sampleCount); 127 code.updateProfileData(codeRegion, codeTable, sampleCount);
125 } 128 }
126 } 129 }
127 } 130 }
128 131
129 class ClassCache extends ServiceObjectCache<ServiceMap> { 132 class ClassCache extends ServiceObjectCache<ServiceMap> {
130 ClassCache(Isolate isolate) : super(isolate); 133 ClassCache(Isolate isolate) : super(isolate);
131 134
132 bool cachesId(String id) => _matcher.hasMatch(id); 135 bool cachesId(String id) => _matcher.hasMatch(id);
133 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Class'; 136 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Class';
134 ServiceMap _upgrade(ObservableMap obj) => 137 ServiceMap _upgrade(ObservableMap obj) =>
135 new ServiceMap.fromMap(isolate, obj); 138 new ServiceMap.fromMap(isolate, obj);
136 139
137 static final RegExp _matcher = new RegExp(r'classes/\d+$'); 140 static final RegExp _matcher = new RegExp(r'classes/\d+$');
138 } 141 }
142
143 class FunctionCache extends ServiceObjectCache<ServiceMap> {
144 FunctionCache(Isolate isolate) : super(isolate);
145
146 bool cachesId(String id) => _matcher.hasMatch(id);
147
148 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Function';
149 ServiceMap _upgrade(ObservableMap obj) =>
150 new ServiceMap.fromMap(isolate, obj);
151
152 static final RegExp _matcher =
153 new RegExp(r'^functions/native-.+|'
154 r'^functions/collected-.+|'
155 r'^functions/reused-.+|'
156 r'^functions/stub-.+|'
157 r'^classes/\d+/functions/.+|'
158 r'^classes/\d+/closures/.+|'
159 r'^classes/\d+/implicit_closures/.+|'
160 r'^classes/\d+/dispatchers/.+');
161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698