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

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

Issue 1157003003: Add TypedData instance kinds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
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 /// An RpcException represents an exceptional event that happened 7 /// An RpcException represents an exceptional event that happened
8 /// while invoking an rpc. 8 /// while invoking an rpc.
9 abstract class RpcException implements Exception { 9 abstract class RpcException implements Exception {
10 RpcException(this.message); 10 RpcException(this.message);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 // Kinds of Instance. 111 // Kinds of Instance.
112 bool get isAbstractType => false; 112 bool get isAbstractType => false;
113 bool get isNull => false; 113 bool get isNull => false;
114 bool get isBool => false; 114 bool get isBool => false;
115 bool get isDouble => false; 115 bool get isDouble => false;
116 bool get isString => false; 116 bool get isString => false;
117 bool get isInt => false; 117 bool get isInt => false;
118 bool get isList => false; 118 bool get isList => false;
119 bool get isMap => false; 119 bool get isMap => false;
120 bool get isTypedData => false;
120 bool get isMirrorReference => false; 121 bool get isMirrorReference => false;
121 bool get isWeakProperty => false; 122 bool get isWeakProperty => false;
122 bool get isClosure => false; 123 bool get isClosure => false;
123 bool get isPlainInstance => false; 124 bool get isPlainInstance => false;
124 125
125 /// Has this object been fully loaded? 126 /// Has this object been fully loaded?
126 bool get loaded => _loaded; 127 bool get loaded => _loaded;
127 bool _loaded = false; 128 bool _loaded = false;
128 // TODO(turnidge): Make loaded observable and get rid of loading 129 // TODO(turnidge): Make loaded observable and get rid of loading
129 // from Isolate. 130 // from Isolate.
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 subclasses.sort(ServiceObject.LexicalSortName); 1838 subclasses.sort(ServiceObject.LexicalSortName);
1838 } 1839 }
1839 1840
1840 Future<ServiceObject> evaluate(String expression) { 1841 Future<ServiceObject> evaluate(String expression) {
1841 return isolate._eval(this, expression); 1842 return isolate._eval(this, expression);
1842 } 1843 }
1843 1844
1844 String toString() => 'Class($vmName)'; 1845 String toString() => 'Class($vmName)';
1845 } 1846 }
1846 1847
1848 const _decodeTable =
Cutch 2015/06/08 23:10:19 Move this to lib/base64.dart
rmacnak 2015/06/09 00:29:47 Done.
1849 const [null, null, null, null, null, null, null, null,
1850 null, null, null, null, null, null, null, null,
1851 null, null, null, null, null, null, null, null,
1852 null, null, null, null, null, null, null, null,
1853 null, null, null, null, null, null, null, null,
1854 null, null, null, 62, null, null, null, 63,
1855 52, 53, 54, 55, 56, 57, 58, 59,
1856 60, 61, null, null, null, 0, null, null,
1857 null, 0, 1, 2, 3, 4, 5, 6,
1858 7, 8, 9, 10, 11, 12, 13, 14,
1859 15, 16, 17, 18, 19, 20, 21, 22,
1860 23, 24, 25, null, null, null, null, null,
1861 null, 26, 27, 28, 29, 30, 31, 32,
1862 33, 34, 35, 36, 37, 38, 39, 40,
1863 41, 42, 43, 44, 45, 46, 47, 48,
1864 49, 50, 51];
1865
1866 Uint8List _decodeBase64(String s) {
1867 if (s.length % 4 != 0) throw "Malformed Base64: $s";
1868
1869 var odd_bits = 0;
1870 if (s[s.length - 1] == '=') {
1871 if (s[s.length - 2] == '=') {
1872 odd_bits = 2;
1873 } else {
1874 odd_bits = 1;
1875 }
1876 }
1877
1878 var result = new Uint8List(s.length ~/ 4 * 3 - odd_bits);
Cutch 2015/06/08 23:10:19 var decodedByteLength = ((s.length ~/ 4) * 3) - od
rmacnak 2015/06/09 00:29:47 Done.
1879 var limit = s.length;
1880 if (odd_bits != 0) {
1881 limit = limit - 4;
1882 }
1883
1884 var i = 0, j = 0;
1885 while (i < limit) {
1886 var triple = _decodeTable[s.codeUnitAt(i++)];
1887 triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
1888 triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
1889 triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
1890 result[j++] = triple >> 16;
1891 result[j++] = (triple >> 8) & 255;
1892 result[j++] = triple & 255;
1893 }
1894
1895 if (odd_bits != 0) {
1896 var triple = _decodeTable[s.codeUnitAt(i++)];
1897 triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
1898 triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
1899 triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
1900 result[j++] = triple >> 16;
1901 if (odd_bits == 1) {
1902 result[j++] = (triple >> 8) & 255;
1903 }
1904 }
1905
1906 return result;
Cutch 2015/06/08 23:10:19 assert(j == decodedByteLength); return result;
rmacnak 2015/06/09 00:29:47 Done.
1907 }
1908
1847 class Instance extends ServiceObject { 1909 class Instance extends ServiceObject {
1848 @observable String kind; 1910 @observable String kind;
1849 @observable Class clazz; 1911 @observable Class clazz;
1850 @observable int size; 1912 @observable int size;
1851 @observable int retainedSize; 1913 @observable int retainedSize;
1852 @observable String valueAsString; // If primitive. 1914 @observable String valueAsString; // If primitive.
1853 @observable bool valueAsStringIsTruncated; 1915 @observable bool valueAsStringIsTruncated;
1854 @observable ServiceFunction function; // If a closure. 1916 @observable ServiceFunction function; // If a closure.
1855 @observable Context context; // If a closure. 1917 @observable Context context; // If a closure.
1856 @observable String name; // If a Type. 1918 @observable String name; // If a Type.
1857 @observable int length; // If a List or Map. 1919 @observable int length; // If a List, Map or TypedData.
1858 1920
1859 @observable var typeClass; 1921 @observable var typeClass;
1860 @observable var fields; 1922 @observable var fields;
1861 @observable var nativeFields; 1923 @observable var nativeFields;
1862 @observable var elements; // If a List. 1924 @observable var elements; // If a List.
1863 @observable var associations; // If a Map. 1925 @observable var associations; // If a Map.
1926 @observable var typedElements; // If a TypedData.
1864 @observable var referent; // If a MirrorReference. 1927 @observable var referent; // If a MirrorReference.
1865 @observable Instance key; // If a WeakProperty. 1928 @observable Instance key; // If a WeakProperty.
1866 @observable Instance value; // If a WeakProperty. 1929 @observable Instance value; // If a WeakProperty.
1867 1930
1868 bool get isAbstractType { 1931 bool get isAbstractType {
1869 return (kind == 'Type' || kind == 'TypeRef' || 1932 return (kind == 'Type' || kind == 'TypeRef' ||
1870 kind == 'TypeParameter' || kind == 'BoundedType'); 1933 kind == 'TypeParameter' || kind == 'BoundedType');
1871 } 1934 }
1872 bool get isNull => kind == 'Null'; 1935 bool get isNull => kind == 'Null';
1873 bool get isBool => kind == 'Bool'; 1936 bool get isBool => kind == 'Bool';
1874 bool get isDouble => kind == 'Double'; 1937 bool get isDouble => kind == 'Double';
1875 bool get isString => kind == 'String'; 1938 bool get isString => kind == 'String';
1876 bool get isInt => kind == 'Int'; 1939 bool get isInt => kind == 'Int';
1877 bool get isList => kind == 'List'; 1940 bool get isList => kind == 'List';
1878 bool get isMap => kind == 'Map'; 1941 bool get isMap => kind == 'Map';
1942 bool get isTypedData {
1943 return kind == 'Uint8ClampedList'
1944 || kind == 'Uint8List'
1945 || kind == 'Uint16List'
1946 || kind == 'Uint32List'
1947 || kind == 'Uint64List'
1948 || kind == 'Int8List'
1949 || kind == 'Int16List'
1950 || kind == 'Int32List'
1951 || kind == 'Int64List'
1952 || kind == 'Float32List'
1953 || kind == 'Float64List'
1954 || kind == 'Int32x4List'
1955 || kind == 'Float32x4List'
1956 || kind == 'Float64x2List';
1957 }
1879 bool get isMirrorReference => kind == 'MirrorReference'; 1958 bool get isMirrorReference => kind == 'MirrorReference';
1880 bool get isWeakProperty => kind == 'WeakProperty'; 1959 bool get isWeakProperty => kind == 'WeakProperty';
1881 bool get isClosure => kind == 'Closure'; 1960 bool get isClosure => kind == 'Closure';
1882 1961
1883 // TODO(turnidge): Is this properly backwards compatible when new 1962 // TODO(turnidge): Is this properly backwards compatible when new
1884 // instance kinds are added? 1963 // instance kinds are added?
1885 bool get isPlainInstance => kind == 'PlainInstance'; 1964 bool get isPlainInstance => kind == 'PlainInstance';
1886 1965
1887 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); 1966 Instance._empty(ServiceObjectOwner owner) : super._empty(owner);
1888 1967
(...skipping 13 matching lines...) Expand all
1902 length = map['length']; 1981 length = map['length'];
1903 1982
1904 if (mapIsRef) { 1983 if (mapIsRef) {
1905 return; 1984 return;
1906 } 1985 }
1907 1986
1908 nativeFields = map['_nativeFields']; 1987 nativeFields = map['_nativeFields'];
1909 fields = map['fields']; 1988 fields = map['fields'];
1910 elements = map['elements']; 1989 elements = map['elements'];
1911 associations = map['associations']; 1990 associations = map['associations'];
1991 if (map['bytes'] != null) {
1992 var bytes = _decodeBase64(map['bytes']);
1993 switch (map['kind']) {
1994 case "Uint8ClampedList":
1995 typedElements = bytes.buffer.asUint8ClampedList(); break;
1996 case "Uint8List":
1997 typedElements = bytes.buffer.asUint8List(); break;
1998 case "Uint16List":
1999 typedElements = bytes.buffer.asUint16List(); break;
2000 case "Uint32List":
2001 typedElements = bytes.buffer.asUint32List(); break;
2002 case "Uint64List":
2003 typedElements = bytes.buffer.asUint64List(); break;
2004 case "Int8List":
2005 typedElements = bytes.buffer.asInt8List(); break;
2006 case "Int16List":
2007 typedElements = bytes.buffer.asInt16List(); break;
2008 case "Int32List":
2009 typedElements = bytes.buffer.asInt32List(); break;
2010 case "Int64List":
2011 typedElements = bytes.buffer.asInt64List(); break;
2012 case "Float32List":
2013 typedElements = bytes.buffer.asFloat32List(); break;
2014 case "Float64List":
2015 typedElements = bytes.buffer.asFloat64List(); break;
2016 case "Int32x4List":
2017 typedElements = bytes.buffer.asInt32x4List(); break;
2018 case "Float32x4List":
2019 typedElements = bytes.buffer.asFloat32x4List(); break;
2020 case "Float64x2List":
2021 typedElements = bytes.buffer.asFloat64x2List(); break;
2022 }
2023 }
1912 typeClass = map['typeClass']; 2024 typeClass = map['typeClass'];
1913 referent = map['mirrorReferent']; 2025 referent = map['mirrorReferent'];
1914 key = map['propertyKey']; 2026 key = map['propertyKey'];
1915 value = map['propertyValue']; 2027 value = map['propertyValue'];
1916 2028
1917 // We are fully loaded. 2029 // We are fully loaded.
1918 _loaded = true; 2030 _loaded = true;
1919 } 2031 }
1920 2032
1921 String get shortName { 2033 String get shortName {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 @observable Library library; 2206 @observable Library library;
2095 @observable Instance declaredType; 2207 @observable Instance declaredType;
2096 @observable bool isStatic; 2208 @observable bool isStatic;
2097 @observable bool isFinal; 2209 @observable bool isFinal;
2098 @observable bool isConst; 2210 @observable bool isConst;
2099 @observable Instance staticValue; 2211 @observable Instance staticValue;
2100 @observable String name; 2212 @observable String name;
2101 @observable String vmName; 2213 @observable String vmName;
2102 2214
2103 @observable bool guardNullable; 2215 @observable bool guardNullable;
2104 @observable String guardClass; 2216 @observable var /* Class | String */ guardClass;
2105 @observable String guardLength; 2217 @observable String guardLength;
2106 @observable SourceLocation location; 2218 @observable SourceLocation location;
2107 2219
2108 Field._empty(ServiceObjectOwner owner) : super._empty(owner); 2220 Field._empty(ServiceObjectOwner owner) : super._empty(owner);
2109 2221
2110 void _update(ObservableMap map, bool mapIsRef) { 2222 void _update(ObservableMap map, bool mapIsRef) {
2111 // Extract full properties. 2223 // Extract full properties.
2112 _upgradeCollection(map, isolate); 2224 _upgradeCollection(map, isolate);
2113 2225
2114 name = map['name']; 2226 name = map['name'];
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 var v = list[i]; 3379 var v = list[i];
3268 if ((v is ObservableMap) && _isServiceMap(v)) { 3380 if ((v is ObservableMap) && _isServiceMap(v)) {
3269 list[i] = owner.getFromMap(v); 3381 list[i] = owner.getFromMap(v);
3270 } else if (v is ObservableList) { 3382 } else if (v is ObservableList) {
3271 _upgradeObservableList(v, owner); 3383 _upgradeObservableList(v, owner);
3272 } else if (v is ObservableMap) { 3384 } else if (v is ObservableMap) {
3273 _upgradeObservableMap(v, owner); 3385 _upgradeObservableMap(v, owner);
3274 } 3386 }
3275 } 3387 }
3276 } 3388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698