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

Side by Side Diff: pkg/compiler/lib/src/inferrer/builder.dart

Issue 2961313002: Always store GlobalTypeInferenceElementData on the member context (Closed)
Patch Set: Created 3 years, 5 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library simple_types_inferrer; 5 library simple_types_inferrer;
6 6
7 import '../closure.dart' show ClosureRepresentationInfo; 7 import '../closure.dart' show ClosureRepresentationInfo;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show Identifiers, Selectors; 9 import '../common/names.dart' show Identifiers, Selectors;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 SemanticSendResolvedMixin<TypeInformation, dynamic>, 49 SemanticSendResolvedMixin<TypeInformation, dynamic>,
50 CompoundBulkMixin<TypeInformation, dynamic>, 50 CompoundBulkMixin<TypeInformation, dynamic>,
51 SetIfNullBulkMixin<TypeInformation, dynamic>, 51 SetIfNullBulkMixin<TypeInformation, dynamic>,
52 PrefixBulkMixin<TypeInformation, dynamic>, 52 PrefixBulkMixin<TypeInformation, dynamic>,
53 PostfixBulkMixin<TypeInformation, dynamic>, 53 PostfixBulkMixin<TypeInformation, dynamic>,
54 ErrorBulkMixin<TypeInformation, dynamic>, 54 ErrorBulkMixin<TypeInformation, dynamic>,
55 NewBulkMixin<TypeInformation, dynamic>, 55 NewBulkMixin<TypeInformation, dynamic>,
56 SetBulkMixin<TypeInformation, dynamic> 56 SetBulkMixin<TypeInformation, dynamic>
57 implements SemanticSendVisitor<TypeInformation, dynamic> { 57 implements SemanticSendVisitor<TypeInformation, dynamic> {
58 final Compiler compiler; 58 final Compiler compiler;
59 final AstElement analyzedElement; 59 final ExecutableElement analyzedElement;
60 final ResolvedAst resolvedAst; 60 final ResolvedAst resolvedAst;
61 final TypeSystem types; 61 final TypeSystem types;
62 final Map<JumpTarget, List<LocalsHandler>> breaksFor = 62 final Map<JumpTarget, List<LocalsHandler>> breaksFor =
63 new Map<JumpTarget, List<LocalsHandler>>(); 63 new Map<JumpTarget, List<LocalsHandler>>();
64 final Map<JumpTarget, List<LocalsHandler>> continuesFor = 64 final Map<JumpTarget, List<LocalsHandler>> continuesFor =
65 new Map<JumpTarget, List<LocalsHandler>>(); 65 new Map<JumpTarget, List<LocalsHandler>>();
66 LocalsHandler locals; 66 LocalsHandler locals;
67 final List<TypeInformation> cascadeReceiverStack = 67 final List<TypeInformation> cascadeReceiverStack =
68 new List<TypeInformation>(); 68 new List<TypeInformation>();
69 69
70 TypeInformation returnType; 70 TypeInformation returnType;
71 bool visitingInitializers = false; 71 bool visitingInitializers = false;
72 bool isConstructorRedirect = false; 72 bool isConstructorRedirect = false;
73 bool seenSuperConstructorCall = false; 73 bool seenSuperConstructorCall = false;
74 SideEffects sideEffects = new SideEffects.empty(); 74 SideEffects sideEffects = new SideEffects.empty();
75 final Element outermostElement; 75 final MemberElement outermostElement;
76 final InferrerEngine inferrer; 76 final InferrerEngine inferrer;
77 final Setlet<Entity> capturedVariables = new Setlet<Entity>(); 77 final Setlet<Entity> capturedVariables = new Setlet<Entity>();
78 final GlobalTypeInferenceElementData inTreeData; 78 final GlobalTypeInferenceElementData inTreeData;
Siggi Cherem (dart-lang) 2017/06/29 21:40:09 rename to memberData like you did for the map in t
Johnni Winther 2017/06/30 08:14:50 Renamed to [memberData]. The builder is created fo
79 79
80 ElementGraphBuilder.internal( 80 ElementGraphBuilder.internal(
81 AstElement analyzedElement, 81 ExecutableElement analyzedElement,
82 this.resolvedAst, 82 this.resolvedAst,
83 this.outermostElement, 83 this.outermostElement,
84 InferrerEngine inferrer, 84 InferrerEngine inferrer,
85 this.compiler, 85 this.compiler,
86 this.locals) 86 this.locals)
87 : this.analyzedElement = analyzedElement, 87 : this.analyzedElement = analyzedElement,
88 this.inferrer = inferrer, 88 this.inferrer = inferrer,
89 this.types = inferrer.types, 89 this.types = inferrer.types,
90 this.inTreeData = analyzedElement.isLocal 90 this.inTreeData = inferrer.dataOfMember(analyzedElement.memberContext) {
91 ? inferrer.dataOfLocalFunction(analyzedElement)
92 : inferrer.dataOfMember(analyzedElement) {
93 assert(outermostElement != null); 91 assert(outermostElement != null);
94 if (locals != null) return; 92 if (locals != null) return;
95 ast.Node node; 93 ast.Node node;
96 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 94 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
97 node = resolvedAst.node; 95 node = resolvedAst.node;
98 } 96 }
99 FieldInitializationScope fieldScope = 97 FieldInitializationScope fieldScope =
100 analyzedElement.isGenerativeConstructor 98 analyzedElement.isGenerativeConstructor
101 ? new FieldInitializationScope(types) 99 ? new FieldInitializationScope(types)
102 : null; 100 : null;
103 locals = 101 locals =
104 new LocalsHandler(inferrer, types, compiler.options, node, fieldScope); 102 new LocalsHandler(inferrer, types, compiler.options, node, fieldScope);
105 } 103 }
106 104
107 ElementGraphBuilder(AstElement element, ResolvedAst resolvedAst, 105 ElementGraphBuilder(ExecutableElement element, ResolvedAst resolvedAst,
108 Compiler compiler, InferrerEngine inferrer, [LocalsHandler handler]) 106 Compiler compiler, InferrerEngine inferrer, [LocalsHandler handler])
109 : this.internal( 107 : this.internal(element, resolvedAst, element.memberContext, inferrer,
110 element, 108 compiler, handler);
111 resolvedAst,
112 element.outermostEnclosingMemberOrTopLevel.implementation,
113 inferrer,
114 compiler,
115 handler);
116 109
117 TreeElements get elements => resolvedAst.elements; 110 TreeElements get elements => resolvedAst.elements;
118 111
119 bool accumulateIsChecks = false; 112 bool accumulateIsChecks = false;
120 bool conditionIsSimple = false; 113 bool conditionIsSimple = false;
121 List<ast.Send> isChecks; 114 List<ast.Send> isChecks;
122 int loopLevel = 0; 115 int loopLevel = 0;
123 116
124 bool get inLoop => loopLevel > 0; 117 bool get inLoop => loopLevel > 0;
125 bool get isThisExposed { 118 bool get isThisExposed {
(...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 element, arguments, sideEffects, inLoop); 2723 element, arguments, sideEffects, inLoop);
2731 } 2724 }
2732 2725
2733 TypeInformation handleDynamicSend(ast.Node node, Selector selector, 2726 TypeInformation handleDynamicSend(ast.Node node, Selector selector,
2734 TypeMask mask, TypeInformation receiverType, ArgumentsTypes arguments) { 2727 TypeMask mask, TypeInformation receiverType, ArgumentsTypes arguments) {
2735 assert(receiverType != null); 2728 assert(receiverType != null);
2736 if (types.selectorNeedsUpdate(receiverType, mask)) { 2729 if (types.selectorNeedsUpdate(receiverType, mask)) {
2737 mask = receiverType == types.dynamicType 2730 mask = receiverType == types.dynamicType
2738 ? null 2731 ? null
2739 : types.newTypedSelector(receiverType, mask); 2732 : types.newTypedSelector(receiverType, mask);
2740 if (analyzedElement.isLocal) { 2733 inferrer.updateSelectorInMember(outermostElement, node, selector, mask);
2741 inferrer.updateSelectorInLocalFunction(
2742 analyzedElement, node, selector, mask);
2743 } else {
2744 inferrer.updateSelectorInMember(analyzedElement, node, selector, mask);
2745 }
2746 } 2734 }
2747 2735
2748 // If the receiver of the call is a local, we may know more about 2736 // If the receiver of the call is a local, we may know more about
2749 // its type by refining it with the potential targets of the 2737 // its type by refining it with the potential targets of the
2750 // calls. 2738 // calls.
2751 ast.Send send = node.asSend(); 2739 ast.Send send = node.asSend();
2752 if (send != null) { 2740 if (send != null) {
2753 ast.Node receiver = send.receiver; 2741 ast.Node receiver = send.receiver;
2754 if (receiver != null) { 2742 if (receiver != null) {
2755 Element element = elements[receiver]; 2743 Element element = elements[receiver];
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 Selector moveNextSelector = Selectors.moveNext; 2933 Selector moveNextSelector = Selectors.moveNext;
2946 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); 2934 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node);
2947 2935
2948 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, 2936 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector,
2949 iteratorMask, expressionType, new ArgumentsTypes.empty()); 2937 iteratorMask, expressionType, new ArgumentsTypes.empty());
2950 2938
2951 return handleForInLoop(node, iteratorType, currentSelector, currentMask, 2939 return handleForInLoop(node, iteratorType, currentSelector, currentMask,
2952 moveNextSelector, moveNextMask); 2940 moveNextSelector, moveNextMask);
2953 } 2941 }
2954 } 2942 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698