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

Side by Side Diff: pkg/compiler/lib/src/enqueue.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
« no previous file with comments | « pkg/compiler/lib/src/deferred_load.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart2js.enqueue; 5 library dart2js.enqueue;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import 'common/resolution.dart' show Resolution; 9 import 'common/resolution.dart' show Resolution;
10 import 'common/tasks.dart' show CompilerTask; 10 import 'common/tasks.dart' show CompilerTask;
11 import 'common/work.dart' show WorkItem; 11 import 'common/work.dart' show WorkItem;
12 import 'common.dart'; 12 import 'common.dart';
13 import 'compiler.dart' show Compiler, GlobalDependencyRegistry; 13 import 'compiler.dart' show Compiler;
14 import 'options.dart'; 14 import 'options.dart';
15 import 'elements/elements.dart' 15 import 'elements/elements.dart'
16 show 16 show
17 AnalyzableElement, 17 AnalyzableElement,
18 ClassElement, 18 ClassElement,
19 ConstructorElement, 19 ConstructorElement,
20 Element, 20 Element,
21 MemberElement; 21 MemberElement;
22 import 'elements/entities.dart'; 22 import 'elements/entities.dart';
23 import 'elements/resolution_types.dart' 23 import 'elements/resolution_types.dart'
(...skipping 18 matching lines...) Expand all
42 EnqueueTask(Compiler compiler) 42 EnqueueTask(Compiler compiler)
43 : this.compiler = compiler, 43 : this.compiler = compiler,
44 super(compiler.measurer) { 44 super(compiler.measurer) {
45 _resolution = new ResolutionEnqueuer( 45 _resolution = new ResolutionEnqueuer(
46 this, 46 this,
47 compiler.options, 47 compiler.options,
48 compiler.reporter, 48 compiler.reporter,
49 compiler.options.analyzeOnly && compiler.options.analyzeMain 49 compiler.options.analyzeOnly && compiler.options.analyzeMain
50 ? const DirectEnqueuerStrategy() 50 ? const DirectEnqueuerStrategy()
51 : const TreeShakingEnqueuerStrategy(), 51 : const TreeShakingEnqueuerStrategy(),
52 compiler.globalDependencies,
53 compiler.backend, 52 compiler.backend,
54 compiler.backend.nativeResolutionEnqueuer(), 53 compiler.backend.nativeResolutionEnqueuer(),
55 new ResolutionWorldBuilderImpl( 54 new ResolutionWorldBuilderImpl(
56 compiler.backend, compiler.resolution, const OpenWorldStrategy()), 55 compiler.backend, compiler.resolution, const OpenWorldStrategy()),
57 new ResolutionWorkItemBuilder(compiler.resolution)); 56 new ResolutionWorkItemBuilder(compiler.resolution));
58 _codegen = compiler.backend.createCodegenEnqueuer(this, compiler); 57 _codegen = compiler.backend.createCodegenEnqueuer(this, compiler);
59 } 58 }
60 59
61 ResolutionEnqueuer get resolution => _resolution; 60 ResolutionEnqueuer get resolution => _resolution;
62 Enqueuer get codegen => _codegen; 61 Enqueuer get codegen => _codegen;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 bool checkNoEnqueuedInvokedInstanceMethods(); 98 bool checkNoEnqueuedInvokedInstanceMethods();
100 void logSummary(log(message)); 99 void logSummary(log(message));
101 100
102 Iterable<Entity> get processedEntities; 101 Iterable<Entity> get processedEntities;
103 102
104 Iterable<ClassEntity> get processedClasses; 103 Iterable<ClassEntity> get processedClasses;
105 } 104 }
106 105
107 abstract class EnqueuerListener { 106 abstract class EnqueuerListener {
108 /// Called to instruct to the backend that [type] has been instantiated. 107 /// Called to instruct to the backend that [type] has been instantiated.
109 void registerInstantiatedType(InterfaceType type); 108 void registerInstantiatedType(InterfaceType type, {bool isGlobal});
110 109
111 /// Called to notify to the backend that a class is being instantiated. Any 110 /// Called to notify to the backend that a class is being instantiated. Any
112 /// backend specific [WorldImpact] of this is returned. 111 /// backend specific [WorldImpact] of this is returned.
113 WorldImpact registerInstantiatedClass(ClassEntity cls, {bool forResolution}); 112 WorldImpact registerInstantiatedClass(ClassEntity cls, {bool forResolution});
114 113
115 /// Called to notify to the backend that a class is implemented by an 114 /// Called to notify to the backend that a class is implemented by an
116 /// instantiated class. Any backend specific [WorldImpact] of this is 115 /// instantiated class. Any backend specific [WorldImpact] of this is
117 /// returned. 116 /// returned.
118 WorldImpact registerImplementedClass(ClassEntity cls, {bool forResolution}); 117 WorldImpact registerImplementedClass(ClassEntity cls, {bool forResolution});
119 118
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 164
166 /// [Enqueuer] which is specific to resolution. 165 /// [Enqueuer] which is specific to resolution.
167 class ResolutionEnqueuer extends EnqueuerImpl { 166 class ResolutionEnqueuer extends EnqueuerImpl {
168 static const ImpactUseCase IMPACT_USE = 167 static const ImpactUseCase IMPACT_USE =
169 const ImpactUseCase('ResolutionEnqueuer'); 168 const ImpactUseCase('ResolutionEnqueuer');
170 169
171 final CompilerTask task; 170 final CompilerTask task;
172 final String name; 171 final String name;
173 final CompilerOptions _options; 172 final CompilerOptions _options;
174 final EnqueuerListener _listener; 173 final EnqueuerListener _listener;
175 final GlobalDependencyRegistry _globalDependencies;
176 final native.NativeEnqueuer nativeEnqueuer; 174 final native.NativeEnqueuer nativeEnqueuer;
177 175
178 final EnqueuerStrategy strategy; 176 final EnqueuerStrategy strategy;
179 final Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>(); 177 final Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>();
180 final ResolutionWorldBuilderImpl _universe; 178 final ResolutionWorldBuilderImpl _universe;
181 final WorkItemBuilder _workItemBuilder; 179 final WorkItemBuilder _workItemBuilder;
182 final DiagnosticReporter _reporter; 180 final DiagnosticReporter _reporter;
183 181
184 bool queueIsClosed = false; 182 bool queueIsClosed = false;
185 183
186 WorldImpactVisitor _impactVisitor; 184 WorldImpactVisitor _impactVisitor;
187 185
188 /// All declaration elements that have been processed by the resolver. 186 /// All declaration elements that have been processed by the resolver.
189 final Set<Entity> _processedEntities = new Set<Entity>(); 187 final Set<Entity> _processedEntities = new Set<Entity>();
190 188
191 final Queue<WorkItem> _queue = new Queue<WorkItem>(); 189 final Queue<WorkItem> _queue = new Queue<WorkItem>();
192 190
193 /// Queue of deferred resolution actions to execute when the resolution queue 191 /// Queue of deferred resolution actions to execute when the resolution queue
194 /// has been emptied. 192 /// has been emptied.
195 final Queue<_DeferredAction> _deferredQueue = new Queue<_DeferredAction>(); 193 final Queue<_DeferredAction> _deferredQueue = new Queue<_DeferredAction>();
196 194
197 ResolutionEnqueuer( 195 ResolutionEnqueuer(
198 this.task, 196 this.task,
199 this._options, 197 this._options,
200 this._reporter, 198 this._reporter,
201 this.strategy, 199 this.strategy,
202 this._globalDependencies,
203 this._listener, 200 this._listener,
204 this.nativeEnqueuer, 201 this.nativeEnqueuer,
205 this._universe, 202 this._universe,
206 this._workItemBuilder, 203 this._workItemBuilder,
207 [this.name = 'resolution enqueuer']) { 204 [this.name = 'resolution enqueuer']) {
208 _impactVisitor = new EnqueuerImplImpactVisitor(this); 205 _impactVisitor = new EnqueuerImplImpactVisitor(this);
209 } 206 }
210 207
211 ResolutionWorldBuilder get worldBuilder => _universe; 208 ResolutionWorldBuilder get worldBuilder => _universe;
212 209
(...skipping 11 matching lines...) Expand all
224 {ConstructorElement constructor, 221 {ConstructorElement constructor,
225 bool mirrorUsage: false, 222 bool mirrorUsage: false,
226 bool nativeUsage: false, 223 bool nativeUsage: false,
227 bool globalDependency: false, 224 bool globalDependency: false,
228 bool isRedirection: false}) { 225 bool isRedirection: false}) {
229 task.measure(() { 226 task.measure(() {
230 _universe.registerTypeInstantiation(type, _applyClassUse, 227 _universe.registerTypeInstantiation(type, _applyClassUse,
231 constructor: constructor, 228 constructor: constructor,
232 byMirrors: mirrorUsage, 229 byMirrors: mirrorUsage,
233 isRedirection: isRedirection); 230 isRedirection: isRedirection);
234 if (globalDependency && !mirrorUsage) {
235 _globalDependencies.registerDependency(type.element);
236 }
237 if (nativeUsage) { 231 if (nativeUsage) {
238 nativeEnqueuer.onInstantiatedType(type); 232 nativeEnqueuer.onInstantiatedType(type);
239 } 233 }
240 _listener.registerInstantiatedType(type); 234 _listener.registerInstantiatedType(type,
235 isGlobal: globalDependency && !mirrorUsage);
241 }); 236 });
242 } 237 }
243 238
244 bool checkNoEnqueuedInvokedInstanceMethods() { 239 bool checkNoEnqueuedInvokedInstanceMethods() {
245 return strategy.checkEnqueuerConsistency(this); 240 return strategy.checkEnqueuerConsistency(this);
246 } 241 }
247 242
248 void checkClass(ClassEntity cls) { 243 void checkClass(ClassEntity cls) {
249 _universe.processClassMembers(cls, 244 _universe.processClassMembers(cls,
250 (MemberEntity member, EnumSet<MemberUse> useSet) { 245 (MemberEntity member, EnumSet<MemberUse> useSet) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 @override 569 @override
575 WorkItem createWorkItem(MemberElement element) { 570 WorkItem createWorkItem(MemberElement element) {
576 assert(invariant(element, element.isDeclaration)); 571 assert(invariant(element, element.isDeclaration));
577 if (element.isMalformed) return null; 572 if (element.isMalformed) return null;
578 573
579 assert(invariant(element, element is AnalyzableElement, 574 assert(invariant(element, element is AnalyzableElement,
580 message: 'Element $element is not analyzable.')); 575 message: 'Element $element is not analyzable.'));
581 return _resolution.createWorkItem(element); 576 return _resolution.createWorkItem(element);
582 } 577 }
583 } 578 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/deferred_load.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698