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 /// Helper function for canceling a Future<StreamSubscription>. | 7 /// Helper function for canceling a Future<StreamSubscription>. |
8 Future cancelFutureSubscription( | 8 Future cancelFutureSubscription( |
9 Future<StreamSubscription> subscriptionFuture) async { | 9 Future<StreamSubscription> subscriptionFuture) async { |
10 if (subscriptionFuture != null) { | 10 if (subscriptionFuture != null) { |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 HeapSnapshot(this.isolate, chunks, nodeCount) : | 965 HeapSnapshot(this.isolate, chunks, nodeCount) : |
966 graph = new ObjectGraph(chunks, nodeCount), | 966 graph = new ObjectGraph(chunks, nodeCount), |
967 timeStamp = new DateTime.now(); | 967 timeStamp = new DateTime.now(); |
968 | 968 |
969 List<Future<ServiceObject>> getMostRetained({int classId, int limit}) { | 969 List<Future<ServiceObject>> getMostRetained({int classId, int limit}) { |
970 var result = []; | 970 var result = []; |
971 for (ObjectVertex v in graph.getMostRetained(classId: classId, | 971 for (ObjectVertex v in graph.getMostRetained(classId: classId, |
972 limit: limit)) { | 972 limit: limit)) { |
973 result.add(isolate.getObjectByAddress(v.address) | 973 result.add(isolate.getObjectByAddress(v.address) |
974 .then((ServiceObject obj) { | 974 .then((ServiceObject obj) { |
975 if (obj is Instance) { | 975 if (obj is HeapObject) { |
976 // TODO(rmacnak): size/retainedSize are properties of all heap | |
977 // objects, not just Instances. | |
978 obj.retainedSize = v.retainedSize; | 976 obj.retainedSize = v.retainedSize; |
| 977 } else { |
| 978 print("${obj.runtimeType} should be a HeapObject"); |
979 } | 979 } |
980 return obj; | 980 return obj; |
981 })); | 981 })); |
982 } | 982 } |
983 return result; | 983 return result; |
984 } | 984 } |
985 } | 985 } |
986 | 986 |
987 /// State for a running isolate. | 987 /// State for a running isolate. |
988 class Isolate extends ServiceObjectOwner with Coverage { | 988 class Isolate extends ServiceObjectOwner with Coverage { |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 } | 2154 } |
2155 | 2155 |
2156 class Instance extends HeapObject { | 2156 class Instance extends HeapObject { |
2157 @observable String kind; | 2157 @observable String kind; |
2158 @observable String valueAsString; // If primitive. | 2158 @observable String valueAsString; // If primitive. |
2159 @observable bool valueAsStringIsTruncated; | 2159 @observable bool valueAsStringIsTruncated; |
2160 @observable ServiceFunction function; // If a closure. | 2160 @observable ServiceFunction function; // If a closure. |
2161 @observable Context context; // If a closure. | 2161 @observable Context context; // If a closure. |
2162 @observable String name; // If a Type. | 2162 @observable String name; // If a Type. |
2163 @observable int length; // If a List, Map or TypedData. | 2163 @observable int length; // If a List, Map or TypedData. |
2164 @observable String pattern; // If a RegExp. | 2164 @observable Instance pattern; // If a RegExp. |
2165 | 2165 |
2166 @observable var typeClass; | 2166 @observable var typeClass; |
2167 @observable var fields; | 2167 @observable var fields; |
2168 @observable var nativeFields; | 2168 @observable var nativeFields; |
2169 @observable var elements; // If a List. | 2169 @observable var elements; // If a List. |
2170 @observable var associations; // If a Map. | 2170 @observable var associations; // If a Map. |
2171 @observable var typedElements; // If a TypedData. | 2171 @observable var typedElements; // If a TypedData. |
2172 @observable var referent; // If a MirrorReference. | 2172 @observable var referent; // If a MirrorReference. |
2173 @observable Instance key; // If a WeakProperty. | 2173 @observable Instance key; // If a WeakProperty. |
2174 @observable Instance value; // If a WeakProperty. | 2174 @observable Instance value; // If a WeakProperty. |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 | 2675 |
2676 Script._empty(ServiceObjectOwner owner) : super._empty(owner); | 2676 Script._empty(ServiceObjectOwner owner) : super._empty(owner); |
2677 | 2677 |
2678 ScriptLine getLine(int line) { | 2678 ScriptLine getLine(int line) { |
2679 assert(_loaded); | 2679 assert(_loaded); |
2680 assert(line >= 1); | 2680 assert(line >= 1); |
2681 return lines[line - lineOffset - 1]; | 2681 return lines[line - lineOffset - 1]; |
2682 } | 2682 } |
2683 | 2683 |
2684 /// This function maps a token position to a line number. | 2684 /// This function maps a token position to a line number. |
2685 int tokenToLine(int token) => _tokenToLine[token]; | 2685 int tokenToLine(int tokenPos) => _tokenToLine[tokenPos]; |
2686 Map _tokenToLine = {}; | 2686 Map _tokenToLine = {}; |
2687 | 2687 |
2688 /// This function maps a token position to a column number. | 2688 /// This function maps a token position to a column number. |
2689 int tokenToCol(int token) => _tokenToCol[token]; | 2689 int tokenToCol(int tokenPos) => _tokenToCol[tokenPos]; |
2690 Map _tokenToCol = {}; | 2690 Map _tokenToCol = {}; |
2691 | 2691 |
| 2692 int guessTokenLength(int line, int column) { |
| 2693 String source = getLine(line).text; |
| 2694 |
| 2695 var pos = column; |
| 2696 if (pos >= source.length) { |
| 2697 return null; |
| 2698 } |
| 2699 |
| 2700 var c = source.codeUnitAt(pos); |
| 2701 if (c == 123) return 1; // { - Map literal |
| 2702 |
| 2703 if (c == 91) return 1; // [ - List literal, index, index assignment |
| 2704 |
| 2705 if (_isOperatorChar(c)) { |
| 2706 while (++pos < source.length && |
| 2707 _isOperatorChar(source.codeUnitAt(pos))); |
| 2708 return pos - column; |
| 2709 } |
| 2710 |
| 2711 if (_isInitialIdentifierChar(c)) { |
| 2712 while (++pos < source.length && |
| 2713 _isIdentifierChar(source.codeUnitAt(pos))); |
| 2714 return pos - column; |
| 2715 } |
| 2716 |
| 2717 return null; |
| 2718 } |
| 2719 |
| 2720 static bool _isOperatorChar(int c) { |
| 2721 switch (c) { |
| 2722 case 25: // % |
| 2723 case 26: // & |
| 2724 case 42: // * |
| 2725 case 43: // + |
| 2726 case 45: // -: |
| 2727 case 47: // / |
| 2728 case 60: // < |
| 2729 case 61: // = |
| 2730 case 62: // > |
| 2731 case 94: // ^ |
| 2732 case 124: // | |
| 2733 case 126: // ~ |
| 2734 return true; |
| 2735 default: |
| 2736 return false; |
| 2737 } |
| 2738 } |
| 2739 |
| 2740 static bool _isInitialIdentifierChar(int c) { |
| 2741 if (c >= 65 && c <= 90) return true; // Upper |
| 2742 if (c >= 97 && c <= 122) return true; // Lower |
| 2743 if (c == 95) return true; // Underscore |
| 2744 if (c == 36) return true; // Dollar |
| 2745 return false; |
| 2746 } |
| 2747 |
| 2748 static bool _isIdentifierChar(int c) { |
| 2749 if (_isInitialIdentifierChar(c)) return true; |
| 2750 return c >= 48 && c <= 75; // Digit |
| 2751 } |
| 2752 |
2692 void _update(ObservableMap map, bool mapIsRef) { | 2753 void _update(ObservableMap map, bool mapIsRef) { |
2693 _upgradeCollection(map, isolate); | 2754 _upgradeCollection(map, isolate); |
2694 super._update(map, mapIsRef); | 2755 super._update(map, mapIsRef); |
2695 | 2756 |
2696 uri = map['uri']; | 2757 uri = map['uri']; |
2697 kind = map['_kind']; | 2758 kind = map['_kind']; |
2698 _shortUri = uri.substring(uri.lastIndexOf('/') + 1); | 2759 _shortUri = uri.substring(uri.lastIndexOf('/') + 1); |
2699 name = _shortUri; | 2760 name = _shortUri; |
2700 vmName = uri; | 2761 vmName = uri; |
2701 if (mapIsRef) { | 2762 if (mapIsRef) { |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 var v = list[i]; | 3794 var v = list[i]; |
3734 if ((v is ObservableMap) && _isServiceMap(v)) { | 3795 if ((v is ObservableMap) && _isServiceMap(v)) { |
3735 list[i] = owner.getFromMap(v); | 3796 list[i] = owner.getFromMap(v); |
3736 } else if (v is ObservableList) { | 3797 } else if (v is ObservableList) { |
3737 _upgradeObservableList(v, owner); | 3798 _upgradeObservableList(v, owner); |
3738 } else if (v is ObservableMap) { | 3799 } else if (v is ObservableMap) { |
3739 _upgradeObservableMap(v, owner); | 3800 _upgradeObservableMap(v, owner); |
3740 } | 3801 } |
3741 } | 3802 } |
3742 } | 3803 } |
OLD | NEW |