| OLD | NEW |
| 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 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 script = map['script']; | 1941 script = map['script']; |
| 1942 tokenPos = map['tokenPos']; | 1942 tokenPos = map['tokenPos']; |
| 1943 endTokenPos = map['endTokenPos']; | 1943 endTokenPos = map['endTokenPos']; |
| 1944 code = _convertNull(map['code']); | 1944 code = _convertNull(map['code']); |
| 1945 unoptimizedCode = _convertNull(map['unoptimizedCode']); | 1945 unoptimizedCode = _convertNull(map['unoptimizedCode']); |
| 1946 isOptimizable = map['optimizable']; | 1946 isOptimizable = map['optimizable']; |
| 1947 isInlinable = map['inlinable']; | 1947 isInlinable = map['inlinable']; |
| 1948 deoptimizations = map['deoptimizations']; | 1948 deoptimizations = map['deoptimizations']; |
| 1949 usageCounter = map['usageCounter']; | 1949 usageCounter = map['usageCounter']; |
| 1950 } | 1950 } |
| 1951 |
| 1952 // TODO(rmacnak): Generalize and move to Coverage. |
| 1953 void processCallSiteData(List callSiteMaps) { |
| 1954 var callSites = new List(); |
| 1955 for (var callSiteMap in callSiteMaps) { |
| 1956 callSites.add(new CallSite.fromMap(callSiteMap, script)); |
| 1957 } |
| 1958 script._processCallSites(callSites); |
| 1959 } |
| 1960 |
| 1961 Future refreshCallSiteData() { |
| 1962 Map params = {}; |
| 1963 if (this is! Isolate) { |
| 1964 params['targetId'] = id; |
| 1965 } |
| 1966 return isolate.invokeRpcNoUpgrade('getCallSiteData', params).then( |
| 1967 (ObservableMap map) { |
| 1968 var data = new ServiceObject._fromMap(isolate, map); |
| 1969 assert(data.type == '_CallSiteData'); |
| 1970 var callSites = data['callSites']; |
| 1971 assert(callSites != null); |
| 1972 processCallSiteData(callSites); |
| 1973 return this; |
| 1974 }); |
| 1975 } |
| 1951 } | 1976 } |
| 1952 | 1977 |
| 1953 | 1978 |
| 1954 class Field extends ServiceObject { | 1979 class Field extends ServiceObject { |
| 1955 @observable var /* Library or Class */ owner; | 1980 @observable var /* Library or Class */ owner; |
| 1956 @observable Instance declaredType; | 1981 @observable Instance declaredType; |
| 1957 @observable bool isStatic; | 1982 @observable bool isStatic; |
| 1958 @observable bool isFinal; | 1983 @observable bool isFinal; |
| 1959 @observable bool isConst; | 1984 @observable bool isConst; |
| 1960 @observable Instance value; | 1985 @observable Instance value; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 void removeBreakpoint(Breakpoint bpt) { | 2089 void removeBreakpoint(Breakpoint bpt) { |
| 2065 assert(breakpoints != null && breakpoints.contains(bpt)); | 2090 assert(breakpoints != null && breakpoints.contains(bpt)); |
| 2066 breakpoints.remove(bpt); | 2091 breakpoints.remove(bpt); |
| 2067 if (breakpoints.isEmpty) { | 2092 if (breakpoints.isEmpty) { |
| 2068 breakpoints = null; | 2093 breakpoints = null; |
| 2069 breakpointResolved = false; | 2094 breakpointResolved = false; |
| 2070 } | 2095 } |
| 2071 } | 2096 } |
| 2072 } | 2097 } |
| 2073 | 2098 |
| 2099 class CallSite { |
| 2100 final String name; |
| 2101 final Script script; |
| 2102 final int tokenPos; |
| 2103 final List<CallSiteEntry> entries; |
| 2104 |
| 2105 CallSite(this.name, this.script, this.tokenPos, this.entries); |
| 2106 |
| 2107 int get line => script.tokenToLine(tokenPos); |
| 2108 int get column => script.tokenToCol(tokenPos); |
| 2109 |
| 2110 |
| 2111 factory CallSite.fromMap(Map siteMap, Script script) { |
| 2112 var name = siteMap['name']; |
| 2113 var tokenPos = siteMap['tokenPos']; |
| 2114 var entries = new List<CallSiteEntry>(); |
| 2115 for (var entryMap in siteMap['cacheEntries']) { |
| 2116 entries.add(new CallSiteEntry.fromMap(entryMap)); |
| 2117 } |
| 2118 return new CallSite(name, script, tokenPos, entries); |
| 2119 } |
| 2120 |
| 2121 operator ==(other) { |
| 2122 return (script == other.script) && (tokenPos == other.tokenPos); |
| 2123 } |
| 2124 int get hashCode => (script.hashCode << 8) | tokenPos; |
| 2125 |
| 2126 String toString() => "CallSite($name, $tokenPos)"; |
| 2127 } |
| 2128 |
| 2129 class CallSiteEntry { |
| 2130 final /* Class | Library */ receiverContainer; |
| 2131 final int count; |
| 2132 |
| 2133 CallSiteEntry(this.receiverContainer, this.count); |
| 2134 |
| 2135 factory CallSiteEntry.fromMap(Map entryMap) { |
| 2136 return new CallSiteEntry(entryMap['receiverContainer'], |
| 2137 entryMap['count']); |
| 2138 } |
| 2139 |
| 2140 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)"; |
| 2141 } |
| 2142 |
| 2074 class Script extends ServiceObject with Coverage { | 2143 class Script extends ServiceObject with Coverage { |
| 2144 Set<CallSite> callSites = new Set<CallSite>(); |
| 2075 final lines = new ObservableList<ScriptLine>(); | 2145 final lines = new ObservableList<ScriptLine>(); |
| 2076 final _hits = new Map<int, int>(); | 2146 final _hits = new Map<int, int>(); |
| 2077 @observable String kind; | 2147 @observable String kind; |
| 2078 @observable int firstTokenPos; | 2148 @observable int firstTokenPos; |
| 2079 @observable int lastTokenPos; | 2149 @observable int lastTokenPos; |
| 2080 @observable Library owningLibrary; | 2150 @observable Library owningLibrary; |
| 2081 bool get canCache => true; | 2151 bool get canCache => true; |
| 2082 bool get immutable => true; | 2152 bool get immutable => true; |
| 2083 | 2153 |
| 2084 String _shortUrl; | 2154 String _shortUrl; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 } | 2219 } |
| 2150 | 2220 |
| 2151 for (var line in lines) { | 2221 for (var line in lines) { |
| 2152 // Remove possible breakpoints on lines with no tokens. | 2222 // Remove possible breakpoints on lines with no tokens. |
| 2153 if (!lineSet.contains(line.line)) { | 2223 if (!lineSet.contains(line.line)) { |
| 2154 line.possibleBpt = false; | 2224 line.possibleBpt = false; |
| 2155 } | 2225 } |
| 2156 } | 2226 } |
| 2157 } | 2227 } |
| 2158 | 2228 |
| 2229 void _processCallSites(List newCallSites) { |
| 2230 var mergedCallSites = new Set(); |
| 2231 mergedCallSites.addAll(newCallSites); |
| 2232 mergedCallSites.addAll(callSites); |
| 2233 callSites = mergedCallSites; |
| 2234 // Notify any Observers that this Script's state has changed. |
| 2235 notifyChange(null); |
| 2236 } |
| 2237 |
| 2159 void _processHits(List scriptHits) { | 2238 void _processHits(List scriptHits) { |
| 2160 // Update hits table. | 2239 // Update hits table. |
| 2161 for (var i = 0; i < scriptHits.length; i += 2) { | 2240 for (var i = 0; i < scriptHits.length; i += 2) { |
| 2162 var line = scriptHits[i]; | 2241 var line = scriptHits[i]; |
| 2163 var hit = scriptHits[i + 1]; // hit status. | 2242 var hit = scriptHits[i + 1]; // hit status. |
| 2164 assert(line >= 1); // Lines start at 1. | 2243 assert(line >= 1); // Lines start at 1. |
| 2165 var oldHits = _hits[line]; | 2244 var oldHits = _hits[line]; |
| 2166 if (oldHits != null) { | 2245 if (oldHits != null) { |
| 2167 hit += oldHits; | 2246 hit += oldHits; |
| 2168 } | 2247 } |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 var v = list[i]; | 2974 var v = list[i]; |
| 2896 if ((v is ObservableMap) && _isServiceMap(v)) { | 2975 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 2897 list[i] = owner.getFromMap(v); | 2976 list[i] = owner.getFromMap(v); |
| 2898 } else if (v is ObservableList) { | 2977 } else if (v is ObservableList) { |
| 2899 _upgradeObservableList(v, owner); | 2978 _upgradeObservableList(v, owner); |
| 2900 } else if (v is ObservableMap) { | 2979 } else if (v is ObservableMap) { |
| 2901 _upgradeObservableMap(v, owner); | 2980 _upgradeObservableMap(v, owner); |
| 2902 } | 2981 } |
| 2903 } | 2982 } |
| 2904 } | 2983 } |
| OLD | NEW |