| 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 /// 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 isTypedData => false; |
| 121 bool get isRegExp => false; |
| 121 bool get isMirrorReference => false; | 122 bool get isMirrorReference => false; |
| 122 bool get isWeakProperty => false; | 123 bool get isWeakProperty => false; |
| 123 bool get isClosure => false; | 124 bool get isClosure => false; |
| 124 bool get isPlainInstance => false; | 125 bool get isPlainInstance => false; |
| 125 | 126 |
| 126 /// Has this object been fully loaded? | 127 /// Has this object been fully loaded? |
| 127 bool get loaded => _loaded; | 128 bool get loaded => _loaded; |
| 128 bool _loaded = false; | 129 bool _loaded = false; |
| 129 // TODO(turnidge): Make loaded observable and get rid of loading | 130 // TODO(turnidge): Make loaded observable and get rid of loading |
| 130 // from Isolate. | 131 // from Isolate. |
| (...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 @observable String kind; | 1869 @observable String kind; |
| 1869 @observable Class clazz; | 1870 @observable Class clazz; |
| 1870 @observable int size; | 1871 @observable int size; |
| 1871 @observable int retainedSize; | 1872 @observable int retainedSize; |
| 1872 @observable String valueAsString; // If primitive. | 1873 @observable String valueAsString; // If primitive. |
| 1873 @observable bool valueAsStringIsTruncated; | 1874 @observable bool valueAsStringIsTruncated; |
| 1874 @observable ServiceFunction function; // If a closure. | 1875 @observable ServiceFunction function; // If a closure. |
| 1875 @observable Context context; // If a closure. | 1876 @observable Context context; // If a closure. |
| 1876 @observable String name; // If a Type. | 1877 @observable String name; // If a Type. |
| 1877 @observable int length; // If a List, Map or TypedData. | 1878 @observable int length; // If a List, Map or TypedData. |
| 1879 @observable String pattern; // If a RegExp. |
| 1878 | 1880 |
| 1879 @observable var typeClass; | 1881 @observable var typeClass; |
| 1880 @observable var fields; | 1882 @observable var fields; |
| 1881 @observable var nativeFields; | 1883 @observable var nativeFields; |
| 1882 @observable var elements; // If a List. | 1884 @observable var elements; // If a List. |
| 1883 @observable var associations; // If a Map. | 1885 @observable var associations; // If a Map. |
| 1884 @observable var typedElements; // If a TypedData. | 1886 @observable var typedElements; // If a TypedData. |
| 1885 @observable var referent; // If a MirrorReference. | 1887 @observable var referent; // If a MirrorReference. |
| 1886 @observable Instance key; // If a WeakProperty. | 1888 @observable Instance key; // If a WeakProperty. |
| 1887 @observable Instance value; // If a WeakProperty. | 1889 @observable Instance value; // If a WeakProperty. |
| 1888 @observable Breakpoint activationBreakpoint; // If a Closure. | 1890 @observable Breakpoint activationBreakpoint; // If a Closure. |
| 1891 @observable Function oneByteFunction; // If a RegExp. |
| 1892 @observable Function twoByteFunction; // If a RegExp. |
| 1893 @observable Function externalOneByteFunction; // If a RegExp. |
| 1894 @observable Function externalTwoByteFunction; // If a RegExp. |
| 1889 | 1895 |
| 1890 bool get isAbstractType { | 1896 bool get isAbstractType { |
| 1891 return (kind == 'Type' || kind == 'TypeRef' || | 1897 return (kind == 'Type' || kind == 'TypeRef' || |
| 1892 kind == 'TypeParameter' || kind == 'BoundedType'); | 1898 kind == 'TypeParameter' || kind == 'BoundedType'); |
| 1893 } | 1899 } |
| 1894 bool get isNull => kind == 'Null'; | 1900 bool get isNull => kind == 'Null'; |
| 1895 bool get isBool => kind == 'Bool'; | 1901 bool get isBool => kind == 'Bool'; |
| 1896 bool get isDouble => kind == 'Double'; | 1902 bool get isDouble => kind == 'Double'; |
| 1897 bool get isString => kind == 'String'; | 1903 bool get isString => kind == 'String'; |
| 1898 bool get isInt => kind == 'Int'; | 1904 bool get isInt => kind == 'Int'; |
| 1899 bool get isList => kind == 'List'; | 1905 bool get isList => kind == 'List'; |
| 1900 bool get isMap => kind == 'Map'; | 1906 bool get isMap => kind == 'Map'; |
| 1901 bool get isTypedData { | 1907 bool get isTypedData { |
| 1902 return kind == 'Uint8ClampedList' | 1908 return kind == 'Uint8ClampedList' |
| 1903 || kind == 'Uint8List' | 1909 || kind == 'Uint8List' |
| 1904 || kind == 'Uint16List' | 1910 || kind == 'Uint16List' |
| 1905 || kind == 'Uint32List' | 1911 || kind == 'Uint32List' |
| 1906 || kind == 'Uint64List' | 1912 || kind == 'Uint64List' |
| 1907 || kind == 'Int8List' | 1913 || kind == 'Int8List' |
| 1908 || kind == 'Int16List' | 1914 || kind == 'Int16List' |
| 1909 || kind == 'Int32List' | 1915 || kind == 'Int32List' |
| 1910 || kind == 'Int64List' | 1916 || kind == 'Int64List' |
| 1911 || kind == 'Float32List' | 1917 || kind == 'Float32List' |
| 1912 || kind == 'Float64List' | 1918 || kind == 'Float64List' |
| 1913 || kind == 'Int32x4List' | 1919 || kind == 'Int32x4List' |
| 1914 || kind == 'Float32x4List' | 1920 || kind == 'Float32x4List' |
| 1915 || kind == 'Float64x2List'; | 1921 || kind == 'Float64x2List'; |
| 1916 } | 1922 } |
| 1923 bool get isRegExp => kind == 'RegExp'; |
| 1917 bool get isMirrorReference => kind == 'MirrorReference'; | 1924 bool get isMirrorReference => kind == 'MirrorReference'; |
| 1918 bool get isWeakProperty => kind == 'WeakProperty'; | 1925 bool get isWeakProperty => kind == 'WeakProperty'; |
| 1919 bool get isClosure => kind == 'Closure'; | 1926 bool get isClosure => kind == 'Closure'; |
| 1920 | 1927 |
| 1921 // TODO(turnidge): Is this properly backwards compatible when new | 1928 // TODO(turnidge): Is this properly backwards compatible when new |
| 1922 // instance kinds are added? | 1929 // instance kinds are added? |
| 1923 bool get isPlainInstance => kind == 'PlainInstance'; | 1930 bool get isPlainInstance => kind == 'PlainInstance'; |
| 1924 | 1931 |
| 1925 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); | 1932 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 1926 | 1933 |
| 1927 void _update(ObservableMap map, bool mapIsRef) { | 1934 void _update(ObservableMap map, bool mapIsRef) { |
| 1928 // Extract full properties. | 1935 // Extract full properties. |
| 1929 _upgradeCollection(map, isolate); | 1936 _upgradeCollection(map, isolate); |
| 1930 | 1937 |
| 1931 kind = map['kind']; | 1938 kind = map['kind']; |
| 1932 clazz = map['class']; | 1939 clazz = map['class']; |
| 1933 size = map['size']; | 1940 size = map['size']; |
| 1934 valueAsString = map['valueAsString']; | 1941 valueAsString = map['valueAsString']; |
| 1935 // Coerce absence to false. | 1942 // Coerce absence to false. |
| 1936 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; | 1943 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; |
| 1937 function = map['closureFunction']; | 1944 function = map['closureFunction']; |
| 1938 context = map['closureContext']; | 1945 context = map['closureContext']; |
| 1939 name = map['name']; | 1946 name = map['name']; |
| 1940 length = map['length']; | 1947 length = map['length']; |
| 1948 pattern = map['pattern']; |
| 1941 | 1949 |
| 1942 if (mapIsRef) { | 1950 if (mapIsRef) { |
| 1943 return; | 1951 return; |
| 1944 } | 1952 } |
| 1945 | 1953 |
| 1954 oneByteFunction = map['_oneByteFunction']; |
| 1955 twoByteFunction = map['_twoByteFunction']; |
| 1956 externalOneByteFunction = map['_externalOneByteFunction']; |
| 1957 externalTwoByteFunction = map['_externalTwoByteFunction']; |
| 1958 |
| 1946 nativeFields = map['_nativeFields']; | 1959 nativeFields = map['_nativeFields']; |
| 1947 fields = map['fields']; | 1960 fields = map['fields']; |
| 1948 elements = map['elements']; | 1961 elements = map['elements']; |
| 1949 associations = map['associations']; | 1962 associations = map['associations']; |
| 1950 if (map['bytes'] != null) { | 1963 if (map['bytes'] != null) { |
| 1951 var bytes = decodeBase64(map['bytes']); | 1964 var bytes = decodeBase64(map['bytes']); |
| 1952 switch (map['kind']) { | 1965 switch (map['kind']) { |
| 1953 case "Uint8ClampedList": | 1966 case "Uint8ClampedList": |
| 1954 typedElements = bytes.buffer.asUint8ClampedList(); break; | 1967 typedElements = bytes.buffer.asUint8ClampedList(); break; |
| 1955 case "Uint8List": | 1968 case "Uint8List": |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 // Chop off the 0x. | 2813 // Chop off the 0x. |
| 2801 address = address.substring(2); | 2814 address = address.substring(2); |
| 2802 } | 2815 } |
| 2803 try { | 2816 try { |
| 2804 return int.parse(address, radix:16); | 2817 return int.parse(address, radix:16); |
| 2805 } catch (_) { | 2818 } catch (_) { |
| 2806 return 0; | 2819 return 0; |
| 2807 } | 2820 } |
| 2808 } | 2821 } |
| 2809 | 2822 |
| 2810 void _resolveJumpTarget(List<CodeInstruction> instructions) { | 2823 void _resolveJumpTarget(List<CodeInstruction> instructionsByAddressOffset, |
| 2824 int startAddress) { |
| 2811 if (!_isJumpInstruction()) { | 2825 if (!_isJumpInstruction()) { |
| 2812 return; | 2826 return; |
| 2813 } | 2827 } |
| 2814 int address = _getJumpAddress(); | 2828 int address = _getJumpAddress(); |
| 2815 if (address == 0) { | 2829 if (address == 0) { |
| 2816 return; | 2830 return; |
| 2817 } | 2831 } |
| 2818 for (var i = 0; i < instructions.length; i++) { | 2832 |
| 2819 var instruction = instructions[i]; | 2833 jumpTarget = instructionsByAddressOffset[address - startAddress]; |
| 2820 if (instruction.address == address) { | |
| 2821 jumpTarget = instruction; | |
| 2822 return; | |
| 2823 } | |
| 2824 } | |
| 2825 } | 2834 } |
| 2826 } | 2835 } |
| 2827 | 2836 |
| 2828 class CodeKind { | 2837 class CodeKind { |
| 2829 final _value; | 2838 final _value; |
| 2830 const CodeKind._internal(this._value); | 2839 const CodeKind._internal(this._value); |
| 2831 String toString() => '$_value'; | 2840 String toString() => '$_value'; |
| 2832 bool isSynthetic() => [Collected, Native, Tag].contains(this); | 2841 bool isSynthetic() => [Collected, Native, Tag].contains(this); |
| 2833 bool isDart() => !isSynthetic(); | 2842 bool isDart() => !isSynthetic(); |
| 2834 static CodeKind fromString(String s) { | 2843 static CodeKind fromString(String s) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2863 | 2872 |
| 2864 class Code extends ServiceObject { | 2873 class Code extends ServiceObject { |
| 2865 @observable CodeKind kind; | 2874 @observable CodeKind kind; |
| 2866 @observable ServiceObject objectPool; | 2875 @observable ServiceObject objectPool; |
| 2867 @observable ServiceFunction function; | 2876 @observable ServiceFunction function; |
| 2868 @observable Script script; | 2877 @observable Script script; |
| 2869 @observable bool isOptimized = false; | 2878 @observable bool isOptimized = false; |
| 2870 @reflectable int startAddress = 0; | 2879 @reflectable int startAddress = 0; |
| 2871 @reflectable int endAddress = 0; | 2880 @reflectable int endAddress = 0; |
| 2872 @reflectable final instructions = new ObservableList<CodeInstruction>(); | 2881 @reflectable final instructions = new ObservableList<CodeInstruction>(); |
| 2882 List<CodeInstruction> instructionsByAddressOffset; |
| 2883 |
| 2873 @observable ProfileCode profile; | 2884 @observable ProfileCode profile; |
| 2874 final List<CodeInlineInterval> inlineIntervals = | 2885 final List<CodeInlineInterval> inlineIntervals = |
| 2875 new List<CodeInlineInterval>(); | 2886 new List<CodeInlineInterval>(); |
| 2876 final ObservableList<ServiceFunction> inlinedFunctions = | 2887 final ObservableList<ServiceFunction> inlinedFunctions = |
| 2877 new ObservableList<ServiceFunction>(); | 2888 new ObservableList<ServiceFunction>(); |
| 2878 | 2889 |
| 2879 bool get immutable => true; | 2890 bool get immutable => true; |
| 2880 | 2891 |
| 2881 Code._empty(ServiceObjectOwner owner) : super._empty(owner); | 2892 Code._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2882 | 2893 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3001 } | 3012 } |
| 3002 inlineIntervals.add(codeInlineInterval); | 3013 inlineIntervals.add(codeInlineInterval); |
| 3003 } | 3014 } |
| 3004 } | 3015 } |
| 3005 | 3016 |
| 3006 @observable bool hasDisassembly = false; | 3017 @observable bool hasDisassembly = false; |
| 3007 | 3018 |
| 3008 void _processDisassembly(List<String> disassembly){ | 3019 void _processDisassembly(List<String> disassembly){ |
| 3009 assert(disassembly != null); | 3020 assert(disassembly != null); |
| 3010 instructions.clear(); | 3021 instructions.clear(); |
| 3022 instructionsByAddressOffset = new List(endAddress - startAddress); |
| 3023 |
| 3011 assert((disassembly.length % 3) == 0); | 3024 assert((disassembly.length % 3) == 0); |
| 3012 for (var i = 0; i < disassembly.length; i += 3) { | 3025 for (var i = 0; i < disassembly.length; i += 3) { |
| 3013 var address = 0; // Assume code comment. | 3026 var address = 0; // Assume code comment. |
| 3014 var machine = disassembly[i + 1]; | 3027 var machine = disassembly[i + 1]; |
| 3015 var human = disassembly[i + 2]; | 3028 var human = disassembly[i + 2]; |
| 3016 var pcOffset = 0; | 3029 var pcOffset = 0; |
| 3017 if (disassembly[i] != '') { | 3030 if (disassembly[i] != '') { |
| 3018 // Not a code comment, extract address. | 3031 // Not a code comment, extract address. |
| 3019 address = int.parse(disassembly[i]); | 3032 address = int.parse(disassembly[i]); |
| 3020 pcOffset = address - startAddress; | 3033 pcOffset = address - startAddress; |
| 3021 } | 3034 } |
| 3022 var instruction = new CodeInstruction(address, pcOffset, machine, human); | 3035 var instruction = new CodeInstruction(address, pcOffset, machine, human); |
| 3023 instructions.add(instruction); | 3036 instructions.add(instruction); |
| 3037 if (disassembly[i] != '') { |
| 3038 // Not a code comment. |
| 3039 instructionsByAddressOffset[pcOffset] = instruction; |
| 3040 } |
| 3024 } | 3041 } |
| 3025 for (var instruction in instructions) { | 3042 for (var instruction in instructions) { |
| 3026 instruction._resolveJumpTarget(instructions); | 3043 instruction._resolveJumpTarget(instructionsByAddressOffset, startAddress); |
| 3027 } | 3044 } |
| 3028 } | 3045 } |
| 3029 | 3046 |
| 3030 void _processDescriptor(Map d) { | 3047 void _processDescriptors(List<Map> descriptors) { |
| 3031 var pcOffset = int.parse(d['pcOffset'], radix:16); | 3048 for (Map descriptor in descriptors) { |
| 3032 var address = startAddress + pcOffset; | 3049 var pcOffset = int.parse(descriptor['pcOffset'], radix:16); |
| 3033 var deoptId = d['deoptId']; | 3050 var address = startAddress + pcOffset; |
| 3034 var tokenPos = d['tokenPos']; | 3051 var deoptId = descriptor['deoptId']; |
| 3035 var tryIndex = d['tryIndex']; | 3052 var tokenPos = descriptor['tokenPos']; |
| 3036 var kind = d['kind'].trim(); | 3053 var tryIndex = descriptor['tryIndex']; |
| 3037 for (var instruction in instructions) { | 3054 var kind = descriptor['kind'].trim(); |
| 3038 if (instruction.address == address) { | 3055 |
| 3056 var instruction = instructionsByAddressOffset[address - startAddress]; |
| 3057 if (instruction != null) { |
| 3039 instruction.descriptors.add(new PcDescriptor(pcOffset, | 3058 instruction.descriptors.add(new PcDescriptor(pcOffset, |
| 3040 deoptId, | 3059 deoptId, |
| 3041 tokenPos, | 3060 tokenPos, |
| 3042 tryIndex, | 3061 tryIndex, |
| 3043 kind)); | 3062 kind)); |
| 3044 return; | 3063 } else { |
| 3064 Logger.root.warning( |
| 3065 'Could not find instruction with pc descriptor address: $address'); |
| 3045 } | 3066 } |
| 3046 } | 3067 } |
| 3047 Logger.root.warning( | |
| 3048 'Could not find instruction with pc descriptor address: $address'); | |
| 3049 } | |
| 3050 | |
| 3051 void _processDescriptors(List<Map> descriptors) { | |
| 3052 for (Map descriptor in descriptors) { | |
| 3053 _processDescriptor(descriptor); | |
| 3054 } | |
| 3055 } | 3068 } |
| 3056 | 3069 |
| 3057 /// Returns true if [address] is contained inside [this]. | 3070 /// Returns true if [address] is contained inside [this]. |
| 3058 bool contains(int address) { | 3071 bool contains(int address) { |
| 3059 return (address >= startAddress) && (address < endAddress); | 3072 return (address >= startAddress) && (address < endAddress); |
| 3060 } | 3073 } |
| 3061 | 3074 |
| 3062 @reflectable bool get isDartCode => (kind == CodeKind.Dart) || | 3075 @reflectable bool get isDartCode => (kind == CodeKind.Dart) || |
| 3063 (kind == CodeKind.Stub); | 3076 (kind == CodeKind.Stub); |
| 3064 | 3077 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 var v = list[i]; | 3364 var v = list[i]; |
| 3352 if ((v is ObservableMap) && _isServiceMap(v)) { | 3365 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 3353 list[i] = owner.getFromMap(v); | 3366 list[i] = owner.getFromMap(v); |
| 3354 } else if (v is ObservableList) { | 3367 } else if (v is ObservableList) { |
| 3355 _upgradeObservableList(v, owner); | 3368 _upgradeObservableList(v, owner); |
| 3356 } else if (v is ObservableMap) { | 3369 } else if (v is ObservableMap) { |
| 3357 _upgradeObservableMap(v, owner); | 3370 _upgradeObservableMap(v, owner); |
| 3358 } | 3371 } |
| 3359 } | 3372 } |
| 3360 } | 3373 } |
| OLD | NEW |