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

Side by Side Diff: pkg/compiler/lib/src/common/codegen.dart

Issue 2349163003: Move towards using WorldImpact for codegen (Closed)
Patch Set: Reinsert missing features uses. Created 4 years, 2 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/common/backend_api.dart ('k') | pkg/compiler/lib/src/common/registry.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.common.codegen; 5 library dart2js.common.codegen;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/values.dart' show ConstantValue; 9 import '../constants/values.dart' show ConstantValue;
10 import '../dart_types.dart' show DartType, InterfaceType; 10 import '../dart_types.dart' show DartType, InterfaceType;
11 import '../elements/elements.dart' 11 import '../elements/elements.dart'
12 show 12 show
13 AstElement, 13 AstElement,
14 ClassElement, 14 ClassElement,
15 Element, 15 Element,
16 FunctionElement, 16 FunctionElement,
17 LocalFunctionElement, 17 LocalFunctionElement,
18 ResolvedAst; 18 ResolvedAst;
19 import '../enqueue.dart' show Enqueuer; 19 import '../enqueue.dart' show Enqueuer;
20 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; 20 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse;
21 import '../universe/world_impact.dart' 21 import '../universe/world_impact.dart'
22 show WorldImpact, WorldImpactBuilder, WorldImpactVisitor; 22 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor;
23 import '../util/util.dart' show Pair, Setlet; 23 import '../util/util.dart' show Pair, Setlet;
24 import 'registry.dart' show Registry, EagerRegistry; 24 import 'registry.dart' show Registry;
25 import 'work.dart' show WorkItem; 25 import 'work.dart' show WorkItem;
26 26
27 class CodegenImpact extends WorldImpact { 27 class CodegenImpact extends WorldImpact {
28 const CodegenImpact(); 28 const CodegenImpact();
29 29
30 // TODO(johnniwinther): Remove this.
31 Registry get registry => null;
32
33 Iterable<ConstantValue> get compileTimeConstants => const <ConstantValue>[]; 30 Iterable<ConstantValue> get compileTimeConstants => const <ConstantValue>[];
34 31
35 Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks { 32 Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks {
36 return const <Pair<DartType, DartType>>[]; 33 return const <Pair<DartType, DartType>>[];
37 } 34 }
38 35
39 Iterable<String> get constSymbols => const <String>[]; 36 Iterable<String> get constSymbols => const <String>[];
40 37
41 Iterable<Set<ClassElement>> get specializedGetInterceptors { 38 Iterable<Set<ClassElement>> get specializedGetInterceptors {
42 return const <Set<ClassElement>>[]; 39 return const <Set<ClassElement>>[];
43 } 40 }
44 41
45 bool get usesInterceptor => false; 42 bool get usesInterceptor => false;
46 43
47 Iterable<ClassElement> get typeConstants => const <ClassElement>[]; 44 Iterable<ClassElement> get typeConstants => const <ClassElement>[];
48 45
49 Iterable<Element> get asyncMarkers => const <FunctionElement>[]; 46 Iterable<Element> get asyncMarkers => const <FunctionElement>[];
50 } 47 }
51 48
52 class _CodegenImpact extends WorldImpactBuilder implements CodegenImpact { 49 class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
53 // TODO(johnniwinther): Remove this.
54 final Registry registry;
55
56 Setlet<ConstantValue> _compileTimeConstants; 50 Setlet<ConstantValue> _compileTimeConstants;
57 Setlet<Pair<DartType, DartType>> _typeVariableBoundsSubtypeChecks; 51 Setlet<Pair<DartType, DartType>> _typeVariableBoundsSubtypeChecks;
58 Setlet<String> _constSymbols; 52 Setlet<String> _constSymbols;
59 List<Set<ClassElement>> _specializedGetInterceptors; 53 List<Set<ClassElement>> _specializedGetInterceptors;
60 bool _usesInterceptor = false; 54 bool _usesInterceptor = false;
61 Setlet<ClassElement> _typeConstants; 55 Setlet<ClassElement> _typeConstants;
62 Setlet<FunctionElement> _asyncMarkers; 56 Setlet<FunctionElement> _asyncMarkers;
63 57
64 _CodegenImpact(this.registry); 58 _CodegenImpact();
65 59
66 void apply(WorldImpactVisitor visitor) { 60 void apply(WorldImpactVisitor visitor) {
67 staticUses.forEach(visitor.visitStaticUse); 61 staticUses.forEach(visitor.visitStaticUse);
68 dynamicUses.forEach(visitor.visitDynamicUse); 62 dynamicUses.forEach(visitor.visitDynamicUse);
69 typeUses.forEach(visitor.visitTypeUse); 63 typeUses.forEach(visitor.visitTypeUse);
70 } 64 }
71 65
72 void registerCompileTimeConstant(ConstantValue constant) { 66 void registerCompileTimeConstant(ConstantValue constant) {
73 if (_compileTimeConstants == null) { 67 if (_compileTimeConstants == null) {
74 _compileTimeConstants = new Setlet<ConstantValue>(); 68 _compileTimeConstants = new Setlet<ConstantValue>();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // TODO(johnniwinther): Split this class into interface and implementation. 147 // TODO(johnniwinther): Split this class into interface and implementation.
154 // TODO(johnniwinther): Move this implementation to the JS backend. 148 // TODO(johnniwinther): Move this implementation to the JS backend.
155 class CodegenRegistry extends Registry { 149 class CodegenRegistry extends Registry {
156 final Compiler compiler; 150 final Compiler compiler;
157 final Element currentElement; 151 final Element currentElement;
158 final _CodegenImpact worldImpact; 152 final _CodegenImpact worldImpact;
159 153
160 CodegenRegistry(Compiler compiler, AstElement currentElement) 154 CodegenRegistry(Compiler compiler, AstElement currentElement)
161 : this.compiler = compiler, 155 : this.compiler = compiler,
162 this.currentElement = currentElement, 156 this.currentElement = currentElement,
163 this.worldImpact = new _CodegenImpact(new EagerRegistry( 157 this.worldImpact = new _CodegenImpact();
164 'EagerRegistry for $currentElement', compiler.enqueuer.codegen));
165 158
166 bool get isForResolution => false; 159 bool get isForResolution => false;
167 160
168 String toString() => 'CodegenRegistry for $currentElement'; 161 String toString() => 'CodegenRegistry for $currentElement';
169 162
170 @deprecated 163 @deprecated
171 void registerInstantiatedClass(ClassElement element) { 164 void registerInstantiatedClass(ClassElement element) {
172 registerInstantiation(element.rawType); 165 registerInstantiation(element.rawType);
173 } 166 }
174 167
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 237
245 WorldImpact run(Compiler compiler, Enqueuer world) { 238 WorldImpact run(Compiler compiler, Enqueuer world) {
246 if (world.isProcessed(element)) return const WorldImpact(); 239 if (world.isProcessed(element)) return const WorldImpact();
247 240
248 registry = new CodegenRegistry(compiler, element); 241 registry = new CodegenRegistry(compiler, element);
249 return compiler.codegen(this, world); 242 return compiler.codegen(this, world);
250 } 243 }
251 244
252 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; 245 String toString() => 'CodegenWorkItem(${resolvedAst.element})';
253 } 246 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/common/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698