OLD | NEW |
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 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 import '../js/rewrite_async.dart'; | 45 import '../js/rewrite_async.dart'; |
46 import '../js_emitter/js_emitter.dart' show CodeEmitterTask; | 46 import '../js_emitter/js_emitter.dart' show CodeEmitterTask; |
47 import '../kernel/task.dart'; | 47 import '../kernel/task.dart'; |
48 import '../library_loader.dart' show LibraryLoader, LoadedLibraries; | 48 import '../library_loader.dart' show LibraryLoader, LoadedLibraries; |
49 import '../native/native.dart' as native; | 49 import '../native/native.dart' as native; |
50 import '../patch_parser.dart' | 50 import '../patch_parser.dart' |
51 show checkNativeAnnotation, checkJsInteropAnnotation; | 51 show checkNativeAnnotation, checkJsInteropAnnotation; |
52 import '../ssa/ssa.dart' show SsaFunctionCompiler; | 52 import '../ssa/ssa.dart' show SsaFunctionCompiler; |
53 import '../tracer.dart'; | 53 import '../tracer.dart'; |
54 import '../tree/tree.dart'; | 54 import '../tree/tree.dart'; |
| 55 import '../types/types.dart'; |
55 import '../universe/call_structure.dart' show CallStructure; | 56 import '../universe/call_structure.dart' show CallStructure; |
56 import '../universe/selector.dart' show Selector; | 57 import '../universe/selector.dart' show Selector; |
57 import '../universe/world_builder.dart'; | 58 import '../universe/world_builder.dart'; |
58 import '../universe/use.dart' show StaticUse, TypeUse; | 59 import '../universe/use.dart' show StaticUse, TypeUse; |
59 import '../universe/world_impact.dart' | 60 import '../universe/world_impact.dart' |
60 show | 61 show |
61 ImpactStrategy, | 62 ImpactStrategy, |
62 ImpactUseCase, | 63 ImpactUseCase, |
63 WorldImpact, | 64 WorldImpact, |
64 WorldImpactBuilder, | 65 WorldImpactBuilder, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 NativeDataBuilder get nativeDataBuilder => _nativeData; | 436 NativeDataBuilder get nativeDataBuilder => _nativeData; |
436 InterceptorDataBuilder _interceptorDataBuilder; | 437 InterceptorDataBuilder _interceptorDataBuilder; |
437 InterceptorData _interceptorData; | 438 InterceptorData _interceptorData; |
438 OneShotInterceptorData _oneShotInterceptorData; | 439 OneShotInterceptorData _oneShotInterceptorData; |
439 BackendUsage _backendUsage; | 440 BackendUsage _backendUsage; |
440 BackendUsageBuilder _backendUsageBuilder; | 441 BackendUsageBuilder _backendUsageBuilder; |
441 MirrorsData mirrorsData; | 442 MirrorsData mirrorsData; |
442 CheckedModeHelpers _checkedModeHelpers; | 443 CheckedModeHelpers _checkedModeHelpers; |
443 | 444 |
444 ResolutionEnqueuerListener _resolutionEnqueuerListener; | 445 ResolutionEnqueuerListener _resolutionEnqueuerListener; |
445 CodegenEnqueuerListener _codegenEnqueuerListener; | |
446 | 446 |
447 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer; | 447 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer; |
448 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer; | 448 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer; |
449 | 449 |
450 BackendHelpers helpers; | 450 BackendHelpers helpers; |
451 BackendImpacts impacts; | 451 BackendImpacts impacts; |
452 | 452 |
453 /// Common classes used by the backend. | 453 /// Common classes used by the backend. |
454 BackendClasses backendClasses; | 454 BackendClasses backendClasses; |
455 | 455 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 nativeData, | 559 nativeData, |
560 _interceptorDataBuilder, | 560 _interceptorDataBuilder, |
561 _backendUsageBuilder, | 561 _backendUsageBuilder, |
562 _rtiNeedBuilder, | 562 _rtiNeedBuilder, |
563 mirrorsData, | 563 mirrorsData, |
564 noSuchMethodRegistry, | 564 noSuchMethodRegistry, |
565 customElementsResolutionAnalysis, | 565 customElementsResolutionAnalysis, |
566 lookupMapLibraryAccess, | 566 lookupMapLibraryAccess, |
567 mirrorsAnalysis, | 567 mirrorsAnalysis, |
568 _nativeResolutionEnqueuer); | 568 _nativeResolutionEnqueuer); |
569 _codegenEnqueuerListener = new CodegenEnqueuerListener( | |
570 this, | |
571 compiler.elementEnvironment, | |
572 commonElements, | |
573 helpers, | |
574 impacts, | |
575 mirrorsData, | |
576 customElementsCodegenAnalysis, | |
577 typeVariableHandler, | |
578 lookupMapAnalysis, | |
579 mirrorsAnalysis, | |
580 _nativeCodegenEnqueuer); | |
581 } | 569 } |
582 | 570 |
583 /// The [ConstantSystem] used to interpret compile-time constants for this | 571 /// The [ConstantSystem] used to interpret compile-time constants for this |
584 /// backend. | 572 /// backend. |
585 ConstantSystem get constantSystem => constants.constantSystem; | 573 ConstantSystem get constantSystem => constants.constantSystem; |
586 | 574 |
587 DiagnosticReporter get reporter => compiler.reporter; | 575 DiagnosticReporter get reporter => compiler.reporter; |
588 | 576 |
589 CommonElements get commonElements => compiler.commonElements; | 577 CommonElements get commonElements => compiler.commonElements; |
590 | 578 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 assert(invariant(NO_LOCATION_SPANNABLE, _rtiEncoder != null, | 634 assert(invariant(NO_LOCATION_SPANNABLE, _rtiEncoder != null, |
647 message: "RuntimeTypesEncoder has not been created.")); | 635 message: "RuntimeTypesEncoder has not been created.")); |
648 return _rtiEncoder; | 636 return _rtiEncoder; |
649 } | 637 } |
650 | 638 |
651 CheckedModeHelpers get checkedModeHelpers => _checkedModeHelpers; | 639 CheckedModeHelpers get checkedModeHelpers => _checkedModeHelpers; |
652 | 640 |
653 EnqueuerListener get resolutionEnqueuerListener => | 641 EnqueuerListener get resolutionEnqueuerListener => |
654 _resolutionEnqueuerListener; | 642 _resolutionEnqueuerListener; |
655 | 643 |
656 EnqueuerListener get codegenEnqueuerListener => _codegenEnqueuerListener; | |
657 | |
658 /// Returns constant environment for the JavaScript interpretation of the | 644 /// Returns constant environment for the JavaScript interpretation of the |
659 /// constants. | 645 /// constants. |
660 JavaScriptConstantCompiler get constants { | 646 JavaScriptConstantCompiler get constants { |
661 return constantCompilerTask.jsConstantCompiler; | 647 return constantCompilerTask.jsConstantCompiler; |
662 } | 648 } |
663 | 649 |
664 bool isDefaultNoSuchMethod(MethodElement element) { | 650 bool isDefaultNoSuchMethod(MethodElement element) { |
665 return noSuchMethodRegistry.isDefaultNoSuchMethodImplementation(element); | 651 return noSuchMethodRegistry.isDefaultNoSuchMethodImplementation(element); |
666 } | 652 } |
667 | 653 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); | 946 node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); |
961 } | 947 } |
962 // No native behavior for this call. | 948 // No native behavior for this call. |
963 return null; | 949 return null; |
964 } | 950 } |
965 | 951 |
966 bool isComplexNoSuchMethod(FunctionElement element) => | 952 bool isComplexNoSuchMethod(FunctionElement element) => |
967 noSuchMethodRegistry.isComplex(element); | 953 noSuchMethodRegistry.isComplex(element); |
968 | 954 |
969 /// Creates an [Enqueuer] for code generation specific to this backend. | 955 /// Creates an [Enqueuer] for code generation specific to this backend. |
970 CodegenEnqueuer createCodegenEnqueuer(CompilerTask task, Compiler compiler) { | 956 CodegenEnqueuer createCodegenEnqueuer( |
| 957 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { |
971 return new CodegenEnqueuer( | 958 return new CodegenEnqueuer( |
972 task, this, compiler.options, const TreeShakingEnqueuerStrategy()); | 959 task, |
| 960 compiler.options, |
| 961 const TreeShakingEnqueuerStrategy(), |
| 962 new CodegenWorldBuilderImpl( |
| 963 this, closedWorld, const TypeMaskStrategy()), |
| 964 new CodegenWorkItemBuilder(this, compiler.options), |
| 965 new CodegenEnqueuerListener( |
| 966 compiler.dumpInfoTask, |
| 967 compiler.elementEnvironment, |
| 968 commonElements, |
| 969 helpers, |
| 970 impacts, |
| 971 backendUsage, |
| 972 rtiNeed, |
| 973 mirrorsData, |
| 974 customElementsCodegenAnalysis, |
| 975 typeVariableHandler, |
| 976 lookupMapAnalysis, |
| 977 mirrorsAnalysis, |
| 978 _nativeCodegenEnqueuer)); |
973 } | 979 } |
974 | 980 |
975 WorldImpact codegen(CodegenWorkItem work) { | 981 WorldImpact codegen(CodegenWorkItem work) { |
976 Element element = work.element; | 982 Element element = work.element; |
977 if (compiler.elementHasCompileTimeError(element)) { | 983 if (compiler.elementHasCompileTimeError(element)) { |
978 DiagnosticMessage message = | 984 DiagnosticMessage message = |
979 // If there's more than one error, the first is probably most | 985 // If there's more than one error, the first is probably most |
980 // informative, as the following errors may be side-effects of the | 986 // informative, as the following errors may be side-effects of the |
981 // first error. | 987 // first error. |
982 compiler.elementsWithCompileTimeErrors[element].first; | 988 compiler.elementsWithCompileTimeErrors[element].first; |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 return _backend.defaultSuperclass(element); | 1649 return _backend.defaultSuperclass(element); |
1644 } | 1650 } |
1645 | 1651 |
1646 @override | 1652 @override |
1647 bool isNativeClass(ClassEntity element) => | 1653 bool isNativeClass(ClassEntity element) => |
1648 _backend.nativeData.isNativeClass(element); | 1654 _backend.nativeData.isNativeClass(element); |
1649 | 1655 |
1650 @override | 1656 @override |
1651 bool isForeign(Element element) => _backend.isForeign(element); | 1657 bool isForeign(Element element) => _backend.isForeign(element); |
1652 } | 1658 } |
OLD | NEW |