Chromium Code Reviews| 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 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1906 script = map['script']; | 1906 script = map['script']; |
| 1907 tokenPos = map['tokenPos']; | 1907 tokenPos = map['tokenPos']; |
| 1908 endTokenPos = map['endTokenPos']; | 1908 endTokenPos = map['endTokenPos']; |
| 1909 code = _convertNull(map['code']); | 1909 code = _convertNull(map['code']); |
| 1910 unoptimizedCode = _convertNull(map['unoptimizedCode']); | 1910 unoptimizedCode = _convertNull(map['unoptimizedCode']); |
| 1911 isOptimizable = map['optimizable']; | 1911 isOptimizable = map['optimizable']; |
| 1912 isInlinable = map['inlinable']; | 1912 isInlinable = map['inlinable']; |
| 1913 deoptimizations = map['deoptimizations']; | 1913 deoptimizations = map['deoptimizations']; |
| 1914 usageCounter = map['usageCounter']; | 1914 usageCounter = map['usageCounter']; |
| 1915 } | 1915 } |
| 1916 | |
| 1917 // TODO(rmacnak): Generalize and move to Coverage. | |
| 1918 void processCallSiteData(List callSiteMaps) { | |
| 1919 var callSites = new List(); | |
| 1920 for (var callSiteMap in callSiteMaps) { | |
| 1921 callSites.add(new CallSite.fromMap(callSiteMap)); | |
| 1922 } | |
| 1923 script._processCallSites(callSites); | |
| 1924 } | |
| 1925 | |
| 1926 Future refreshCallSiteData() { | |
| 1927 Map params = {}; | |
| 1928 if (this is! Isolate) { | |
| 1929 params['targetId'] = id; | |
| 1930 } | |
| 1931 return isolate.invokeRpcNoUpgrade('getCallSiteData', params).then( | |
| 1932 (ObservableMap map) { | |
| 1933 var data = new ServiceObject._fromMap(isolate, map); | |
| 1934 assert(data.type == '_CallSiteData'); | |
| 1935 var callSites = data['callSites']; | |
| 1936 assert(callSites != null); | |
| 1937 processCallSiteData(callSites); | |
| 1938 return this; | |
| 1939 }); | |
| 1940 } | |
| 1916 } | 1941 } |
| 1917 | 1942 |
| 1918 | 1943 |
| 1919 class Field extends ServiceObject { | 1944 class Field extends ServiceObject { |
| 1920 @observable var /* Library or Class */ owner; | 1945 @observable var /* Library or Class */ owner; |
| 1921 @observable Instance declaredType; | 1946 @observable Instance declaredType; |
| 1922 @observable bool isStatic; | 1947 @observable bool isStatic; |
| 1923 @observable bool isFinal; | 1948 @observable bool isFinal; |
| 1924 @observable bool isConst; | 1949 @observable bool isConst; |
| 1925 @observable Instance value; | 1950 @observable Instance value; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2019 // TODO(turnidge): This is not so efficient. Consider improving. | 2044 // TODO(turnidge): This is not so efficient. Consider improving. |
| 2020 for (var bpt in this.script.isolate.breakpoints) { | 2045 for (var bpt in this.script.isolate.breakpoints) { |
| 2021 if (bpt.script == this.script && | 2046 if (bpt.script == this.script && |
| 2022 bpt.script.tokenToLine(bpt.tokenPos) == line) { | 2047 bpt.script.tokenToLine(bpt.tokenPos) == line) { |
| 2023 this.bpt = bpt; | 2048 this.bpt = bpt; |
| 2024 } | 2049 } |
| 2025 } | 2050 } |
| 2026 } | 2051 } |
| 2027 } | 2052 } |
| 2028 | 2053 |
| 2054 class CallSite { | |
| 2055 final String name; | |
| 2056 final int line; | |
| 2057 final int column; | |
|
Cutch
2015/03/09 18:22:42
Can we store tokenPos and script instead?
rmacnak
2015/03/09 23:16:02
Done.
| |
| 2058 final List<CallSiteEntry> entries; | |
| 2059 | |
| 2060 CallSite(this.name, this.line, this.column, this.entries); | |
| 2061 | |
| 2062 factory CallSite.fromMap(Map siteMap) { | |
| 2063 var name = siteMap['name']; | |
| 2064 var line = siteMap['line']; | |
| 2065 var column = siteMap['column']; | |
| 2066 var entries = new List<CallSiteEntry>(); | |
| 2067 for (var entryMap in siteMap['cacheEntries']) { | |
| 2068 entries.add(new CallSiteEntry.fromMap(entryMap)); | |
| 2069 } | |
| 2070 return new CallSite(name, line, column, entries); | |
| 2071 } | |
| 2072 | |
| 2073 operator ==(other) { | |
| 2074 return line == other.line && column == other.column; | |
| 2075 } | |
| 2076 int get hashCode => (line << 8) | column; | |
| 2077 | |
| 2078 String toString() => "CallSite($name, $line:$column)"; | |
| 2079 } | |
| 2080 | |
| 2081 class CallSiteEntry { | |
|
Cutch
2015/03/09 18:22:42
Maybe rename to InstanceCall?
abstract class Call
| |
| 2082 final Class receiverClass; | |
| 2083 final int count; | |
| 2084 | |
| 2085 CallSiteEntry(this.receiverClass, this.count); | |
| 2086 | |
| 2087 factory CallSiteEntry.fromMap(Map entryMap) { | |
| 2088 return new CallSiteEntry(entryMap['receiverClass'], | |
| 2089 entryMap['count']); | |
| 2090 } | |
| 2091 | |
| 2092 String toString() => "CallSiteEntry(${receiverClass.name}, $count)"; | |
| 2093 } | |
| 2094 | |
| 2029 class Script extends ServiceObject with Coverage { | 2095 class Script extends ServiceObject with Coverage { |
| 2096 Set callSites = new Set(); | |
| 2030 final lines = new ObservableList<ScriptLine>(); | 2097 final lines = new ObservableList<ScriptLine>(); |
| 2031 final _hits = new Map<int, int>(); | 2098 final _hits = new Map<int, int>(); |
| 2032 @observable String kind; | 2099 @observable String kind; |
| 2033 @observable int firstTokenPos; | 2100 @observable int firstTokenPos; |
| 2034 @observable int lastTokenPos; | 2101 @observable int lastTokenPos; |
| 2035 @observable Library owningLibrary; | 2102 @observable Library owningLibrary; |
| 2036 bool get canCache => true; | 2103 bool get canCache => true; |
| 2037 bool get immutable => true; | 2104 bool get immutable => true; |
| 2038 | 2105 |
| 2039 String _shortUrl; | 2106 String _shortUrl; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2104 } | 2171 } |
| 2105 | 2172 |
| 2106 for (var line in lines) { | 2173 for (var line in lines) { |
| 2107 // Remove possible breakpoints on lines with no tokens. | 2174 // Remove possible breakpoints on lines with no tokens. |
| 2108 if (!lineSet.contains(line.line)) { | 2175 if (!lineSet.contains(line.line)) { |
| 2109 line.possibleBpt = false; | 2176 line.possibleBpt = false; |
| 2110 } | 2177 } |
| 2111 } | 2178 } |
| 2112 } | 2179 } |
| 2113 | 2180 |
| 2181 void _processCallSites(List newCallSites) { | |
| 2182 var mergedCallSites = new Set(); | |
| 2183 mergedCallSites.addAll(newCallSites); | |
| 2184 mergedCallSites.addAll(callSites); | |
| 2185 callSites = mergedCallSites; | |
| 2186 // Notify any Observers that this Script's state has changed. | |
| 2187 notifyChange(null); | |
| 2188 } | |
| 2189 | |
| 2114 void _processHits(List scriptHits) { | 2190 void _processHits(List scriptHits) { |
| 2115 // Update hits table. | 2191 // Update hits table. |
| 2116 for (var i = 0; i < scriptHits.length; i += 2) { | 2192 for (var i = 0; i < scriptHits.length; i += 2) { |
| 2117 var line = scriptHits[i]; | 2193 var line = scriptHits[i]; |
| 2118 var hit = scriptHits[i + 1]; // hit status. | 2194 var hit = scriptHits[i + 1]; // hit status. |
| 2119 assert(line >= 1); // Lines start at 1. | 2195 assert(line >= 1); // Lines start at 1. |
| 2120 var oldHits = _hits[line]; | 2196 var oldHits = _hits[line]; |
| 2121 if (oldHits != null) { | 2197 if (oldHits != null) { |
| 2122 hit += oldHits; | 2198 hit += oldHits; |
| 2123 } | 2199 } |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2832 var v = list[i]; | 2908 var v = list[i]; |
| 2833 if ((v is ObservableMap) && _isServiceMap(v)) { | 2909 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 2834 list[i] = owner.getFromMap(v); | 2910 list[i] = owner.getFromMap(v); |
| 2835 } else if (v is ObservableList) { | 2911 } else if (v is ObservableList) { |
| 2836 _upgradeObservableList(v, owner); | 2912 _upgradeObservableList(v, owner); |
| 2837 } else if (v is ObservableMap) { | 2913 } else if (v is ObservableMap) { |
| 2838 _upgradeObservableMap(v, owner); | 2914 _upgradeObservableMap(v, owner); |
| 2839 } | 2915 } |
| 2840 } | 2916 } |
| 2841 } | 2917 } |
| OLD | NEW |