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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 1000933004: Display ICData entries at call sites, with links to the targets and guarded classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: super calls Created 5 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 /// A [ServiceObject] represents a persistent object within the vm. 7 /// A [ServiceObject] represents a persistent object within the vm.
8 abstract class ServiceObject extends Observable { 8 abstract class ServiceObject extends Observable {
9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { 9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) {
10 return o1.name.compareTo(o2.name); 10 return o1.name.compareTo(o2.name);
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return isolate.invokeRpcNoUpgrade('getCoverage', params).then( 309 return isolate.invokeRpcNoUpgrade('getCoverage', params).then(
310 (ObservableMap map) { 310 (ObservableMap map) {
311 var coverage = new ServiceObject._fromMap(isolate, map); 311 var coverage = new ServiceObject._fromMap(isolate, map);
312 assert(coverage.type == 'CodeCoverage'); 312 assert(coverage.type == 'CodeCoverage');
313 var coverageList = coverage['coverage']; 313 var coverageList = coverage['coverage'];
314 assert(coverageList != null); 314 assert(coverageList != null);
315 processCoverageData(coverageList); 315 processCoverageData(coverageList);
316 return this; 316 return this;
317 }); 317 });
318 } 318 }
319
320 /// Default handler for coverage data.
321 void processCallSiteData(List coverageData) {
322 coverageData.forEach((scriptCoverage) {
323 assert(scriptCoverage['script'] != null);
324 scriptCoverage['script']._processCallSites(scriptCoverage['callSites']);
325 });
326 }
327
328 Future refreshCallSiteData() {
329 Map params = {};
330 if (this is! Isolate) {
331 params['targetId'] = id;
332 }
333 return isolate.invokeRpcNoUpgrade('getCallSiteData', params).then(
334 (ObservableMap map) {
335 var coverage = new ServiceObject._fromMap(isolate, map);
336 assert(coverage.type == 'CodeCoverage');
337 var coverageList = coverage['coverage'];
338 assert(coverageList != null);
339 processCallSiteData(coverageList);
340 return this;
341 });
342 }
319 } 343 }
320 344
321 abstract class ServiceObjectOwner extends ServiceObject { 345 abstract class ServiceObjectOwner extends ServiceObject {
322 /// Creates an empty [ServiceObjectOwner]. 346 /// Creates an empty [ServiceObjectOwner].
323 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); 347 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner);
324 348
325 /// Builds a [ServiceObject] corresponding to the [id] from [map]. 349 /// Builds a [ServiceObject] corresponding to the [id] from [map].
326 /// The result may come from the cache. The result will not necessarily 350 /// The result may come from the cache. The result will not necessarily
327 /// be [loaded]. 351 /// be [loaded].
328 ServiceObject getFromMap(ObservableMap map); 352 ServiceObject getFromMap(ObservableMap map);
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 script = map['script']; 1967 script = map['script'];
1944 tokenPos = map['tokenPos']; 1968 tokenPos = map['tokenPos'];
1945 endTokenPos = map['endTokenPos']; 1969 endTokenPos = map['endTokenPos'];
1946 code = _convertNull(map['code']); 1970 code = _convertNull(map['code']);
1947 unoptimizedCode = _convertNull(map['unoptimizedCode']); 1971 unoptimizedCode = _convertNull(map['unoptimizedCode']);
1948 isOptimizable = map['optimizable']; 1972 isOptimizable = map['optimizable'];
1949 isInlinable = map['inlinable']; 1973 isInlinable = map['inlinable'];
1950 deoptimizations = map['deoptimizations']; 1974 deoptimizations = map['deoptimizations'];
1951 usageCounter = map['usageCounter']; 1975 usageCounter = map['usageCounter'];
1952 } 1976 }
1953
1954 // TODO(rmacnak): Generalize and move to Coverage.
1955 void processCallSiteData(List callSiteMaps) {
1956 var callSites = new List();
1957 for (var callSiteMap in callSiteMaps) {
1958 callSites.add(new CallSite.fromMap(callSiteMap, script));
1959 }
1960 script._processCallSites(callSites);
1961 }
1962
1963 Future refreshCallSiteData() {
1964 Map params = {};
1965 if (this is! Isolate) {
1966 params['targetId'] = id;
1967 }
1968 return isolate.invokeRpcNoUpgrade('getCallSiteData', params).then(
1969 (ObservableMap map) {
1970 var data = new ServiceObject._fromMap(isolate, map);
1971 assert(data.type == '_CallSiteData');
1972 var callSites = data['callSites'];
1973 assert(callSites != null);
1974 processCallSiteData(callSites);
1975 return this;
1976 });
1977 }
1978 } 1977 }
1979 1978
1980 1979
1981 class Field extends ServiceObject { 1980 class Field extends ServiceObject {
1982 @observable var /* Library or Class */ owner; 1981 @observable var /* Library or Class */ owner;
1983 @observable Instance declaredType; 1982 @observable Instance declaredType;
1984 @observable bool isStatic; 1983 @observable bool isStatic;
1985 @observable bool isFinal; 1984 @observable bool isFinal;
1986 @observable bool isConst; 1985 @observable bool isConst;
1987 @observable Instance value; 1986 @observable Instance value;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 final String name; 2101 final String name;
2103 final Script script; 2102 final Script script;
2104 final int tokenPos; 2103 final int tokenPos;
2105 final List<CallSiteEntry> entries; 2104 final List<CallSiteEntry> entries;
2106 2105
2107 CallSite(this.name, this.script, this.tokenPos, this.entries); 2106 CallSite(this.name, this.script, this.tokenPos, this.entries);
2108 2107
2109 int get line => script.tokenToLine(tokenPos); 2108 int get line => script.tokenToLine(tokenPos);
2110 int get column => script.tokenToCol(tokenPos); 2109 int get column => script.tokenToCol(tokenPos);
2111 2110
2112
2113 factory CallSite.fromMap(Map siteMap, Script script) { 2111 factory CallSite.fromMap(Map siteMap, Script script) {
2114 var name = siteMap['name']; 2112 var name = siteMap['name'];
2115 var tokenPos = siteMap['tokenPos']; 2113 var tokenPos = siteMap['tokenPos'];
2116 var entries = new List<CallSiteEntry>(); 2114 var entries = new List<CallSiteEntry>();
2117 for (var entryMap in siteMap['cacheEntries']) { 2115 for (var entryMap in siteMap['cacheEntries']) {
2118 entries.add(new CallSiteEntry.fromMap(entryMap)); 2116 entries.add(new CallSiteEntry.fromMap(entryMap));
2119 } 2117 }
2120 return new CallSite(name, script, tokenPos, entries); 2118 return new CallSite(name, script, tokenPos, entries);
2121 } 2119 }
2122 2120
2123 operator ==(other) { 2121 operator ==(other) {
2124 return (script == other.script) && (tokenPos == other.tokenPos); 2122 return (script == other.script) && (tokenPos == other.tokenPos);
2125 } 2123 }
2126 int get hashCode => (script.hashCode << 8) | tokenPos; 2124 int get hashCode => (script.hashCode << 8) | tokenPos;
2127 2125
2128 String toString() => "CallSite($name, $tokenPos)"; 2126 String toString() => "CallSite($name, $tokenPos)";
2129 } 2127 }
2130 2128
2131 class CallSiteEntry { 2129 class CallSiteEntry {
2132 final /* Class | Library */ receiverContainer; 2130 final /* Class | Library */ receiverContainer;
2133 final int count; 2131 final int count;
2132 final ServiceFunction target;
2134 2133
2135 CallSiteEntry(this.receiverContainer, this.count); 2134 CallSiteEntry(this.receiverContainer, this.count, this.target);
2136 2135
2137 factory CallSiteEntry.fromMap(Map entryMap) { 2136 factory CallSiteEntry.fromMap(Map entryMap) {
2138 return new CallSiteEntry(entryMap['receiverContainer'], 2137 return new CallSiteEntry(entryMap['receiverContainer'],
2139 entryMap['count']); 2138 entryMap['count'],
2139 entryMap['target']);
2140 } 2140 }
2141 2141
2142 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)"; 2142 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)";
2143 } 2143 }
2144 2144
2145 class Script extends ServiceObject with Coverage { 2145 class Script extends ServiceObject with Coverage {
2146 Set<CallSite> callSites = new Set<CallSite>(); 2146 Set<CallSite> callSites = new Set<CallSite>();
2147 final lines = new ObservableList<ScriptLine>(); 2147 final lines = new ObservableList<ScriptLine>();
2148 final _hits = new Map<int, int>(); 2148 final _hits = new Map<int, int>();
2149 @observable String kind; 2149 @observable String kind;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 } 2221 }
2222 2222
2223 for (var line in lines) { 2223 for (var line in lines) {
2224 // Remove possible breakpoints on lines with no tokens. 2224 // Remove possible breakpoints on lines with no tokens.
2225 if (!lineSet.contains(line.line)) { 2225 if (!lineSet.contains(line.line)) {
2226 line.possibleBpt = false; 2226 line.possibleBpt = false;
2227 } 2227 }
2228 } 2228 }
2229 } 2229 }
2230 2230
2231 void _processCallSites(List newCallSites) {
2232 var mergedCallSites = new Set();
2233 mergedCallSites.addAll(newCallSites);
2234 mergedCallSites.addAll(callSites);
2235 callSites = mergedCallSites;
2236 // Notify any Observers that this Script's state has changed.
2237 notifyChange(null);
2238 }
2239
2240 void _processHits(List scriptHits) { 2231 void _processHits(List scriptHits) {
2241 // Update hits table. 2232 // Update hits table.
2242 for (var i = 0; i < scriptHits.length; i += 2) { 2233 for (var i = 0; i < scriptHits.length; i += 2) {
2243 var line = scriptHits[i]; 2234 var line = scriptHits[i];
2244 var hit = scriptHits[i + 1]; // hit status. 2235 var hit = scriptHits[i + 1]; // hit status.
2245 assert(line >= 1); // Lines start at 1. 2236 assert(line >= 1); // Lines start at 1.
2246 var oldHits = _hits[line]; 2237 var oldHits = _hits[line];
2247 if (oldHits != null) { 2238 if (oldHits != null) {
2248 hit += oldHits; 2239 hit += oldHits;
2249 } 2240 }
2250 _hits[line] = hit; 2241 _hits[line] = hit;
2251 } 2242 }
2252 _applyHitsToLines(); 2243 _applyHitsToLines();
2253 // Notify any Observers that this Script's state has changed. 2244 // Notify any Observers that this Script's state has changed.
2254 notifyChange(null); 2245 notifyChange(null);
2255 } 2246 }
2256 2247
2248
2249 void _processCallSites(List newCallSiteMaps) {
2250 var mergedCallSites = new Set<CallSite>();
2251 for (var callSiteMap in newCallSiteMaps) {
2252 mergedCallSites.add(new CallSite.fromMap(callSiteMap, this));
2253 }
2254
2255 mergedCallSites.addAll(callSites);
2256 callSites = mergedCallSites;
2257 // Notify any Observers that this Script's state has changed.
2258 notifyChange(null);
2259 }
2260
2257 void _processSource(String source) { 2261 void _processSource(String source) {
2258 // Preemptyively mark that this is not loaded. 2262 // Preemptyively mark that this is not loaded.
2259 _loaded = false; 2263 _loaded = false;
2260 if (source == null) { 2264 if (source == null) {
2261 return; 2265 return;
2262 } 2266 }
2263 var sourceLines = source.split('\n'); 2267 var sourceLines = source.split('\n');
2264 if (sourceLines.length == 0) { 2268 if (sourceLines.length == 0) {
2265 return; 2269 return;
2266 } 2270 }
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 var v = list[i]; 2980 var v = list[i];
2977 if ((v is ObservableMap) && _isServiceMap(v)) { 2981 if ((v is ObservableMap) && _isServiceMap(v)) {
2978 list[i] = owner.getFromMap(v); 2982 list[i] = owner.getFromMap(v);
2979 } else if (v is ObservableList) { 2983 } else if (v is ObservableList) {
2980 _upgradeObservableList(v, owner); 2984 _upgradeObservableList(v, owner);
2981 } else if (v is ObservableMap) { 2985 } else if (v is ObservableMap) {
2982 _upgradeObservableMap(v, owner); 2986 _upgradeObservableMap(v, owner);
2983 } 2987 }
2984 } 2988 }
2985 } 2989 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698