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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 2884233002: Use entities in runtime_types (Closed)
Patch Set: Remove debug print 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 js_backend.backend; 5 library js_backend.backend;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/backend_api.dart' 8 import '../common/backend_api.dart'
9 show ForeignResolver, NativeRegistry, ImpactTransformer; 9 show ForeignResolver, NativeRegistry, ImpactTransformer;
10 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; 10 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem;
11 import '../common/names.dart' show Uris; 11 import '../common/names.dart' show Uris;
12 import '../common/resolution.dart' show Resolution, Target; 12 import '../common/resolution.dart' show Resolution, Target;
13 import '../common/tasks.dart' show CompilerTask; 13 import '../common/tasks.dart' show CompilerTask;
14 import '../compiler.dart' show Compiler; 14 import '../compiler.dart' show Compiler;
15 import '../constants/constant_system.dart'; 15 import '../constants/constant_system.dart';
16 import '../constants/expressions.dart'; 16 import '../constants/expressions.dart';
17 import '../constants/values.dart'; 17 import '../constants/values.dart';
18 import '../common_elements.dart' show CommonElements, ElementEnvironment; 18 import '../common_elements.dart' show CommonElements;
19 import '../deferred_load.dart' show DeferredLoadTask; 19 import '../deferred_load.dart' show DeferredLoadTask;
20 import '../dump_info.dart' show DumpInfoTask; 20 import '../dump_info.dart' show DumpInfoTask;
21 import '../elements/elements.dart'; 21 import '../elements/elements.dart';
22 import '../elements/entities.dart'; 22 import '../elements/entities.dart';
23 import '../elements/names.dart'; 23 import '../elements/names.dart';
24 import '../elements/resolution_types.dart'; 24 import '../elements/resolution_types.dart';
25 import '../elements/types.dart';
26 import '../enqueue.dart' 25 import '../enqueue.dart'
27 show 26 show
28 DirectEnqueuerStrategy, 27 DirectEnqueuerStrategy,
29 Enqueuer, 28 Enqueuer,
30 EnqueueTask, 29 EnqueueTask,
31 ResolutionEnqueuer, 30 ResolutionEnqueuer,
32 TreeShakingEnqueuerStrategy; 31 TreeShakingEnqueuerStrategy;
33 import '../frontend_strategy.dart'; 32 import '../frontend_strategy.dart';
34 import '../io/multi_information.dart' show MultiSourceInformationStrategy; 33 import '../io/multi_information.dart' show MultiSourceInformationStrategy;
35 import '../io/position_information.dart' show PositionSourceInformationStrategy; 34 import '../io/position_information.dart' show PositionSourceInformationStrategy;
36 import '../io/source_information.dart' show SourceInformationStrategy; 35 import '../io/source_information.dart' show SourceInformationStrategy;
37 import '../io/start_end_information.dart' 36 import '../io/start_end_information.dart'
38 show StartEndSourceInformationStrategy; 37 show StartEndSourceInformationStrategy;
39 import '../js/js.dart' as jsAst; 38 import '../js/js.dart' as jsAst;
40 import '../js/js.dart' show js; 39 import '../js/js.dart' show js;
41 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; 40 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy;
42 import '../js/rewrite_async.dart'; 41 import '../js/rewrite_async.dart';
43 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, Emitter; 42 import '../js_emitter/js_emitter.dart' show CodeEmitterTask;
44 import '../kernel/task.dart'; 43 import '../kernel/task.dart';
45 import '../library_loader.dart' show LoadedLibraries; 44 import '../library_loader.dart' show LoadedLibraries;
46 import '../native/native.dart' as native; 45 import '../native/native.dart' as native;
47 import '../native/resolver.dart'; 46 import '../native/resolver.dart';
48 import '../ssa/ssa.dart' show SsaFunctionCompiler; 47 import '../ssa/ssa.dart' show SsaFunctionCompiler;
49 import '../tracer.dart'; 48 import '../tracer.dart';
50 import '../tree/tree.dart'; 49 import '../tree/tree.dart';
51 import '../types/types.dart'; 50 import '../types/types.dart';
52 import '../universe/call_structure.dart' show CallStructure; 51 import '../universe/call_structure.dart' show CallStructure;
53 import '../universe/selector.dart' show Selector; 52 import '../universe/selector.dart' show Selector;
(...skipping 17 matching lines...) Expand all
71 import 'js_interop_analysis.dart' show JsInteropAnalysis; 70 import 'js_interop_analysis.dart' show JsInteropAnalysis;
72 import 'lookup_map_analysis.dart' 71 import 'lookup_map_analysis.dart'
73 show LookupMapResolutionAnalysis, LookupMapAnalysis; 72 show LookupMapResolutionAnalysis, LookupMapAnalysis;
74 import 'mirrors_analysis.dart'; 73 import 'mirrors_analysis.dart';
75 import 'mirrors_data.dart'; 74 import 'mirrors_data.dart';
76 import 'namer.dart'; 75 import 'namer.dart';
77 import 'native_data.dart'; 76 import 'native_data.dart';
78 import 'no_such_method_registry.dart'; 77 import 'no_such_method_registry.dart';
79 import 'patch_resolver.dart'; 78 import 'patch_resolver.dart';
80 import 'resolution_listener.dart'; 79 import 'resolution_listener.dart';
80 import 'runtime_types.dart';
81 import 'type_variable_handler.dart'; 81 import 'type_variable_handler.dart';
82 82
83 part 'runtime_types.dart';
84
85 const VERBOSE_OPTIMIZER_HINTS = false; 83 const VERBOSE_OPTIMIZER_HINTS = false;
86 84
87 abstract class FunctionCompiler { 85 abstract class FunctionCompiler {
88 /// Generates JavaScript code for `work.element`. 86 /// Generates JavaScript code for `work.element`.
89 jsAst.Fun compile(CodegenWorkItem work, ClosedWorld closedWorld); 87 jsAst.Fun compile(CodegenWorkItem work, ClosedWorld closedWorld);
90 88
91 Iterable get tasks; 89 Iterable get tasks;
92 } 90 }
93 91
94 /* 92 /*
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 List<CompilerTask> get tasks { 367 List<CompilerTask> get tasks {
370 List<CompilerTask> result = functionCompiler.tasks; 368 List<CompilerTask> result = functionCompiler.tasks;
371 result.add(emitter); 369 result.add(emitter);
372 result.add(patchResolverTask); 370 result.add(patchResolverTask);
373 result.add(kernelTask); 371 result.add(kernelTask);
374 return result; 372 return result;
375 } 373 }
376 374
377 final RuntimeTypesNeedBuilder _rtiNeedBuilder; 375 final RuntimeTypesNeedBuilder _rtiNeedBuilder;
378 RuntimeTypesNeed _rtiNeed; 376 RuntimeTypesNeed _rtiNeed;
379 final _RuntimeTypes _rti; 377 final RuntimeTypesImpl _rti;
380 378
381 RuntimeTypesEncoder _rtiEncoder; 379 RuntimeTypesEncoder _rtiEncoder;
382 380
383 /// True if the html library has been loaded. 381 /// True if the html library has been loaded.
384 bool htmlLibraryIsLoaded = false; 382 bool htmlLibraryIsLoaded = false;
385 383
386 /// Resolution analysis for tracking reflective access to type variables. 384 /// Resolution analysis for tracking reflective access to type variables.
387 TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis; 385 TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis;
388 386
389 /// Codegen handler for reflective access to type variables. 387 /// Codegen handler for reflective access to type variables.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 return const StartEndSourceInformationStrategy(); 479 return const StartEndSourceInformationStrategy();
482 } 480 }
483 } 481 }
484 482
485 JavaScriptBackend(this.compiler, 483 JavaScriptBackend(this.compiler,
486 {bool generateSourceMap: true, 484 {bool generateSourceMap: true,
487 bool useStartupEmitter: false, 485 bool useStartupEmitter: false,
488 bool useMultiSourceInfo: false, 486 bool useMultiSourceInfo: false,
489 bool useNewSourceInfo: false, 487 bool useNewSourceInfo: false,
490 bool useKernel: false}) 488 bool useKernel: false})
491 : _rti = new _RuntimeTypes(compiler), 489 : _rti = new RuntimeTypesImpl(
490 compiler.elementEnvironment, compiler.frontEndStrategy.dartTypes),
492 optimizerHints = new OptimizerHintsForTests( 491 optimizerHints = new OptimizerHintsForTests(
493 compiler.elementEnvironment, compiler.commonElements), 492 compiler.elementEnvironment, compiler.commonElements),
494 this.sourceInformationStrategy = createSourceInformationStrategy( 493 this.sourceInformationStrategy = createSourceInformationStrategy(
495 generateSourceMap: generateSourceMap, 494 generateSourceMap: generateSourceMap,
496 useMultiSourceInfo: useMultiSourceInfo, 495 useMultiSourceInfo: useMultiSourceInfo,
497 useNewSourceInfo: useNewSourceInfo), 496 useNewSourceInfo: useNewSourceInfo),
498 constantCompilerTask = new JavaScriptConstantTask(compiler), 497 constantCompilerTask = new JavaScriptConstantTask(compiler),
499 _nativeDataResolver = new NativeDataResolverImpl(compiler), 498 _nativeDataResolver = new NativeDataResolverImpl(compiler),
500 _rtiNeedBuilder = 499 _rtiNeedBuilder =
501 compiler.frontEndStrategy.createRuntimeTypesNeedBuilder() { 500 compiler.frontEndStrategy.createRuntimeTypesNeedBuilder() {
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1115 }
1117 1116
1118 /// Called when the compiler starts running the codegen enqueuer. The 1117 /// Called when the compiler starts running the codegen enqueuer. The
1119 /// [WorldImpact] of enabled backend features is returned. 1118 /// [WorldImpact] of enabled backend features is returned.
1120 WorldImpact onCodegenStart( 1119 WorldImpact onCodegenStart(
1121 ClosedWorld closedWorld, CodegenWorldBuilder codegenWorldBuilder) { 1120 ClosedWorld closedWorld, CodegenWorldBuilder codegenWorldBuilder) {
1122 _oneShotInterceptorData = 1121 _oneShotInterceptorData =
1123 new OneShotInterceptorData(closedWorld.interceptorData, commonElements); 1122 new OneShotInterceptorData(closedWorld.interceptorData, commonElements);
1124 _namer = determineNamer(closedWorld, codegenWorldBuilder); 1123 _namer = determineNamer(closedWorld, codegenWorldBuilder);
1125 tracer = new Tracer(closedWorld, namer, compiler); 1124 tracer = new Tracer(closedWorld, namer, compiler);
1126 _rtiEncoder = 1125 _rtiEncoder = _namer.rtiEncoder = new RuntimeTypesEncoderImpl(
1127 _namer.rtiEncoder = new _RuntimeTypesEncoder(namer, commonElements); 1126 namer, compiler.elementEnvironment, commonElements);
1128 emitter.createEmitter(namer, closedWorld, codegenWorldBuilder); 1127 emitter.createEmitter(namer, closedWorld, codegenWorldBuilder);
1129 _codegenImpactTransformer = new CodegenImpactTransformer( 1128 _codegenImpactTransformer = new CodegenImpactTransformer(
1130 compiler.options, 1129 compiler.options,
1131 compiler.elementEnvironment, 1130 compiler.elementEnvironment,
1132 commonElements, 1131 commonElements,
1133 impacts, 1132 impacts,
1134 checkedModeHelpers, 1133 checkedModeHelpers,
1135 closedWorld.nativeData, 1134 closedWorld.nativeData,
1136 backendUsage, 1135 backendUsage,
1137 rtiNeed, 1136 rtiNeed,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1448
1450 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { 1449 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) {
1451 return !selector.isGetter; 1450 return !selector.isGetter;
1452 } 1451 }
1453 1452
1454 /// Returns `true` if [member] is called from a subclass via `super`. 1453 /// Returns `true` if [member] is called from a subclass via `super`.
1455 bool isAliasedSuperMember(MemberEntity member) { 1454 bool isAliasedSuperMember(MemberEntity member) {
1456 return _aliasedSuperMembers.contains(member); 1455 return _aliasedSuperMembers.contains(member);
1457 } 1456 }
1458 } 1457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698