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

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: 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 _ignoreError(error, stackTrace) { 286 _ignoreError(error, stackTrace) {
287 // do nothing. 287 // do nothing.
288 } 288 }
289 } 289 }
290 290
291 abstract class Coverage { 291 abstract class Coverage {
292 // Following getters and functions will be provided by [ServiceObject]. 292 // Following getters and functions will be provided by [ServiceObject].
293 String get id; 293 String get id;
294 Isolate get isolate; 294 Isolate get isolate;
295 295
296 Future refreshCoverage() {
297 return refreshCallSiteData();
298 }
299
296 /// Default handler for coverage data. 300 /// Default handler for coverage data.
297 void processCoverageData(List coverageData) { 301 void processCallSiteData(List coverageData) {
298 coverageData.forEach((scriptCoverage) { 302 coverageData.forEach((scriptCoverage) {
299 assert(scriptCoverage['script'] != null); 303 assert(scriptCoverage['script'] != null);
300 scriptCoverage['script']._processHits(scriptCoverage['hits']); 304 scriptCoverage['script']._processCallSites(scriptCoverage['callSites']);
301 }); 305 });
302 } 306 }
303 307
304 Future refreshCoverage() { 308 Future refreshCallSiteData() {
305 Map params = {}; 309 Map params = {};
306 if (this is! Isolate) { 310 if (this is! Isolate) {
307 params['targetId'] = id; 311 params['targetId'] = id;
308 } 312 }
309 return isolate.invokeRpcNoUpgrade('getCoverage', params).then( 313 return isolate.invokeRpcNoUpgrade('getCallSiteData', params).then(
310 (ObservableMap map) { 314 (ObservableMap map) {
311 var coverage = new ServiceObject._fromMap(isolate, map); 315 var coverage = new ServiceObject._fromMap(isolate, map);
312 assert(coverage.type == 'CodeCoverage'); 316 assert(coverage.type == 'CodeCoverage');
313 var coverageList = coverage['coverage']; 317 var coverageList = coverage['coverage'];
314 assert(coverageList != null); 318 assert(coverageList != null);
315 processCoverageData(coverageList); 319 processCallSiteData(coverageList);
316 return this; 320 return this;
317 }); 321 });
318 } 322 }
319 } 323 }
320 324
321 abstract class ServiceObjectOwner extends ServiceObject { 325 abstract class ServiceObjectOwner extends ServiceObject {
322 /// Creates an empty [ServiceObjectOwner]. 326 /// Creates an empty [ServiceObjectOwner].
323 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); 327 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner);
324 328
325 /// Builds a [ServiceObject] corresponding to the [id] from [map]. 329 /// Builds a [ServiceObject] corresponding to the [id] from [map].
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 script = map['script']; 1947 script = map['script'];
1944 tokenPos = map['tokenPos']; 1948 tokenPos = map['tokenPos'];
1945 endTokenPos = map['endTokenPos']; 1949 endTokenPos = map['endTokenPos'];
1946 code = _convertNull(map['code']); 1950 code = _convertNull(map['code']);
1947 unoptimizedCode = _convertNull(map['unoptimizedCode']); 1951 unoptimizedCode = _convertNull(map['unoptimizedCode']);
1948 isOptimizable = map['optimizable']; 1952 isOptimizable = map['optimizable'];
1949 isInlinable = map['inlinable']; 1953 isInlinable = map['inlinable'];
1950 deoptimizations = map['deoptimizations']; 1954 deoptimizations = map['deoptimizations'];
1951 usageCounter = map['usageCounter']; 1955 usageCounter = map['usageCounter'];
1952 } 1956 }
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 } 1957 }
1979 1958
1980 1959
1981 class Field extends ServiceObject { 1960 class Field extends ServiceObject {
1982 @observable var /* Library or Class */ owner; 1961 @observable var /* Library or Class */ owner;
1983 @observable Instance declaredType; 1962 @observable Instance declaredType;
1984 @observable bool isStatic; 1963 @observable bool isStatic;
1985 @observable bool isFinal; 1964 @observable bool isFinal;
1986 @observable bool isConst; 1965 @observable bool isConst;
1987 @observable Instance value; 1966 @observable Instance value;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 final String name; 2081 final String name;
2103 final Script script; 2082 final Script script;
2104 final int tokenPos; 2083 final int tokenPos;
2105 final List<CallSiteEntry> entries; 2084 final List<CallSiteEntry> entries;
2106 2085
2107 CallSite(this.name, this.script, this.tokenPos, this.entries); 2086 CallSite(this.name, this.script, this.tokenPos, this.entries);
2108 2087
2109 int get line => script.tokenToLine(tokenPos); 2088 int get line => script.tokenToLine(tokenPos);
2110 int get column => script.tokenToCol(tokenPos); 2089 int get column => script.tokenToCol(tokenPos);
2111 2090
2091 int get aggregateCount {
2092 var count = 0;
2093 for (var entry in entries) {
2094 count += entry.count;
2095 }
2096 return count;
2097 }
2112 2098
2113 factory CallSite.fromMap(Map siteMap, Script script) { 2099 factory CallSite.fromMap(Map siteMap, Script script) {
2114 var name = siteMap['name']; 2100 var name = siteMap['name'];
2115 var tokenPos = siteMap['tokenPos']; 2101 var tokenPos = siteMap['tokenPos'];
2116 var entries = new List<CallSiteEntry>(); 2102 var entries = new List<CallSiteEntry>();
2117 for (var entryMap in siteMap['cacheEntries']) { 2103 for (var entryMap in siteMap['cacheEntries']) {
2118 entries.add(new CallSiteEntry.fromMap(entryMap)); 2104 entries.add(new CallSiteEntry.fromMap(entryMap));
2119 } 2105 }
2120 return new CallSite(name, script, tokenPos, entries); 2106 return new CallSite(name, script, tokenPos, entries);
2121 } 2107 }
2122 2108
2123 operator ==(other) { 2109 operator ==(other) {
2124 return (script == other.script) && (tokenPos == other.tokenPos); 2110 return (script == other.script) && (tokenPos == other.tokenPos);
2125 } 2111 }
2126 int get hashCode => (script.hashCode << 8) | tokenPos; 2112 int get hashCode => (script.hashCode << 8) | tokenPos;
2127 2113
2128 String toString() => "CallSite($name, $tokenPos)"; 2114 String toString() => "CallSite($name, $tokenPos)";
2129 } 2115 }
2130 2116
2131 class CallSiteEntry { 2117 class CallSiteEntry {
2132 final /* Class | Library */ receiverContainer; 2118 final /* Class | Library */ receiverContainer;
2133 final int count; 2119 final int count;
2120 final ServiceFunction target;
2134 2121
2135 CallSiteEntry(this.receiverContainer, this.count); 2122 CallSiteEntry(this.receiverContainer, this.count, this.target);
2136 2123
2137 factory CallSiteEntry.fromMap(Map entryMap) { 2124 factory CallSiteEntry.fromMap(Map entryMap) {
2138 return new CallSiteEntry(entryMap['receiverContainer'], 2125 return new CallSiteEntry(entryMap['receiverContainer'],
2139 entryMap['count']); 2126 entryMap['count'],
2127 entryMap['target']);
2140 } 2128 }
2141 2129
2142 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)"; 2130 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)";
2143 } 2131 }
2144 2132
2145 class Script extends ServiceObject with Coverage { 2133 class Script extends ServiceObject with Coverage {
2146 Set<CallSite> callSites = new Set<CallSite>(); 2134 Set<CallSite> callSites = new Set<CallSite>();
2147 final lines = new ObservableList<ScriptLine>(); 2135 final lines = new ObservableList<ScriptLine>();
2148 final _hits = new Map<int, int>(); 2136 final _hits = new Map<int, int>();
2149 @observable String kind; 2137 @observable String kind;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 } 2209 }
2222 2210
2223 for (var line in lines) { 2211 for (var line in lines) {
2224 // Remove possible breakpoints on lines with no tokens. 2212 // Remove possible breakpoints on lines with no tokens.
2225 if (!lineSet.contains(line.line)) { 2213 if (!lineSet.contains(line.line)) {
2226 line.possibleBpt = false; 2214 line.possibleBpt = false;
2227 } 2215 }
2228 } 2216 }
2229 } 2217 }
2230 2218
2231 void _processCallSites(List newCallSites) { 2219 void _processCallSites(List newCallSiteMaps) {
2232 var mergedCallSites = new Set(); 2220 var mergedCallSites = new Set<CallSite>();
2233 mergedCallSites.addAll(newCallSites); 2221 for (var callSiteMap in newCallSiteMaps) {
2234 mergedCallSites.addAll(callSites); 2222 var newSite = new CallSite.fromMap(callSiteMap, this);
2235 callSites = mergedCallSites; 2223 mergedCallSites.add(newSite);
2236 // Notify any Observers that this Script's state has changed.
2237 notifyChange(null);
2238 }
2239 2224
2240 void _processHits(List scriptHits) { 2225 var line = newSite.line;
2241 // Update hits table. 2226 var hit = newSite.aggregateCount;
2242 for (var i = 0; i < scriptHits.length; i += 2) {
2243 var line = scriptHits[i];
2244 var hit = scriptHits[i + 1]; // hit status.
2245 assert(line >= 1); // Lines start at 1. 2227 assert(line >= 1); // Lines start at 1.
2246 var oldHits = _hits[line]; 2228 var oldHits = _hits[line];
2247 if (oldHits != null) { 2229 if (oldHits != null) {
2248 hit += oldHits; 2230 hit += oldHits;
2249 } 2231 }
2250 _hits[line] = hit; 2232 _hits[line] = hit;
2251 } 2233 }
2234
2235 mergedCallSites.addAll(callSites);
2236 callSites = mergedCallSites;
2252 _applyHitsToLines(); 2237 _applyHitsToLines();
2253 // Notify any Observers that this Script's state has changed. 2238 // Notify any Observers that this Script's state has changed.
2254 notifyChange(null); 2239 notifyChange(null);
2255 } 2240 }
2256 2241
2257 void _processSource(String source) { 2242 void _processSource(String source) {
2258 // Preemptyively mark that this is not loaded. 2243 // Preemptyively mark that this is not loaded.
2259 _loaded = false; 2244 _loaded = false;
2260 if (source == null) { 2245 if (source == null) {
2261 return; 2246 return;
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 var v = list[i]; 2961 var v = list[i];
2977 if ((v is ObservableMap) && _isServiceMap(v)) { 2962 if ((v is ObservableMap) && _isServiceMap(v)) {
2978 list[i] = owner.getFromMap(v); 2963 list[i] = owner.getFromMap(v);
2979 } else if (v is ObservableList) { 2964 } else if (v is ObservableList) {
2980 _upgradeObservableList(v, owner); 2965 _upgradeObservableList(v, owner);
2981 } else if (v is ObservableMap) { 2966 } else if (v is ObservableMap) {
2982 _upgradeObservableMap(v, owner); 2967 _upgradeObservableMap(v, owner);
2983 } 2968 }
2984 } 2969 }
2985 } 2970 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/script_inset.dart ('k') | runtime/observatory/test/call_site_data_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698