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

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

Issue 2291233002: Converted Observatory instance-view element (Closed)
Patch Set: Addressed comments Created 4 years, 3 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 // 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 break; 260 break;
261 case 'Script': 261 case 'Script':
262 obj = new Script._empty(owner); 262 obj = new Script._empty(owner);
263 break; 263 break;
264 case 'Socket': 264 case 'Socket':
265 obj = new Socket._empty(owner); 265 obj = new Socket._empty(owner);
266 break; 266 break;
267 case 'Sentinel': 267 case 'Sentinel':
268 obj = new Sentinel._empty(owner); 268 obj = new Sentinel._empty(owner);
269 break; 269 break;
270 case 'TypeArguments':
271 obj = new TypeArguments._empty(owner);
272 break;
270 case 'Instance': 273 case 'Instance':
271 obj = new Instance._empty(owner); 274 obj = new Instance._empty(owner);
272 break; 275 break;
273 default: 276 default:
274 break; 277 break;
275 } 278 }
276 if (obj == null) { 279 if (obj == null) {
277 obj = new ServiceMap._empty(owner); 280 obj = new ServiceMap._empty(owner);
278 } 281 }
279 obj.update(map); 282 obj.update(map);
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 } 1359 }
1357 1360
1358 /// Builds the class hierarchy and returns the Object class. 1361 /// Builds the class hierarchy and returns the Object class.
1359 Future<Class> _buildClassHierarchy(List<Class> classes) { 1362 Future<Class> _buildClassHierarchy(List<Class> classes) {
1360 rootClasses.clear(); 1363 rootClasses.clear();
1361 objectClass = null; 1364 objectClass = null;
1362 for (var cls in classes) { 1365 for (var cls in classes) {
1363 if (cls.superclass == null) { 1366 if (cls.superclass == null) {
1364 rootClasses.add(cls); 1367 rootClasses.add(cls);
1365 } 1368 }
1366 if ((cls.vmName == 'Object') && (cls.isPatch == false)) { 1369 if ((cls.vmName == 'Object') &&
1370 (cls.isPatch == false) &&
1371 (cls.library.uri == 'dart:core')) {
1367 objectClass = cls; 1372 objectClass = cls;
1368 } 1373 }
1369 } 1374 }
1370 assert(objectClass != null); 1375 assert(objectClass != null);
1371 return new Future.value(objectClass); 1376 return new Future.value(objectClass);
1372 } 1377 }
1373 1378
1374 Class getClassByCid(int cid) => _classesByCid[cid]; 1379 Class getClassByCid(int cid) => _classesByCid[cid];
1375 1380
1376 ServiceObject getFromMap(ObservableMap map) { 1381 ServiceObject getFromMap(ObservableMap map) {
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 : asSentinel = null; 2584 : asSentinel = null;
2580 } 2585 }
2581 2586
2582 class BoundField implements M.BoundField { 2587 class BoundField implements M.BoundField {
2583 final Field decl; 2588 final Field decl;
2584 final Guarded<Instance> value; 2589 final Guarded<Instance> value;
2585 BoundField(this.decl, value) 2590 BoundField(this.decl, value)
2586 : value = new Guarded(value); 2591 : value = new Guarded(value);
2587 } 2592 }
2588 2593
2594 class NativeField implements M.NativeField {
2595 final int value;
2596 NativeField(this.value);
2597 }
2598
2589 class MapAssociation implements M.MapAssociation { 2599 class MapAssociation implements M.MapAssociation {
2590 final Guarded<Instance> key; 2600 final Guarded<Instance> key;
2591 final Guarded<Instance> value; 2601 final Guarded<Instance> value;
2592 MapAssociation(key, value) 2602 MapAssociation(key, value)
2593 : key = new Guarded(key), 2603 : key = new Guarded(key),
2594 value = new Guarded(value); 2604 value = new Guarded(value);
2595 } 2605 }
2596 2606
2597 class Instance extends HeapObject implements M.Instance { 2607 class Instance extends HeapObject implements M.Instance {
2598 @observable M.InstanceKind kind; 2608 @observable M.InstanceKind kind;
2599 @observable String valueAsString; // If primitive. 2609 @observable String valueAsString; // If primitive.
2600 @observable bool valueAsStringIsTruncated; 2610 @observable bool valueAsStringIsTruncated;
2601 @observable ServiceFunction closureFunction; // If a closure. 2611 @observable ServiceFunction closureFunction; // If a closure.
2602 @observable Context context; // If a closure. 2612 @observable Context closureContext; // If a closure.
2603 @observable int length; // If a List, Map or TypedData. 2613 @observable int length; // If a List, Map or TypedData.
2604 int count; 2614 int count;
2605 int offset; 2615 int offset;
2606 @observable Instance pattern; // If a RegExp. 2616 @observable Instance pattern; // If a RegExp.
2607 2617
2608 @observable String name; 2618 @observable String name;
2609 @observable Class typeClass; 2619 @observable Class typeClass;
2610 @observable Class parameterizedClass; 2620 @observable Class parameterizedClass;
2611 @observable ServiceObject typeArguments; 2621 @observable TypeArguments typeArguments;
2612 @observable int parameterIndex; 2622 @observable int parameterIndex;
2613 @observable Instance targetType; 2623 @observable Instance targetType;
2614 @observable Instance bound; 2624 @observable Instance bound;
2615 2625
2616 @observable Iterable<BoundField> fields; 2626 @observable Iterable<BoundField> fields;
2617 @observable var nativeFields; 2627 @observable var nativeFields;
2618 @observable Iterable<Guarded<HeapObject>> elements; // If a List. 2628 @observable Iterable<Guarded<HeapObject>> elements; // If a List.
2619 @observable Iterable<MapAssociation> associations; // If a Map. 2629 @observable Iterable<MapAssociation> associations; // If a Map.
2620 @observable Iterable<dynamic> typedElements; // If a TypedData. 2630 @observable Iterable<dynamic> typedElements; // If a TypedData.
2621 @observable HeapObject referent; // If a MirrorReference. 2631 @observable HeapObject referent; // If a MirrorReference.
2622 @observable Instance key; // If a WeakProperty. 2632 @observable Instance key; // If a WeakProperty.
2623 @observable Instance value; // If a WeakProperty. 2633 @observable Instance value; // If a WeakProperty.
2624 @observable Breakpoint activationBreakpoint; // If a Closure. 2634 @observable Breakpoint activationBreakpoint; // If a Closure.
2625 @observable ServiceFunction oneByteFunction; // If a RegExp. 2635 @observable ServiceFunction oneByteFunction; // If a RegExp.
2626 @observable ServiceFunction twoByteFunction; // If a RegExp. 2636 @observable ServiceFunction twoByteFunction; // If a RegExp.
2627 @observable ServiceFunction externalOneByteFunction; // If a RegExp. 2637 @observable ServiceFunction externalOneByteFunction; // If a RegExp.
2628 @observable ServiceFunction externalTwoByteFunction; // If a RegExp. 2638 @observable ServiceFunction externalTwoByteFunction; // If a RegExp.
2629 @observable Instance oneByteBytecode; // If a RegExp. 2639 @observable Instance oneByteBytecode; // If a RegExp.
2630 @observable Instance twoByteBytecode; // If a RegExp. 2640 @observable Instance twoByteBytecode; // If a RegExp.
2631 @observable bool isCaseSensitive; // If a RegExp. 2641 @observable bool isCaseSensitive; // If a RegExp.
2632 @observable bool isMultiLine; // If a RegExp. 2642 @observable bool isMultiLine; // If a RegExp.
2633 2643
2634 bool get isAbstractType { 2644 bool get isAbstractType => M.isAbstractType(kind);
2635 return (kind == M.InstanceKind.type ||
2636 kind == M.InstanceKind.typeRef ||
2637 kind == M.InstanceKind.typeParameter ||
2638 kind == M.InstanceKind.boundedType);
2639 }
2640 bool get isNull => kind == M.InstanceKind.vNull; 2645 bool get isNull => kind == M.InstanceKind.vNull;
2641 bool get isBool => kind == M.InstanceKind.bool; 2646 bool get isBool => kind == M.InstanceKind.bool;
2642 bool get isDouble => kind == M.InstanceKind.double; 2647 bool get isDouble => kind == M.InstanceKind.double;
2643 bool get isString => kind == M.InstanceKind.string; 2648 bool get isString => kind == M.InstanceKind.string;
2644 bool get isInt => kind == M.InstanceKind.int; 2649 bool get isInt => kind == M.InstanceKind.int;
2645 bool get isList => kind == M.InstanceKind.list; 2650 bool get isList => kind == M.InstanceKind.list;
2646 bool get isMap => kind == M.InstanceKind.map; 2651 bool get isMap => kind == M.InstanceKind.map;
2647 bool get isTypedData { 2652 bool get isTypedData {
2648 return M.isTypedData(kind); 2653 return M.isTypedData(kind);
2649 } 2654 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 void _update(ObservableMap map, bool mapIsRef) { 2689 void _update(ObservableMap map, bool mapIsRef) {
2685 // Extract full properties.1 2690 // Extract full properties.1
2686 _upgradeCollection(map, isolate); 2691 _upgradeCollection(map, isolate);
2687 super._update(map, mapIsRef); 2692 super._update(map, mapIsRef);
2688 2693
2689 kind = stringToInstanceKind(map['kind']); 2694 kind = stringToInstanceKind(map['kind']);
2690 valueAsString = map['valueAsString']; 2695 valueAsString = map['valueAsString'];
2691 // Coerce absence to false. 2696 // Coerce absence to false.
2692 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; 2697 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true;
2693 closureFunction = map['closureFunction']; 2698 closureFunction = map['closureFunction'];
2694 context = map['closureContext']; 2699 closureContext = map['closureContext'];
2695 name = map['name']; 2700 name = map['name'];
2696 length = map['length']; 2701 length = map['length'];
2697 pattern = map['pattern']; 2702 pattern = map['pattern'];
2698 typeClass = map['typeClass']; 2703 typeClass = map['typeClass'];
2699 2704
2700 if (mapIsRef) { 2705 if (mapIsRef) {
2701 return; 2706 return;
2702 } 2707 }
2703 2708
2704 count = map['count']; 2709 count = map['count'];
2705 offset = map['offset']; 2710 offset = map['offset'];
2706 isCaseSensitive = map['isCaseSensitive']; 2711 isCaseSensitive = map['isCaseSensitive'];
2707 isMultiLine = map['isMultiLine']; 2712 isMultiLine = map['isMultiLine'];
2708 bool isCompiled = map['_oneByteFunction'] is ServiceFunction; 2713 bool isCompiled = map['_oneByteFunction'] is ServiceFunction;
2709 oneByteFunction = isCompiled ? map['_oneByteFunction'] : null; 2714 oneByteFunction = isCompiled ? map['_oneByteFunction'] : null;
2710 twoByteFunction = isCompiled ? map['_twoByteFunction'] : null; 2715 twoByteFunction = isCompiled ? map['_twoByteFunction'] : null;
2711 externalOneByteFunction = isCompiled ? map['_externalOneByteFunction'] : nul l; 2716 externalOneByteFunction = isCompiled ? map['_externalOneByteFunction'] : nul l;
2712 externalTwoByteFunction = isCompiled ? map['_externalTwoByteFunction'] : nul l; 2717 externalTwoByteFunction = isCompiled ? map['_externalTwoByteFunction'] : nul l;
2713 oneByteBytecode = map['_oneByteBytecode']; 2718 oneByteBytecode = map['_oneByteBytecode'];
2714 twoByteBytecode = map['_twoByteBytecode']; 2719 twoByteBytecode = map['_twoByteBytecode'];
2715 2720
2716 nativeFields = map['_nativeFields'];
2717 if (map['fields'] != null) { 2721 if (map['fields'] != null) {
2718 fields = map['fields'] 2722 fields = map['fields']
2719 .map((f) => new BoundField(f['decl'], f['value'])).toList(); 2723 .map((f) => new BoundField(f['decl'], f['value'])).toList();
2724 } else {
2725 fields = null;
2726 }
2727 if (map['_nativeFields'] != null) {
2728 nativeFields = map['_nativeFields']
2729 .map((f) => new NativeField(f['value'])).toList();
2730 } else {
2731 nativeFields = null;
2720 } 2732 }
2721 if (map['elements'] != null) { 2733 if (map['elements'] != null) {
2722 // Should be: 2734 // Should be:
2723 // elements = map['elements'].map((e) => new Guarded<Instance>(e)).toList(); 2735 // elements = map['elements'].map((e) => new Guarded<Instance>(e)).toList();
2724 // some times we obtain object that are not InstanceRef 2736 // some times we obtain object that are not InstanceRef
2725 elements = map['elements'].map((e) => new Guarded<ServiceObject>(e)) 2737 elements = map['elements'].map((e) => new Guarded<ServiceObject>(e))
2726 .toList(); 2738 .toList();
2739 } else {
2740 elements = null;
2727 } 2741 }
2728 if (map['associations'] != null) { 2742 if (map['associations'] != null) {
2729 associations = map['associations'].map((a) => 2743 associations = map['associations'].map((a) =>
2730 new MapAssociation(a['key'], a['value'])).toList(); 2744 new MapAssociation(a['key'], a['value'])).toList();
2745 } else {
2746 associations = null;
2731 }; 2747 };
2732 if (map['bytes'] != null) { 2748 if (map['bytes'] != null) {
2733 Uint8List bytes = BASE64.decode(map['bytes']); 2749 Uint8List bytes = BASE64.decode(map['bytes']);
2734 switch (map['kind']) { 2750 switch (map['kind']) {
2735 case "Uint8ClampedList": 2751 case "Uint8ClampedList":
2736 typedElements = bytes.buffer.asUint8ClampedList(); break; 2752 typedElements = bytes.buffer.asUint8ClampedList(); break;
2737 case "Uint8List": 2753 case "Uint8List":
2738 typedElements = bytes.buffer.asUint8List(); break; 2754 typedElements = bytes.buffer.asUint8List(); break;
2739 case "Uint16List": 2755 case "Uint16List":
2740 typedElements = bytes.buffer.asUint16List(); break; 2756 typedElements = bytes.buffer.asUint16List(); break;
(...skipping 13 matching lines...) Expand all
2754 typedElements = bytes.buffer.asFloat32List(); break; 2770 typedElements = bytes.buffer.asFloat32List(); break;
2755 case "Float64List": 2771 case "Float64List":
2756 typedElements = bytes.buffer.asFloat64List(); break; 2772 typedElements = bytes.buffer.asFloat64List(); break;
2757 case "Int32x4List": 2773 case "Int32x4List":
2758 typedElements = bytes.buffer.asInt32x4List(); break; 2774 typedElements = bytes.buffer.asInt32x4List(); break;
2759 case "Float32x4List": 2775 case "Float32x4List":
2760 typedElements = bytes.buffer.asFloat32x4List(); break; 2776 typedElements = bytes.buffer.asFloat32x4List(); break;
2761 case "Float64x2List": 2777 case "Float64x2List":
2762 typedElements = bytes.buffer.asFloat64x2List(); break; 2778 typedElements = bytes.buffer.asFloat64x2List(); break;
2763 } 2779 }
2780 } else {
2781 typedElements = null;
2764 } 2782 }
2765 parameterizedClass = map['parameterizedClass']; 2783 parameterizedClass = map['parameterizedClass'];
2766 typeArguments = map['typeArguments']; 2784 typeArguments = map['typeArguments'];
2767 parameterIndex = map['parameterIndex']; 2785 parameterIndex = map['parameterIndex'];
2768 targetType = map['targetType']; 2786 targetType = map['targetType'];
2769 bound = map['bound']; 2787 bound = map['bound'];
2770 2788
2771 referent = map['mirrorReferent']; 2789 referent = map['mirrorReferent'];
2772 key = map['propertyKey']; 2790 key = map['propertyKey'];
2773 value = map['propertyValue']; 2791 value = map['propertyValue'];
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
3698 dartOwner = map['_owner']; 3716 dartOwner = map['_owner'];
3699 selector = map['_selector']; 3717 selector = map['_selector'];
3700 if (mapIsRef) { 3718 if (mapIsRef) {
3701 return; 3719 return;
3702 } 3720 }
3703 argumentsDescriptor = map['_argumentsDescriptor']; 3721 argumentsDescriptor = map['_argumentsDescriptor'];
3704 entries = map['_entries']; 3722 entries = map['_entries'];
3705 } 3723 }
3706 } 3724 }
3707 3725
3726 class TypeArguments extends HeapObject implements M.TypeArguments {
3727 HeapObject dartOwner;
3728 String name;
3729 Iterable<Instance> types;
3730
3731 TypeArguments._empty(ServiceObjectOwner owner) : super._empty(owner);
3732
3733 void _update(ObservableMap map, bool mapIsRef) {
3734 _upgradeCollection(map, isolate);
3735 super._update(map, mapIsRef);
3736
3737 dartOwner = map['_owner'];
3738 name = map['name'];
3739 if (mapIsRef) {
3740 return;
3741 }
3742 types = map['types'];
3743 }
3744 }
3745
3708 class MegamorphicCache extends HeapObject implements M.MegamorphicCache { 3746 class MegamorphicCache extends HeapObject implements M.MegamorphicCache {
3709 @observable int mask; 3747 @observable int mask;
3710 @observable Instance buckets; 3748 @observable Instance buckets;
3711 @observable String selector; 3749 @observable String selector;
3712 @observable Instance argumentsDescriptor; 3750 @observable Instance argumentsDescriptor;
3713 3751
3714 bool get immutable => false; 3752 bool get immutable => false;
3715 3753
3716 MegamorphicCache._empty(ServiceObjectOwner owner) : super._empty(owner); 3754 MegamorphicCache._empty(ServiceObjectOwner owner) : super._empty(owner);
3717 3755
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
4382 var v = list[i]; 4420 var v = list[i];
4383 if ((v is ObservableMap) && _isServiceMap(v)) { 4421 if ((v is ObservableMap) && _isServiceMap(v)) {
4384 list[i] = owner.getFromMap(v); 4422 list[i] = owner.getFromMap(v);
4385 } else if (v is ObservableList) { 4423 } else if (v is ObservableList) {
4386 _upgradeObservableList(v, owner); 4424 _upgradeObservableList(v, owner);
4387 } else if (v is ObservableMap) { 4425 } else if (v is ObservableMap) {
4388 _upgradeObservableMap(v, owner); 4426 _upgradeObservableMap(v, owner);
4389 } 4427 }
4390 } 4428 }
4391 } 4429 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/repositories/type_arguments.dart ('k') | runtime/observatory/lib/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698