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

Side by Side Diff: pkg/compiler/lib/src/enqueue.dart

Issue 2302363003: No longer store the compilation-context in WorkItem. (Closed)
Patch Set: ... lint Created 4 years, 3 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/compiler.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/names.dart' show Identifiers; 9 import 'common/names.dart' show Identifiers;
10 import 'common/resolution.dart' show Resolution; 10 import 'common/resolution.dart' show Resolution;
11 import 'common/resolution.dart' show ResolutionWorkItem; 11 import 'common/resolution.dart' show ResolutionWorkItem;
12 import 'common/tasks.dart' show CompilerTask; 12 import 'common/tasks.dart' show CompilerTask;
13 import 'common/work.dart' show ItemCompilationContext, WorkItem; 13 import 'common/work.dart' show WorkItem;
14 import 'common.dart'; 14 import 'common.dart';
15 import 'compiler.dart' show Compiler; 15 import 'compiler.dart' show Compiler;
16 import 'dart_types.dart' show DartType, InterfaceType; 16 import 'dart_types.dart' show DartType, InterfaceType;
17 import 'elements/elements.dart' 17 import 'elements/elements.dart'
18 show 18 show
19 AnalyzableElement, 19 AnalyzableElement,
20 AstElement, 20 AstElement,
21 ClassElement, 21 ClassElement,
22 ConstructorElement, 22 ConstructorElement,
23 Element, 23 Element,
24 Elements, 24 Elements,
25 Entity, 25 Entity,
26 FunctionElement, 26 FunctionElement,
27 LibraryElement, 27 LibraryElement,
28 Member, 28 Member,
29 Name, 29 Name,
30 TypedElement, 30 TypedElement,
31 TypedefElement; 31 TypedefElement;
32 import 'native/native.dart' as native; 32 import 'native/native.dart' as native;
33 import 'types/types.dart' show TypeMaskStrategy; 33 import 'types/types.dart' show TypeMaskStrategy;
34 import 'universe/selector.dart' show Selector; 34 import 'universe/selector.dart' show Selector;
35 import 'universe/universe.dart'; 35 import 'universe/universe.dart';
36 import 'universe/use.dart' 36 import 'universe/use.dart'
37 show DynamicUse, StaticUse, StaticUseKind, TypeUse, TypeUseKind; 37 show DynamicUse, StaticUse, StaticUseKind, TypeUse, TypeUseKind;
38 import 'universe/world_impact.dart' 38 import 'universe/world_impact.dart'
39 show ImpactUseCase, WorldImpact, WorldImpactVisitor; 39 show ImpactUseCase, WorldImpact, WorldImpactVisitor;
40 import 'util/util.dart' show Setlet; 40 import 'util/util.dart' show Setlet;
41 41
42 typedef ItemCompilationContext ItemCompilationContextCreator();
43
44 class EnqueueTask extends CompilerTask { 42 class EnqueueTask extends CompilerTask {
45 final ResolutionEnqueuer resolution; 43 final ResolutionEnqueuer resolution;
46 final Enqueuer codegen; 44 final Enqueuer codegen;
47 final Compiler compiler; 45 final Compiler compiler;
48 46
49 String get name => 'Enqueue'; 47 String get name => 'Enqueue';
50 48
51 EnqueueTask(Compiler compiler) 49 EnqueueTask(Compiler compiler)
52 : compiler = compiler, 50 : compiler = compiler,
53 resolution = new ResolutionEnqueuer( 51 resolution = new ResolutionEnqueuer(
54 compiler, 52 compiler,
55 compiler.backend.createItemCompilationContext,
56 compiler.options.analyzeOnly && compiler.options.analyzeMain 53 compiler.options.analyzeOnly && compiler.options.analyzeMain
57 ? const EnqueuerStrategy() 54 ? const EnqueuerStrategy()
58 : const TreeShakingEnqueuerStrategy()), 55 : const TreeShakingEnqueuerStrategy()),
59 codegen = compiler.backend.createCodegenEnqueuer(compiler), 56 codegen = compiler.backend.createCodegenEnqueuer(compiler),
60 super(compiler.measurer) { 57 super(compiler.measurer) {
61 codegen.task = this; 58 codegen.task = this;
62 resolution.task = this; 59 resolution.task = this;
63 60
64 codegen.nativeEnqueuer = compiler.backend.nativeCodegenEnqueuer(codegen); 61 codegen.nativeEnqueuer = compiler.backend.nativeCodegenEnqueuer(codegen);
65 resolution.nativeEnqueuer = 62 resolution.nativeEnqueuer =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 bool isProcessed(Element member); 118 bool isProcessed(Element member);
122 119
123 Iterable<Entity> get processedEntities; 120 Iterable<Entity> get processedEntities;
124 } 121 }
125 122
126 /// [Enqueuer] which is specific to resolution. 123 /// [Enqueuer] which is specific to resolution.
127 class ResolutionEnqueuer extends Enqueuer { 124 class ResolutionEnqueuer extends Enqueuer {
128 final String name; 125 final String name;
129 final Compiler compiler; // TODO(ahe): Remove this dependency. 126 final Compiler compiler; // TODO(ahe): Remove this dependency.
130 final EnqueuerStrategy strategy; 127 final EnqueuerStrategy strategy;
131 final ItemCompilationContextCreator itemCompilationContextCreator;
132 final Map<String, Set<Element>> instanceMembersByName = 128 final Map<String, Set<Element>> instanceMembersByName =
133 new Map<String, Set<Element>>(); 129 new Map<String, Set<Element>>();
134 final Map<String, Set<Element>> instanceFunctionsByName = 130 final Map<String, Set<Element>> instanceFunctionsByName =
135 new Map<String, Set<Element>>(); 131 new Map<String, Set<Element>>();
136 final Set<ClassElement> _processedClasses = new Set<ClassElement>(); 132 final Set<ClassElement> _processedClasses = new Set<ClassElement>();
137 Set<ClassElement> recentClasses = new Setlet<ClassElement>(); 133 Set<ClassElement> recentClasses = new Setlet<ClassElement>();
138 final Universe universe = new Universe(const TypeMaskStrategy()); 134 final Universe universe = new Universe(const TypeMaskStrategy());
139 135
140 static final TRACE_MIRROR_ENQUEUING = 136 static final TRACE_MIRROR_ENQUEUING =
141 const bool.fromEnvironment("TRACE_MIRROR_ENQUEUING"); 137 const bool.fromEnvironment("TRACE_MIRROR_ENQUEUING");
142 138
143 bool queueIsClosed = false; 139 bool queueIsClosed = false;
144 140
145 bool hasEnqueuedReflectiveElements = false; 141 bool hasEnqueuedReflectiveElements = false;
146 bool hasEnqueuedReflectiveStaticFields = false; 142 bool hasEnqueuedReflectiveStaticFields = false;
147 143
148 WorldImpactVisitor impactVisitor; 144 WorldImpactVisitor impactVisitor;
149 145
150 ResolutionEnqueuer( 146 ResolutionEnqueuer(Compiler compiler, this.strategy)
151 Compiler compiler, this.itemCompilationContextCreator, this.strategy)
152 : this.name = 'resolution enqueuer', 147 : this.name = 'resolution enqueuer',
153 this.compiler = compiler, 148 this.compiler = compiler,
154 processedElements = new Set<AstElement>(), 149 processedElements = new Set<AstElement>(),
155 queue = new Queue<ResolutionWorkItem>(), 150 queue = new Queue<ResolutionWorkItem>(),
156 deferredQueue = new Queue<_DeferredAction>() { 151 deferredQueue = new Queue<_DeferredAction>() {
157 impactVisitor = new _EnqueuerImpactVisitor(this); 152 impactVisitor = new _EnqueuerImpactVisitor(this);
158 } 153 }
159 154
160 // TODO(johnniwinther): Move this to [ResolutionEnqueuer]. 155 // TODO(johnniwinther): Move this to [ResolutionEnqueuer].
161 Resolution get resolution => compiler.resolution; 156 Resolution get resolution => compiler.resolution;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 assert(invariant(element, element is AnalyzableElement, 728 assert(invariant(element, element is AnalyzableElement,
734 message: 'Element $element is not analyzable.')); 729 message: 'Element $element is not analyzable.'));
735 if (hasBeenProcessed(element)) return false; 730 if (hasBeenProcessed(element)) return false;
736 if (queueIsClosed) { 731 if (queueIsClosed) {
737 throw new SpannableAssertionFailure( 732 throw new SpannableAssertionFailure(
738 element, "Resolution work list is closed. Trying to add $element."); 733 element, "Resolution work list is closed. Trying to add $element.");
739 } 734 }
740 735
741 compiler.world.registerUsedElement(element); 736 compiler.world.registerUsedElement(element);
742 737
743 ResolutionWorkItem workItem = compiler.resolution 738 ResolutionWorkItem workItem = compiler.resolution.createWorkItem(element);
744 .createWorkItem(element, itemCompilationContextCreator());
745 queue.add(workItem); 739 queue.add(workItem);
746 740
747 // Enable isolate support if we start using something from the isolate 741 // Enable isolate support if we start using something from the isolate
748 // library, or timers for the async library. We exclude constant fields, 742 // library, or timers for the async library. We exclude constant fields,
749 // which are ending here because their initializing expression is compiled. 743 // which are ending here because their initializing expression is compiled.
750 LibraryElement library = element.library; 744 LibraryElement library = element.library;
751 if (!compiler.hasIsolateSupport && (!element.isField || !element.isConst)) { 745 if (!compiler.hasIsolateSupport && (!element.isField || !element.isConst)) {
752 String uri = library.canonicalUri.toString(); 746 String uri = library.canonicalUri.toString();
753 if (uri == 'dart:isolate') { 747 if (uri == 'dart:isolate') {
754 enableIsolateSupport(); 748 enableIsolateSupport();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 } 912 }
919 913
920 typedef void _DeferredActionFunction(); 914 typedef void _DeferredActionFunction();
921 915
922 class _DeferredAction { 916 class _DeferredAction {
923 final Element element; 917 final Element element;
924 final _DeferredActionFunction action; 918 final _DeferredActionFunction action;
925 919
926 _DeferredAction(this.element, this.action); 920 _DeferredAction(this.element, this.action);
927 } 921 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.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