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

Side by Side Diff: pkg/fletchc/lib/src/fletch_enqueuer.dart

Issue 1328793002: Don't rely on resolution for enqueuing (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.fletch_enqueuer; 5 library fletchc.fletch_enqueuer;
6 6
7 import 'dart:collection' show 7 import 'dart:collection' show
8 Queue; 8 Queue;
9 9
10 import 'package:compiler/src/dart2jslib.dart' show 10 import 'package:compiler/src/dart2jslib.dart' show
11 CodegenEnqueuer, 11 CodegenEnqueuer,
12 Compiler, 12 Compiler,
13 CompilerTask, 13 CompilerTask,
14 EnqueueTask, 14 EnqueueTask,
15 ItemCompilationContextCreator, 15 ItemCompilationContextCreator,
16 QueueFilter, 16 QueueFilter,
17 Registry, 17 Registry,
18 ResolutionEnqueuer, 18 ResolutionEnqueuer,
19 WorkItem, 19 WorkItem,
20 WorldImpact; 20 WorldImpact;
21 21
22 import 'package:compiler/src/universe/universe.dart' show 22 import 'package:compiler/src/universe/universe.dart' show
23 CallStructure, 23 CallStructure,
24 Selector,
24 Universe, 25 Universe,
25 UniverseSelector; 26 UniverseSelector;
26 27
27 import 'package:compiler/src/dart_types.dart' show 28 import 'package:compiler/src/dart_types.dart' show
28 DartType, 29 DartType,
29 InterfaceType; 30 InterfaceType;
30 31
31 import 'package:compiler/src/elements/elements.dart' show 32 import 'package:compiler/src/elements/elements.dart' show
32 ClassElement, 33 ClassElement,
33 ConstructorElement, 34 ConstructorElement,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // TODO(ahe): Should be typed [FletchEnqueuer]. 73 // TODO(ahe): Should be typed [FletchEnqueuer].
73 final CodegenEnqueuer codegen; 74 final CodegenEnqueuer codegen;
74 75
75 FletchEnqueueTask(FletchCompilerImplementation compiler) 76 FletchEnqueueTask(FletchCompilerImplementation compiler)
76 : resolution = new ResolutionEnqueuer( 77 : resolution = new ResolutionEnqueuer(
77 compiler, compiler.backend.createItemCompilationContext), 78 compiler, compiler.backend.createItemCompilationContext),
78 codegen = makeCodegenEnqueuer(compiler), 79 codegen = makeCodegenEnqueuer(compiler),
79 super(compiler) { 80 super(compiler) {
80 codegen.task = this; 81 codegen.task = this;
81 resolution.task = this; 82 resolution.task = this;
82 if (codegen is! TransitionalFletchEnqueuer) {
83 FletchEnqueuer fletchEnqueuer = codegen;
84 fletchEnqueuer.dynamicCallEnqueuer.task = this;
85 }
86 codegen.nativeEnqueuer = compiler.backend.nativeCodegenEnqueuer(codegen); 83 codegen.nativeEnqueuer = compiler.backend.nativeCodegenEnqueuer(codegen);
87 84
88 resolution.nativeEnqueuer = 85 resolution.nativeEnqueuer =
89 compiler.backend.nativeResolutionEnqueuer(resolution); 86 compiler.backend.nativeResolutionEnqueuer(resolution);
90 } 87 }
91 88
92 String get name => 'Fletch enqueue'; 89 String get name => 'Fletch enqueue';
93 90
94 void forgetElement(Element element) { 91 void forgetElement(Element element) {
95 resolution.forgetElement(element); 92 resolution.forgetElement(element);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 queue.add(workItem); 147 queue.add(workItem);
151 return true; 148 return true;
152 } 149 }
153 150
154 DynamicCallEnqueuer get dynamicCallEnqueuer => notImplemented; 151 DynamicCallEnqueuer get dynamicCallEnqueuer => notImplemented;
155 152
156 Set<Element> get _enqueuedElements => notImplemented; 153 Set<Element> get _enqueuedElements => notImplemented;
157 154
158 Queue<Element> get _pendingEnqueuedElements => notImplemented; 155 Queue<Element> get _pendingEnqueuedElements => notImplemented;
159 156
160 void _enqueueElement(Element element) => notImplemented; 157 void _enqueueElement(element, selector) => notImplemented;
161 } 158 }
162 159
163 class FletchEnqueuer extends EnqueuerMixin implements CodegenEnqueuer { 160 class FletchEnqueuer extends EnqueuerMixin implements CodegenEnqueuer {
164 final ItemCompilationContextCreator itemCompilationContextCreator; 161 final ItemCompilationContextCreator itemCompilationContextCreator;
165 162
166 final FletchCompilerImplementation compiler; 163 final FletchCompilerImplementation compiler;
167 164
168 final Map generatedCode = new Map(); 165 final Map generatedCode = new Map();
169 166
170 bool queueIsClosed = false; 167 bool queueIsClosed = false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 dynamicCallEnqueuer.forgetElement(element); 211 dynamicCallEnqueuer.forgetElement(element);
215 } 212 }
216 213
217 void registerInstantiatedType( 214 void registerInstantiatedType(
218 InterfaceType type, 215 InterfaceType type,
219 Registry registry, 216 Registry registry,
220 {bool mirrorUsage: false}) { 217 {bool mirrorUsage: false}) {
221 dynamicCallEnqueuer.registerInstantiatedType(type); 218 dynamicCallEnqueuer.registerInstantiatedType(type);
222 } 219 }
223 220
221 // TODO(ahe): Remove this method.
224 void registerStaticUse(Element element) { 222 void registerStaticUse(Element element) {
225 _enqueueElement(element); 223 _enqueueElement(
224 element,
225 new UniverseSelector(new Selector.fromElement(element), null));
226 } 226 }
227 227
228 // TODO(ahe): Remove this method.
228 void addToWorkList(Element element) { 229 void addToWorkList(Element element) {
229 _enqueueElement(element); 230 _enqueueElement(
231 element, new UniverseSelector(new Selector.fromElement(element), null));
230 } 232 }
231 233
232 void forEach(void f(WorkItem work)) { 234 void forEach(void f(WorkItem work)) {
233 do { 235 do {
234 do { 236 do {
235 while (!queueIsEmpty) { 237 while (!queueIsEmpty) {
236 Element element = _pendingEnqueuedElements.removeFirst(); 238 Element element = _pendingEnqueuedElements.removeFirst();
237 if (element.isField) continue; 239 if (element.isField) continue;
238 FletchCodegenWorkItem workItem = new FletchCodegenWorkItem( 240 FletchCodegenWorkItem workItem = new FletchCodegenWorkItem(
239 compiler, element, itemCompilationContextCreator()); 241 compiler, element, itemCompilationContextCreator());
(...skipping 28 matching lines...) Expand all
268 } 270 }
269 271
270 void registerDynamicGetter(UniverseSelector selector) { 272 void registerDynamicGetter(UniverseSelector selector) {
271 dynamicCallEnqueuer.enqueueSelector(selector); 273 dynamicCallEnqueuer.enqueueSelector(selector);
272 } 274 }
273 275
274 void registerDynamicSetter(UniverseSelector selector) { 276 void registerDynamicSetter(UniverseSelector selector) {
275 dynamicCallEnqueuer.enqueueSelector(selector); 277 dynamicCallEnqueuer.enqueueSelector(selector);
276 } 278 }
277 279
278 void _enqueueElement(Element element) { 280 void _enqueueElement(Element element, UniverseSelector selector) {
279 if (_enqueuedElements.add(element)) { 281 if (_enqueuedElements.add(element)) {
280 _pendingEnqueuedElements.addLast(element); 282 _pendingEnqueuedElements.addLast(element);
281 newlyEnqueuedElements.add(element); 283 newlyEnqueuedElements.add(element);
282 compiler.reportVerboseInfo(element, "enqueued this", forceVerbose: true); 284 compiler.reportVerboseInfo(element, "enqueued this", forceVerbose: true);
283 } 285 }
284 } 286 }
285 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698