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

Side by Side Diff: pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart

Issue 2814453005: Merge CommonElements and BackendHelpers! (Closed)
Patch Set: comments and re-merge, take two Created 3 years, 8 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 import '../common/backend_api.dart'; 5 import '../common/backend_api.dart';
6 import '../common/resolution.dart'; 6 import '../common/resolution.dart';
7 import '../common_elements.dart'; 7 import '../common_elements.dart';
8 import '../constants/constant_system.dart'; 8 import '../constants/constant_system.dart';
9 import '../constants/values.dart'; 9 import '../constants/values.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
11 import '../elements/entities.dart'; 11 import '../elements/entities.dart';
12 import '../elements/resolution_types.dart'; 12 import '../elements/resolution_types.dart';
13 import '../universe/call_structure.dart'; 13 import '../universe/call_structure.dart';
14 import '../universe/use.dart' show ConstantUse, StaticUse; 14 import '../universe/use.dart' show ConstantUse, StaticUse;
15 import '../universe/world_impact.dart' 15 import '../universe/world_impact.dart'
16 show WorldImpact, StagedWorldImpactBuilder; 16 show WorldImpact, StagedWorldImpactBuilder;
17 import 'backend_usage.dart' show BackendUsageBuilder; 17 import 'backend_usage.dart' show BackendUsageBuilder;
18 import 'backend_helpers.dart';
19 import 'native_data.dart'; 18 import 'native_data.dart';
20 19
21 /** 20 /**
22 * Support for Custom Elements. 21 * Support for Custom Elements.
23 * 22 *
24 * The support for custom elements the compiler builds a table that maps the 23 * The support for custom elements the compiler builds a table that maps the
25 * custom element class's [Type] to the interceptor for the class and the 24 * custom element class's [Type] to the interceptor for the class and the
26 * constructor(s) for the class. 25 * constructor(s) for the class.
27 * 26 *
28 * We want the table to contain only the custom element classes used, and we 27 * We want the table to contain only the custom element classes used, and we
(...skipping 21 matching lines...) Expand all
50 * final tag; 49 * final tag;
51 * Component(this.tag); 50 * Component(this.tag);
52 * void register() => document.register(T, tag); 51 * void register() => document.register(T, tag);
53 * } 52 * }
54 * const Component<FancyButton>('x-fancy-button').register(); 53 * const Component<FancyButton>('x-fancy-button').register();
55 * 54 *
56 * In these cases we conservatively generate all viable entries in the table. 55 * In these cases we conservatively generate all viable entries in the table.
57 */ 56 */
58 abstract class CustomElementsAnalysisBase { 57 abstract class CustomElementsAnalysisBase {
59 final NativeBasicData _nativeData; 58 final NativeBasicData _nativeData;
60 final BackendHelpers _helpers;
61 final Resolution _resolution; 59 final Resolution _resolution;
60 final CommonElements _commonElements;
62 61
63 CustomElementsAnalysisBase(this._resolution, this._helpers, this._nativeData); 62 CustomElementsAnalysisBase(
63 this._resolution, this._commonElements, this._nativeData);
64 64
65 CustomElementsAnalysisJoin get join; 65 CustomElementsAnalysisJoin get join;
66 66
67 void registerInstantiatedClass(ClassElement classElement) { 67 void registerInstantiatedClass(ClassElement classElement) {
68 classElement.ensureResolved(_resolution); 68 classElement.ensureResolved(_resolution);
69 if (!_nativeData.isNativeOrExtendsNative(classElement)) return; 69 if (!_nativeData.isNativeOrExtendsNative(classElement)) return;
70 if (classElement.isMixinApplication) return; 70 if (classElement.isMixinApplication) return;
71 if (classElement.isAbstract) return; 71 if (classElement.isAbstract) return;
72 // JsInterop classes are opaque interfaces without a concrete 72 // JsInterop classes are opaque interfaces without a concrete
73 // implementation. 73 // implementation.
74 if (_nativeData.isJsInteropClass(classElement)) return; 74 if (_nativeData.isJsInteropClass(classElement)) return;
75 join.instantiatedClasses.add(classElement); 75 join.instantiatedClasses.add(classElement);
76 } 76 }
77 77
78 void registerStaticUse(MemberEntity element) { 78 void registerStaticUse(MemberEntity element) {
79 assert(element != null); 79 assert(element != null);
80 if (element == _helpers.findIndexForNativeSubclassType) { 80 if (element == _commonElements.findIndexForNativeSubclassType) {
81 join.demanded = true; 81 join.demanded = true;
82 } 82 }
83 } 83 }
84 84
85 /// Computes the [WorldImpact] of the classes registered since last flush. 85 /// Computes the [WorldImpact] of the classes registered since last flush.
86 WorldImpact flush() => join.flush(); 86 WorldImpact flush() => join.flush();
87 } 87 }
88 88
89 class CustomElementsResolutionAnalysis extends CustomElementsAnalysisBase { 89 class CustomElementsResolutionAnalysis extends CustomElementsAnalysisBase {
90 final CustomElementsAnalysisJoin join; 90 final CustomElementsAnalysisJoin join;
91 91
92 CustomElementsResolutionAnalysis( 92 CustomElementsResolutionAnalysis(
93 Resolution resolution, 93 Resolution resolution,
94 ConstantSystem constantSystem, 94 ConstantSystem constantSystem,
95 CommonElements commonElements, 95 CommonElements commonElements,
96 BackendClasses backendClasses, 96 BackendClasses backendClasses,
97 BackendHelpers helpers,
98 NativeBasicData nativeData, 97 NativeBasicData nativeData,
99 BackendUsageBuilder backendUsageBuilder) 98 BackendUsageBuilder backendUsageBuilder)
100 : join = new CustomElementsAnalysisJoin(resolution, constantSystem, 99 : join = new CustomElementsAnalysisJoin(resolution, constantSystem,
101 commonElements, backendClasses, nativeData, 100 commonElements, backendClasses, nativeData,
102 backendUsageBuilder: backendUsageBuilder), 101 backendUsageBuilder: backendUsageBuilder),
103 super(resolution, helpers, nativeData) { 102 super(resolution, commonElements, nativeData) {
104 // TODO(sra): Remove this work-around. We should mark allClassesSelected in 103 // TODO(sra): Remove this work-around. We should mark allClassesSelected in
105 // both joins only when we see a construct generating an unknown [Type] but 104 // both joins only when we see a construct generating an unknown [Type] but
106 // we can't currently recognize all cases. In particular, the work-around 105 // we can't currently recognize all cases. In particular, the work-around
107 // for the unimplemented `ClassMirror.reflectedType` is not recognizable. 106 // for the unimplemented `ClassMirror.reflectedType` is not recognizable.
108 // TODO(12607): Match on [ClassMirror.reflectedType] 107 // TODO(12607): Match on [ClassMirror.reflectedType]
109 join.allClassesSelected = true; 108 join.allClassesSelected = true;
110 } 109 }
111 110
112 void registerTypeLiteral(ResolutionDartType type) { 111 void registerTypeLiteral(ResolutionDartType type) {
113 if (type.isInterfaceType) { 112 if (type.isInterfaceType) {
(...skipping 11 matching lines...) Expand all
125 } 124 }
126 125
127 class CustomElementsCodegenAnalysis extends CustomElementsAnalysisBase { 126 class CustomElementsCodegenAnalysis extends CustomElementsAnalysisBase {
128 final CustomElementsAnalysisJoin join; 127 final CustomElementsAnalysisJoin join;
129 128
130 CustomElementsCodegenAnalysis( 129 CustomElementsCodegenAnalysis(
131 Resolution resolution, 130 Resolution resolution,
132 ConstantSystem constantSystem, 131 ConstantSystem constantSystem,
133 CommonElements commonElements, 132 CommonElements commonElements,
134 BackendClasses backendClasses, 133 BackendClasses backendClasses,
135 BackendHelpers helpers,
136 NativeBasicData nativeData) 134 NativeBasicData nativeData)
137 : join = new CustomElementsAnalysisJoin(resolution, constantSystem, 135 : join = new CustomElementsAnalysisJoin(resolution, constantSystem,
138 commonElements, backendClasses, nativeData), 136 commonElements, backendClasses, nativeData),
139 super(resolution, helpers, nativeData) { 137 super(resolution, commonElements, nativeData) {
140 // TODO(sra): Remove this work-around. We should mark allClassesSelected in 138 // TODO(sra): Remove this work-around. We should mark allClassesSelected in
141 // both joins only when we see a construct generating an unknown [Type] but 139 // both joins only when we see a construct generating an unknown [Type] but
142 // we can't currently recognize all cases. In particular, the work-around 140 // we can't currently recognize all cases. In particular, the work-around
143 // for the unimplemented `ClassMirror.reflectedType` is not recognizable. 141 // for the unimplemented `ClassMirror.reflectedType` is not recognizable.
144 // TODO(12607): Match on [ClassMirror.reflectedType] 142 // TODO(12607): Match on [ClassMirror.reflectedType]
145 join.allClassesSelected = true; 143 join.allClassesSelected = true;
146 } 144 }
147 145
148 void registerTypeConstant(ClassElement element) { 146 void registerTypeConstant(ClassElement element) {
149 assert(element.isClass); 147 assert(element.isClass);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 result.add(member); 250 result.add(member);
253 } 251 }
254 } 252 }
255 } 253 }
256 254
257 classElement.forEachMember(selectGenerativeConstructors, 255 classElement.forEachMember(selectGenerativeConstructors,
258 includeBackendMembers: false, includeSuperAndInjectedMembers: false); 256 includeBackendMembers: false, includeSuperAndInjectedMembers: false);
259 return result; 257 return result;
260 } 258 }
261 } 259 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/constant_emitter.dart ('k') | pkg/compiler/lib/src/js_backend/frequency_namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698