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

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

Issue 2954493002: Less inequivalence on Hello World! (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 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 'model.dart';
25 import 'native_emitter.dart' show NativeEmitter; 26 import 'native_emitter.dart' show NativeEmitter;
26 import 'type_test_registry.dart' show TypeTestRegistry; 27 import 'type_test_registry.dart' show TypeTestRegistry;
27 import 'sorter.dart'; 28 import 'sorter.dart';
28 29
29 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter"); 30 const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter");
30 31
31 /** 32 /**
32 * Generates the code for all used classes in the program. Static fields (even 33 * Generates the code for all used classes in the program. Static fields (even
33 * in classes) are ignored, since they can be treated as non-class elements. 34 * in classes) are ignored, since they can be treated as non-class elements.
34 * 35 *
35 * The code for the containing (used) methods must exist in the `universe`. 36 * The code for the containing (used) methods must exist in the `universe`.
36 */ 37 */
37 class CodeEmitterTask extends CompilerTask { 38 class CodeEmitterTask extends CompilerTask {
38 TypeTestRegistry typeTestRegistry; 39 TypeTestRegistry typeTestRegistry;
39 NativeEmitter _nativeEmitter; 40 NativeEmitter _nativeEmitter;
40 MetadataCollector metadataCollector; 41 MetadataCollector metadataCollector;
41 EmitterFactory _emitterFactory; 42 EmitterFactory _emitterFactory;
42 Emitter _emitter; 43 Emitter _emitter;
43 final Compiler compiler; 44 final Compiler compiler;
44 45
46 ProgramBuilder programForTesting;
47
45 /// The [Sorter] use for ordering elements in the generated JavaScript. 48 /// The [Sorter] use for ordering elements in the generated JavaScript.
46 final Sorter sorter; 49 final Sorter sorter;
47 50
48 JavaScriptBackend get backend => compiler.backend; 51 JavaScriptBackend get backend => compiler.backend;
49 52
50 @deprecated 53 @deprecated
51 // This field should be removed. It's currently only needed for dump-info and 54 // This field should be removed. It's currently only needed for dump-info and
52 // tests. 55 // tests.
53 // The field is set after the program has been emitted. 56 // The field is set after the program has been emitted.
54 /// Contains a list of all classes that are emitted. 57 /// Contains a list of all classes that are emitted.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 190 }
188 191
189 int assembleProgram(Namer namer, ClosedWorld closedWorld) { 192 int assembleProgram(Namer namer, ClosedWorld closedWorld) {
190 return measure(() { 193 return measure(() {
191 _finalizeRti(); 194 _finalizeRti();
192 ProgramBuilder programBuilder = new ProgramBuilder( 195 ProgramBuilder programBuilder = new ProgramBuilder(
193 compiler.options, 196 compiler.options,
194 compiler.reporter, 197 compiler.reporter,
195 closedWorld.elementEnvironment, 198 closedWorld.elementEnvironment,
196 closedWorld.commonElements, 199 closedWorld.commonElements,
197 compiler.types, 200 closedWorld.dartTypes,
198 compiler.deferredLoadTask, 201 compiler.deferredLoadTask,
199 compiler.backendStrategy.closureDataLookup, 202 compiler.backendStrategy.closureDataLookup,
200 compiler.codegenWorldBuilder, 203 compiler.codegenWorldBuilder,
201 backend.nativeCodegenEnqueuer, 204 backend.nativeCodegenEnqueuer,
202 closedWorld.backendUsage, 205 closedWorld.backendUsage,
203 backend.constants, 206 backend.constants,
204 closedWorld.nativeData, 207 closedWorld.nativeData,
205 backend.rtiNeed, 208 backend.rtiNeed,
206 backend.mirrorsData, 209 backend.mirrorsData,
207 closedWorld.interceptorData, 210 closedWorld.interceptorData,
(...skipping 22 matching lines...) Expand all
230 abstract class EmitterFactory { 233 abstract class EmitterFactory {
231 /// Returns true, if the emitter supports reflection. 234 /// Returns true, if the emitter supports reflection.
232 bool get supportsReflection; 235 bool get supportsReflection;
233 236
234 /// Create the [Emitter] for the emitter [task] that uses the given [namer]. 237 /// Create the [Emitter] for the emitter [task] that uses the given [namer].
235 Emitter createEmitter( 238 Emitter createEmitter(
236 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld); 239 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld);
237 } 240 }
238 241
239 abstract class Emitter { 242 abstract class Emitter {
243 Program get programForTesting;
244
240 /// Uses the [programBuilder] to generate a model of the program, emits 245 /// Uses the [programBuilder] to generate a model of the program, emits
241 /// the program, and returns the size of the generated output. 246 /// the program, and returns the size of the generated output.
242 int emitProgram(ProgramBuilder programBuilder); 247 int emitProgram(ProgramBuilder programBuilder);
243 248
244 /// Returns the JS function that must be invoked to get the value of the 249 /// Returns the JS function that must be invoked to get the value of the
245 /// lazily initialized static. 250 /// lazily initialized static.
246 jsAst.Expression isolateLazyInitializerAccess(covariant FieldEntity element); 251 jsAst.Expression isolateLazyInitializerAccess(covariant FieldEntity element);
247 252
248 /// Returns the closure expression of a static function. 253 /// Returns the closure expression of a static function.
249 jsAst.Expression isolateStaticClosureAccess(covariant FunctionEntity element); 254 jsAst.Expression isolateStaticClosureAccess(covariant FunctionEntity element);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 jsAst.Expression constantReference(ConstantValue constant); 288 jsAst.Expression constantReference(ConstantValue constant);
284 289
285 /// Returns the JS template for the given [builtin]. 290 /// Returns the JS template for the given [builtin].
286 jsAst.Template templateForBuiltin(JsBuiltin builtin); 291 jsAst.Template templateForBuiltin(JsBuiltin builtin);
287 292
288 /// Returns the size of the code generated for a given output [unit]. 293 /// Returns the size of the code generated for a given output [unit].
289 int generatedSize(OutputUnit unit); 294 int generatedSize(OutputUnit unit);
290 } 295 }
291 296
292 abstract class EmitterBase implements Emitter { 297 abstract class EmitterBase implements Emitter {
298 Program programForTesting;
293 Namer get namer; 299 Namer get namer;
294 300
295 jsAst.PropertyAccess globalPropertyAccessForMember(MemberEntity element) { 301 jsAst.PropertyAccess globalPropertyAccessForMember(MemberEntity element) {
296 jsAst.Name name = namer.globalPropertyNameForMember(element); 302 jsAst.Name name = namer.globalPropertyNameForMember(element);
297 jsAst.PropertyAccess pa = new jsAst.PropertyAccess( 303 jsAst.PropertyAccess pa = new jsAst.PropertyAccess(
298 new jsAst.VariableUse(namer.globalObjectForMember(element)), name); 304 new jsAst.VariableUse(namer.globalObjectForMember(element)), name);
299 return pa; 305 return pa;
300 } 306 }
301 307
302 jsAst.PropertyAccess globalPropertyAccessForClass(ClassEntity element) { 308 jsAst.PropertyAccess globalPropertyAccessForClass(ClassEntity element) {
(...skipping 28 matching lines...) Expand all
331 @override 337 @override
332 jsAst.Expression interceptorClassAccess(ClassEntity element) { 338 jsAst.Expression interceptorClassAccess(ClassEntity element) {
333 return globalPropertyAccessForClass(element); 339 return globalPropertyAccessForClass(element);
334 } 340 }
335 341
336 @override 342 @override
337 jsAst.Expression typeAccess(Entity element) { 343 jsAst.Expression typeAccess(Entity element) {
338 return globalPropertyAccessForType(element); 344 return globalPropertyAccessForType(element);
339 } 345 }
340 } 346 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.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