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