| 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 // Some value smaller than the object ring, so requesting a large array | 7 // Some value smaller than the object ring, so requesting a large array |
| 8 // doesn't result in an expired ref because the elements lapped it in the | 8 // doesn't result in an expired ref because the elements lapped it in the |
| 9 // object ring. | 9 // object ring. |
| 10 const int kDefaultFieldLimit = 100; | 10 const int kDefaultFieldLimit = 100; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 String toString() => 'MalformedResponseRpcException(${message})'; | 86 String toString() => 'MalformedResponseRpcException(${message})'; |
| 87 } | 87 } |
| 88 | 88 |
| 89 class FakeVMRpcException extends RpcException { | 89 class FakeVMRpcException extends RpcException { |
| 90 FakeVMRpcException(String message) : super(message); | 90 FakeVMRpcException(String message) : super(message); |
| 91 | 91 |
| 92 String toString() => 'FakeVMRpcException(${message})'; | 92 String toString() => 'FakeVMRpcException(${message})'; |
| 93 } | 93 } |
| 94 | 94 |
| 95 /// A [ServiceObject] represents a persistent object within the vm. | 95 /// A [ServiceObject] represents a persistent object within the vm. |
| 96 abstract class ServiceObject extends Observable implements M.ObjectRef { | 96 abstract class ServiceObject extends Observable { |
| 97 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 97 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
| 98 return o1.name.compareTo(o2.name); | 98 return o1.name.compareTo(o2.name); |
| 99 } | 99 } |
| 100 | 100 |
| 101 List removeDuplicatesAndSortLexical(List<ServiceObject> list) { | 101 List removeDuplicatesAndSortLexical(List<ServiceObject> list) { |
| 102 return list.toSet().toList()..sort(LexicalSortName); | 102 return list.toSet().toList()..sort(LexicalSortName); |
| 103 } | 103 } |
| 104 | 104 |
| 105 /// The owner of this [ServiceObject]. This can be an [Isolate], a | 105 /// The owner of this [ServiceObject]. This can be an [Isolate], a |
| 106 /// [VM], or null. | 106 /// [VM], or null. |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 // Updates internal state from [map]. [map] can be a reference. | 374 // Updates internal state from [map]. [map] can be a reference. |
| 375 void _update(ObservableMap map, bool mapIsRef); | 375 void _update(ObservableMap map, bool mapIsRef); |
| 376 | 376 |
| 377 // Helper that can be passed to .catchError that ignores the error. | 377 // Helper that can be passed to .catchError that ignores the error. |
| 378 _ignoreError(error, stackTrace) { | 378 _ignoreError(error, stackTrace) { |
| 379 // do nothing. | 379 // do nothing. |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 | 382 |
| 383 abstract class HeapObject extends ServiceObject { | 383 abstract class HeapObject extends ServiceObject implements M.Object { |
| 384 @observable Class clazz; | 384 @observable Class clazz; |
| 385 @observable int size; | 385 @observable int size; |
| 386 @observable int retainedSize; | 386 @observable int retainedSize; |
| 387 | 387 |
| 388 HeapObject._empty(ServiceObjectOwner owner) : super._empty(owner); | 388 HeapObject._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 389 | 389 |
| 390 void _update(ObservableMap map, bool mapIsRef) { | 390 void _update(ObservableMap map, bool mapIsRef) { |
| 391 if (map['class'] != null) { | 391 if (map['class'] != null) { |
| 392 // Sent with refs for some types. Load it if available, but don't clobber | 392 // Sent with refs for some types. Load it if available, but don't clobber |
| 393 // it with null for kinds that only send if for full responses. | 393 // it with null for kinds that only send if for full responses. |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 snapshot.delta(counters, _maxSnapshot.counters); | 1071 snapshot.delta(counters, _maxSnapshot.counters); |
| 1072 _maxSnapshot.max(counters); | 1072 _maxSnapshot.max(counters); |
| 1073 snapshots.add(snapshot); | 1073 snapshots.add(snapshot); |
| 1074 // Only keep _historySize snapshots. | 1074 // Only keep _historySize snapshots. |
| 1075 if (snapshots.length > _historySize) { | 1075 if (snapshots.length > _historySize) { |
| 1076 snapshots.removeAt(0); | 1076 snapshots.removeAt(0); |
| 1077 } | 1077 } |
| 1078 } | 1078 } |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 class InboundReferences implements M.InboundReferences { |
| 1082 final Iterable<InboundReference> elements; |
| 1083 |
| 1084 InboundReferences(ServiceMap map) |
| 1085 : this.elements = map['references'] |
| 1086 .map((rmap) => new InboundReference(rmap)); |
| 1087 } |
| 1088 |
| 1089 class InboundReference implements M.InboundReference { |
| 1090 final HeapObject source; |
| 1091 final Instance parentField; |
| 1092 final int parentListIndex; |
| 1093 final int parentWordOffset; |
| 1094 |
| 1095 InboundReference(ServiceMap map) |
| 1096 : source = map['source'], |
| 1097 parentField = map['parentField'], |
| 1098 parentListIndex = map['parentListIndex'], |
| 1099 parentWordOffset = map['_parentWordOffset']; |
| 1100 } |
| 1101 |
| 1102 class RetainingPath implements M.RetainingPath { |
| 1103 final Iterable<RetainingPathItem> elements; |
| 1104 |
| 1105 RetainingPath(ServiceMap map) |
| 1106 : this.elements = map['elements'] |
| 1107 .map((rmap) => new RetainingPathItem(rmap)); |
| 1108 } |
| 1109 |
| 1110 class RetainingPathItem implements M.RetainingPathItem { |
| 1111 final HeapObject source; |
| 1112 final Instance parentField; |
| 1113 final int parentListIndex; |
| 1114 final int parentWordOffset; |
| 1115 |
| 1116 RetainingPathItem(ServiceMap map) |
| 1117 : source = map['value'], |
| 1118 parentField = map['parentField'], |
| 1119 parentListIndex = map['parentListIndex'], |
| 1120 parentWordOffset = map['_parentWordOffset']; |
| 1121 } |
| 1122 |
| 1081 class HeapSpace extends Observable implements M.HeapSpace { | 1123 class HeapSpace extends Observable implements M.HeapSpace { |
| 1082 @observable int used = 0; | 1124 @observable int used = 0; |
| 1083 @observable int capacity = 0; | 1125 @observable int capacity = 0; |
| 1084 @observable int external = 0; | 1126 @observable int external = 0; |
| 1085 @observable int collections = 0; | 1127 @observable int collections = 0; |
| 1086 @observable double totalCollectionTimeInSeconds = 0.0; | 1128 @observable double totalCollectionTimeInSeconds = 0.0; |
| 1087 @observable double averageCollectionPeriodInMillis = 0.0; | 1129 @observable double averageCollectionPeriodInMillis = 0.0; |
| 1088 | 1130 |
| 1089 Duration get avgCollectionTime { | 1131 Duration get avgCollectionTime { |
| 1090 final mcs = totalCollectionTimeInSeconds * Duration.MICROSECONDS_PER_SECOND | 1132 final mcs = totalCollectionTimeInSeconds * Duration.MICROSECONDS_PER_SECOND |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2539 @observable String name; | 2581 @observable String name; |
| 2540 @observable Class typeClass; | 2582 @observable Class typeClass; |
| 2541 @observable Class parameterizedClass; | 2583 @observable Class parameterizedClass; |
| 2542 @observable ServiceObject typeArguments; | 2584 @observable ServiceObject typeArguments; |
| 2543 @observable int parameterIndex; | 2585 @observable int parameterIndex; |
| 2544 @observable Instance targetType; | 2586 @observable Instance targetType; |
| 2545 @observable Instance bound; | 2587 @observable Instance bound; |
| 2546 | 2588 |
| 2547 @observable Iterable<BoundField> fields; | 2589 @observable Iterable<BoundField> fields; |
| 2548 @observable var nativeFields; | 2590 @observable var nativeFields; |
| 2549 @observable Iterable<Guarded<ServiceObject>> elements; // If a List. | 2591 @observable Iterable<Guarded<HeapObject>> elements; // If a List. |
| 2550 @observable Iterable<MapAssociation> associations; // If a Map. | 2592 @observable Iterable<MapAssociation> associations; // If a Map. |
| 2551 @observable Iterable<dynamic> typedElements; // If a TypedData. | 2593 @observable Iterable<dynamic> typedElements; // If a TypedData. |
| 2552 @observable ServiceObject referent; // If a MirrorReference. | 2594 @observable HeapObject referent; // If a MirrorReference. |
| 2553 @observable Instance key; // If a WeakProperty. | 2595 @observable Instance key; // If a WeakProperty. |
| 2554 @observable Instance value; // If a WeakProperty. | 2596 @observable Instance value; // If a WeakProperty. |
| 2555 @observable Breakpoint activationBreakpoint; // If a Closure. | 2597 @observable Breakpoint activationBreakpoint; // If a Closure. |
| 2556 @observable ServiceFunction oneByteFunction; // If a RegExp. | 2598 @observable ServiceFunction oneByteFunction; // If a RegExp. |
| 2557 @observable ServiceFunction twoByteFunction; // If a RegExp. | 2599 @observable ServiceFunction twoByteFunction; // If a RegExp. |
| 2558 @observable ServiceFunction externalOneByteFunction; // If a RegExp. | 2600 @observable ServiceFunction externalOneByteFunction; // If a RegExp. |
| 2559 @observable ServiceFunction externalTwoByteFunction; // If a RegExp. | 2601 @observable ServiceFunction externalTwoByteFunction; // If a RegExp. |
| 2560 @observable Instance oneByteBytecode; // If a RegExp. | 2602 @observable Instance oneByteBytecode; // If a RegExp. |
| 2561 @observable Instance twoByteBytecode; // If a RegExp. | 2603 @observable Instance twoByteBytecode; // If a RegExp. |
| 2562 @observable bool isCaseSensitive; // If a RegExp. | 2604 @observable bool isCaseSensitive; // If a RegExp. |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2897 kind = stringToSentinelKind(map['kind']); | 2939 kind = stringToSentinelKind(map['kind']); |
| 2898 valueAsString = map['valueAsString']; | 2940 valueAsString = map['valueAsString']; |
| 2899 _loaded = true; | 2941 _loaded = true; |
| 2900 } | 2942 } |
| 2901 | 2943 |
| 2902 String toString() => 'Sentinel($kind)'; | 2944 String toString() => 'Sentinel($kind)'; |
| 2903 } | 2945 } |
| 2904 | 2946 |
| 2905 class Field extends HeapObject implements M.FieldRef { | 2947 class Field extends HeapObject implements M.FieldRef { |
| 2906 // Library or Class. | 2948 // Library or Class. |
| 2907 @observable ServiceObject dartOwner; | 2949 @observable HeapObject dartOwner; |
| 2908 @observable Library library; | 2950 @observable Library library; |
| 2909 @observable Instance declaredType; | 2951 @observable Instance declaredType; |
| 2910 @observable bool isStatic; | 2952 @observable bool isStatic; |
| 2911 @observable bool isFinal; | 2953 @observable bool isFinal; |
| 2912 @observable bool isConst; | 2954 @observable bool isConst; |
| 2913 @observable Instance staticValue; | 2955 @observable Instance staticValue; |
| 2914 @observable String name; | 2956 @observable String name; |
| 2915 @observable String vmName; | 2957 @observable String vmName; |
| 2916 | 2958 |
| 2917 @observable bool guardNullable; | 2959 @observable bool guardNullable; |
| (...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4253 var v = list[i]; | 4295 var v = list[i]; |
| 4254 if ((v is ObservableMap) && _isServiceMap(v)) { | 4296 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 4255 list[i] = owner.getFromMap(v); | 4297 list[i] = owner.getFromMap(v); |
| 4256 } else if (v is ObservableList) { | 4298 } else if (v is ObservableList) { |
| 4257 _upgradeObservableList(v, owner); | 4299 _upgradeObservableList(v, owner); |
| 4258 } else if (v is ObservableMap) { | 4300 } else if (v is ObservableMap) { |
| 4259 _upgradeObservableMap(v, owner); | 4301 _upgradeObservableMap(v, owner); |
| 4260 } | 4302 } |
| 4261 } | 4303 } |
| 4262 } | 4304 } |
| OLD | NEW |