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

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

Issue 2696483005: Move global dependencies to BackendUsage (Closed)
Patch Set: Created 3 years, 10 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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.dart'; 5 import '../common.dart';
6 import '../common/resolution.dart' show Resolution; 6 import '../common/resolution.dart' show Resolution;
7 import '../compiler.dart' show GlobalDependencyRegistry;
8 import '../core_types.dart'; 7 import '../core_types.dart';
9 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
10 import '../elements/resolution_types.dart'; 9 import '../elements/resolution_types.dart';
11 import '../universe/selector.dart'; 10 import '../universe/selector.dart';
12 import '../universe/use.dart'; 11 import '../universe/use.dart';
13 import '../universe/world_impact.dart' 12 import '../universe/world_impact.dart'
14 show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl; 13 show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl;
14 import '../util/util.dart' show Setlet;
15 import 'backend_helpers.dart'; 15 import 'backend_helpers.dart';
16 import 'backend_impact.dart'; 16 import 'backend_impact.dart';
17 17
18 class BackendUsage { 18 class BackendUsage {
19 final CommonElements commonElements; 19 final CommonElements commonElements;
20 final BackendHelpers helpers; 20 final BackendHelpers helpers;
21 final Resolution resolution; 21 final Resolution resolution;
22 final GlobalDependencyRegistry globalDependencies; 22 // TODO(johnniwinther): Remove the need for this.
23 Setlet<Element> _globalDependencies;
23 24
24 /// List of elements that the backend may use. 25 /// List of elements that the backend may use.
25 final Set<Element> helpersUsed = new Set<Element>(); 26 final Set<Element> helpersUsed = new Set<Element>();
26 27
27 bool needToInitializeIsolateAffinityTag = false; 28 bool needToInitializeIsolateAffinityTag = false;
28 bool needToInitializeDispatchProperty = false; 29 bool needToInitializeDispatchProperty = false;
29 30
30 BackendUsage(this.commonElements, this.helpers, this.resolution, 31 BackendUsage(this.commonElements, this.helpers, this.resolution);
31 this.globalDependencies);
32 32
33 /// The backend must *always* call this method when enqueuing an 33 /// The backend must *always* call this method when enqueuing an
34 /// element. Calls done by the backend are not seen by global 34 /// element. Calls done by the backend are not seen by global
35 /// optimizations, so they would make these optimizations unsound. 35 /// optimizations, so they would make these optimizations unsound.
36 /// Therefore we need to collect the list of helpers the backend may 36 /// Therefore we need to collect the list of helpers the backend may
37 /// use. 37 /// use.
38 // TODO(johnniwinther): Replace this with a more precise modelling; type 38 // TODO(johnniwinther): Replace this with a more precise modelling; type
39 // inference of these elements is disabled. 39 // inference of these elements is disabled.
40 Element registerBackendUse(Element element) { 40 Element registerBackendUse(Element element) {
41 if (element == null) return null; 41 if (element == null) return null;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 void registerBackendStaticUse( 106 void registerBackendStaticUse(
107 WorldImpactBuilder worldImpact, MethodElement element, 107 WorldImpactBuilder worldImpact, MethodElement element,
108 {bool isGlobal: false}) { 108 {bool isGlobal: false}) {
109 registerBackendUse(element); 109 registerBackendUse(element);
110 worldImpact.registerStaticUse( 110 worldImpact.registerStaticUse(
111 // TODO(johnniwinther): Store the correct use in impacts. 111 // TODO(johnniwinther): Store the correct use in impacts.
112 new StaticUse.foreignUse(element)); 112 new StaticUse.foreignUse(element));
113 if (isGlobal) { 113 if (isGlobal) {
114 globalDependencies.registerDependency(element); 114 registerGlobalDependency(element);
115 } 115 }
116 } 116 }
117 117
118 void registerBackendInstantiation( 118 void registerBackendInstantiation(
119 WorldImpactBuilder worldImpact, ClassElement cls, 119 WorldImpactBuilder worldImpact, ClassElement cls,
120 {bool isGlobal: false}) { 120 {bool isGlobal: false}) {
121 cls.ensureResolved(resolution); 121 cls.ensureResolved(resolution);
122 registerBackendUse(cls); 122 registerBackendUse(cls);
123 worldImpact.registerTypeUse(new TypeUse.instantiation(cls.rawType)); 123 worldImpact.registerTypeUse(new TypeUse.instantiation(cls.rawType));
124 if (isGlobal) { 124 if (isGlobal) {
125 globalDependencies.registerDependency(cls); 125 registerGlobalDependency(cls);
126 } 126 }
127 } 127 }
128 128
129 void registerBackendImpact( 129 void registerBackendImpact(
130 WorldImpactBuilder worldImpact, BackendImpact backendImpact) { 130 WorldImpactBuilder worldImpact, BackendImpact backendImpact) {
131 for (Element staticUse in backendImpact.staticUses) { 131 for (Element staticUse in backendImpact.staticUses) {
132 assert(staticUse != null); 132 assert(staticUse != null);
133 registerBackendStaticUse(worldImpact, staticUse); 133 registerBackendStaticUse(worldImpact, staticUse);
134 } 134 }
135 for (Element staticUse in backendImpact.globalUses) { 135 for (Element staticUse in backendImpact.globalUses) {
(...skipping 22 matching lines...) Expand all
158 switch (feature) { 158 switch (feature) {
159 case BackendFeature.needToInitializeDispatchProperty: 159 case BackendFeature.needToInitializeDispatchProperty:
160 needToInitializeDispatchProperty = true; 160 needToInitializeDispatchProperty = true;
161 break; 161 break;
162 case BackendFeature.needToInitializeIsolateAffinityTag: 162 case BackendFeature.needToInitializeIsolateAffinityTag:
163 needToInitializeIsolateAffinityTag = true; 163 needToInitializeIsolateAffinityTag = true;
164 break; 164 break;
165 } 165 }
166 } 166 }
167 } 167 }
168
169 void registerGlobalDependency(Element element) {
170 if (element == null) return;
171 if (_globalDependencies == null) {
172 _globalDependencies = new Setlet<Element>();
173 }
174 _globalDependencies.add(element.implementation);
175 }
176
177 Iterable<Element> get globalDependencies => _globalDependencies;
168 } 178 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698