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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/code_emitter_task.dart

Issue 2843283004: Use more entities in program_builder, collector and registry (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 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) 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.js_emitter.code_emitter_task; 5 library dart2js.js_emitter.code_emitter_task;
6 6
7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; 7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/tasks.dart' show CompilerTask; 10 import '../common/tasks.dart' show CompilerTask;
11 import '../compiler.dart' show Compiler; 11 import '../compiler.dart' show Compiler;
12 import '../constants/values.dart'; 12 import '../constants/values.dart';
13 import '../deferred_load.dart' show OutputUnit; 13 import '../deferred_load.dart' show OutputUnit;
14 import '../elements/entities.dart'; 14 import '../elements/entities.dart';
15 import '../js/js.dart' as jsAst; 15 import '../js/js.dart' as jsAst;
16 import '../js_backend/js_backend.dart' show JavaScriptBackend, Namer; 16 import '../js_backend/js_backend.dart' show JavaScriptBackend, Namer;
17 import '../universe/world_builder.dart' show CodegenWorldBuilder; 17 import '../universe/world_builder.dart' show CodegenWorldBuilder;
18 import '../world.dart' show ClosedWorld; 18 import '../world.dart' show ClosedWorld;
19 import 'full_emitter/emitter.dart' as full_js_emitter; 19 import 'full_emitter/emitter.dart' as full_js_emitter;
20 import 'lazy_emitter/emitter.dart' as lazy_js_emitter; 20 import 'lazy_emitter/emitter.dart' as lazy_js_emitter;
21 import 'program_builder/program_builder.dart'; 21 import 'program_builder/program_builder.dart';
22 import 'startup_emitter/emitter.dart' as startup_js_emitter; 22 import 'startup_emitter/emitter.dart' as startup_js_emitter;
23 23
24 import 'metadata_collector.dart' show MetadataCollector; 24 import 'metadata_collector.dart' show MetadataCollector;
25 import 'native_emitter.dart' show NativeEmitter; 25 import 'native_emitter.dart' show NativeEmitter;
26 import 'type_test_registry.dart' show TypeTestRegistry; 26 import 'type_test_registry.dart' show TypeTestRegistry;
27 import 'sorter.dart';
27 28
28 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter"); 29 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter");
29 30
30 /** 31 /**
31 * Generates the code for all used classes in the program. Static fields (even 32 * Generates the code for all used classes in the program. Static fields (even
32 * in classes) are ignored, since they can be treated as non-class elements. 33 * in classes) are ignored, since they can be treated as non-class elements.
33 * 34 *
34 * The code for the containing (used) methods must exist in the `universe`. 35 * The code for the containing (used) methods must exist in the `universe`.
35 */ 36 */
36 class CodeEmitterTask extends CompilerTask { 37 class CodeEmitterTask extends CompilerTask {
(...skipping 28 matching lines...) Expand all
65 generateSourceMap: generateSourceMap); 66 generateSourceMap: generateSourceMap);
66 } 67 }
67 } 68 }
68 69
69 Emitter get emitter { 70 Emitter get emitter {
70 assert(invariant(NO_LOCATION_SPANNABLE, _emitter != null, 71 assert(invariant(NO_LOCATION_SPANNABLE, _emitter != null,
71 message: "Emitter has not been created yet.")); 72 message: "Emitter has not been created yet."));
72 return _emitter; 73 return _emitter;
73 } 74 }
74 75
76 /// Returns the [Sorter] use for ordering elements in the generated
77 /// JavaScript.
78 // TODO(johnniwinther): Switch this based on the used entity model.
79 Sorter get sorter => const ElementSorter();
80
75 String get name => 'Code emitter'; 81 String get name => 'Code emitter';
76 82
77 /// Returns true, if the emitter supports reflection. 83 /// Returns true, if the emitter supports reflection.
78 bool get supportsReflection => _emitterFactory.supportsReflection; 84 bool get supportsReflection => _emitterFactory.supportsReflection;
79 85
80 /// Returns the closure expression of a static function. 86 /// Returns the closure expression of a static function.
81 jsAst.Expression isolateStaticClosureAccess(FunctionEntity element) { 87 jsAst.Expression isolateStaticClosureAccess(FunctionEntity element) {
82 return emitter.isolateStaticClosureAccess(element); 88 return emitter.isolateStaticClosureAccess(element);
83 } 89 }
84 90
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 backend.rtiEncoder); 175 backend.rtiEncoder);
170 typeTestRegistry = new TypeTestRegistry(codegenWorldBuilder, closedWorld); 176 typeTestRegistry = new TypeTestRegistry(codegenWorldBuilder, closedWorld);
171 }); 177 });
172 } 178 }
173 179
174 int assembleProgram(Namer namer, ClosedWorld closedWorld) { 180 int assembleProgram(Namer namer, ClosedWorld closedWorld) {
175 return measure(() { 181 return measure(() {
176 _finalizeRti(); 182 _finalizeRti();
177 ProgramBuilder programBuilder = new ProgramBuilder( 183 ProgramBuilder programBuilder = new ProgramBuilder(
178 compiler.options, 184 compiler.options,
185 compiler.elementEnvironment,
179 compiler.commonElements, 186 compiler.commonElements,
180 compiler.types, 187 compiler.types,
181 compiler.deferredLoadTask, 188 compiler.deferredLoadTask,
182 compiler.closureToClassMapper, 189 compiler.closureToClassMapper,
183 compiler.codegenWorldBuilder, 190 compiler.codegenWorldBuilder,
184 backend.nativeCodegenEnqueuer, 191 backend.nativeCodegenEnqueuer,
185 backend.backendUsage, 192 backend.backendUsage,
186 backend.constants, 193 backend.constants,
187 backend.nativeData, 194 backend.nativeData,
188 backend.rtiNeed, 195 backend.rtiNeed,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 270
264 /// Returns the JS code for accessing the given [constant]. 271 /// Returns the JS code for accessing the given [constant].
265 jsAst.Expression constantReference(ConstantValue constant); 272 jsAst.Expression constantReference(ConstantValue constant);
266 273
267 /// Returns the JS template for the given [builtin]. 274 /// Returns the JS template for the given [builtin].
268 jsAst.Template templateForBuiltin(JsBuiltin builtin); 275 jsAst.Template templateForBuiltin(JsBuiltin builtin);
269 276
270 /// Returns the size of the code generated for a given output [unit]. 277 /// Returns the size of the code generated for a given output [unit].
271 int generatedSize(OutputUnit unit); 278 int generatedSize(OutputUnit unit);
272 } 279 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/runtime_types.dart ('k') | pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698