| 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 '../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 CodegenWorkItem; | 10 import '../common/codegen.dart' show CodegenWorkItem; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 final Set<ClassEntity> specialOperatorEqClasses = new Set<ClassEntity>(); | 358 final Set<ClassEntity> specialOperatorEqClasses = new Set<ClassEntity>(); |
| 359 | 359 |
| 360 List<CompilerTask> get tasks { | 360 List<CompilerTask> get tasks { |
| 361 List<CompilerTask> result = functionCompiler.tasks; | 361 List<CompilerTask> result = functionCompiler.tasks; |
| 362 result.add(emitter); | 362 result.add(emitter); |
| 363 result.add(patchResolverTask); | 363 result.add(patchResolverTask); |
| 364 result.add(kernelTask); | 364 result.add(kernelTask); |
| 365 return result; | 365 return result; |
| 366 } | 366 } |
| 367 | 367 |
| 368 final RuntimeTypesNeedBuilder _rtiNeedBuilder; | 368 RuntimeTypesImpl _rti; |
| 369 RuntimeTypesNeed _rtiNeed; | |
| 370 final RuntimeTypesImpl _rti; | |
| 371 | 369 |
| 372 RuntimeTypesEncoder _rtiEncoder; | 370 RuntimeTypesEncoder _rtiEncoder; |
| 373 | 371 |
| 374 /// True if the html library has been loaded. | 372 /// True if the html library has been loaded. |
| 375 bool htmlLibraryIsLoaded = false; | 373 bool htmlLibraryIsLoaded = false; |
| 376 | 374 |
| 377 /// Resolution analysis for tracking reflective access to type variables. | |
| 378 TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis; | |
| 379 | |
| 380 /// Codegen handler for reflective access to type variables. | 375 /// Codegen handler for reflective access to type variables. |
| 381 TypeVariableCodegenAnalysis _typeVariableCodegenAnalysis; | 376 TypeVariableCodegenAnalysis _typeVariableCodegenAnalysis; |
| 382 | 377 |
| 383 /// Resolution support for generating table of interceptors and | 378 /// Resolution support for generating table of interceptors and |
| 384 /// constructors for custom elements. | 379 /// constructors for custom elements. |
| 385 CustomElementsResolutionAnalysis _customElementsResolutionAnalysis; | 380 CustomElementsResolutionAnalysis _customElementsResolutionAnalysis; |
| 386 | 381 |
| 387 /// Codegen support for generating table of interceptors and | 382 /// Codegen support for generating table of interceptors and |
| 388 /// constructors for custom elements. | 383 /// constructors for custom elements. |
| 389 CustomElementsCodegenAnalysis _customElementsCodegenAnalysis; | 384 CustomElementsCodegenAnalysis _customElementsCodegenAnalysis; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 420 | 415 |
| 421 PatchResolverTask patchResolverTask; | 416 PatchResolverTask patchResolverTask; |
| 422 | 417 |
| 423 /// The strategy used for collecting and emitting source information. | 418 /// The strategy used for collecting and emitting source information. |
| 424 SourceInformationStrategy sourceInformationStrategy; | 419 SourceInformationStrategy sourceInformationStrategy; |
| 425 | 420 |
| 426 /// Interface for serialization of backend specific data. | 421 /// Interface for serialization of backend specific data. |
| 427 JavaScriptBackendSerialization serialization; | 422 JavaScriptBackendSerialization serialization; |
| 428 | 423 |
| 429 NativeDataBuilderImpl _nativeDataBuilder; | 424 NativeDataBuilderImpl _nativeDataBuilder; |
| 430 final NativeBasicDataBuilderImpl _nativeBasicDataBuilder = | |
| 431 new NativeBasicDataBuilderImpl(); | |
| 432 NativeBasicDataImpl _nativeBasicData; | |
| 433 NativeDataBuilder get nativeDataBuilder => _nativeDataBuilder; | 425 NativeDataBuilder get nativeDataBuilder => _nativeDataBuilder; |
| 434 final NativeDataResolver _nativeDataResolver; | 426 final NativeDataResolver _nativeDataResolver; |
| 435 OneShotInterceptorData _oneShotInterceptorData; | 427 OneShotInterceptorData _oneShotInterceptorData; |
| 436 BackendUsageBuilder _backendUsageBuilder; | 428 BackendUsageBuilder _backendUsageBuilder; |
| 437 MirrorsDataImpl _mirrorsData; | 429 MirrorsDataImpl _mirrorsData; |
| 438 CheckedModeHelpers _checkedModeHelpers; | 430 CheckedModeHelpers _checkedModeHelpers; |
| 439 | 431 |
| 440 final SuperMemberData superMemberData = new SuperMemberData(); | 432 final SuperMemberData superMemberData = new SuperMemberData(); |
| 441 | 433 |
| 442 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer; | 434 native.NativeResolutionEnqueuer _nativeResolutionEnqueuer; |
| 443 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer; | 435 native.NativeCodegenEnqueuer _nativeCodegenEnqueuer; |
| 444 | 436 |
| 445 BackendImpacts impacts; | |
| 446 | |
| 447 Target _target; | 437 Target _target; |
| 448 | 438 |
| 449 Tracer tracer; | 439 Tracer tracer; |
| 450 | 440 |
| 451 JavaScriptBackend(this.compiler, | 441 JavaScriptBackend(this.compiler, |
| 452 {bool generateSourceMap: true, | 442 {bool generateSourceMap: true, |
| 453 bool useStartupEmitter: false, | 443 bool useStartupEmitter: false, |
| 454 bool useMultiSourceInfo: false, | 444 bool useMultiSourceInfo: false, |
| 455 bool useNewSourceInfo: false, | 445 bool useNewSourceInfo: false, |
| 456 bool useKernel: false}) | 446 bool useKernel: false}) |
| 457 : _rti = new RuntimeTypesImpl( | 447 : optimizerHints = new OptimizerHintsForTests( |
| 458 compiler.frontendStrategy.elementEnvironment, | |
| 459 compiler.frontendStrategy.dartTypes), | |
| 460 optimizerHints = new OptimizerHintsForTests( | |
| 461 compiler.frontendStrategy.elementEnvironment, | 448 compiler.frontendStrategy.elementEnvironment, |
| 462 compiler.frontendStrategy.commonElements), | 449 compiler.frontendStrategy.commonElements), |
| 463 this.sourceInformationStrategy = | 450 this.sourceInformationStrategy = |
| 464 compiler.backendStrategy.sourceInformationStrategy, | 451 compiler.backendStrategy.sourceInformationStrategy, |
| 465 constantCompilerTask = new JavaScriptConstantTask(compiler), | 452 constantCompilerTask = new JavaScriptConstantTask(compiler), |
| 466 _nativeDataResolver = new NativeDataResolverImpl(compiler), | 453 _nativeDataResolver = new NativeDataResolverImpl(compiler) { |
| 467 _rtiNeedBuilder = | |
| 468 compiler.frontendStrategy.createRuntimeTypesNeedBuilder() { | |
| 469 CommonElements commonElements = compiler.frontendStrategy.commonElements; | 454 CommonElements commonElements = compiler.frontendStrategy.commonElements; |
| 470 _target = new JavaScriptBackendTarget(this); | 455 _target = new JavaScriptBackendTarget(this); |
| 471 impacts = new BackendImpacts(compiler.options, commonElements); | |
| 472 _mirrorsData = compiler.frontendStrategy.createMirrorsDataBuilder(); | 456 _mirrorsData = compiler.frontendStrategy.createMirrorsDataBuilder(); |
| 473 _backendUsageBuilder = new BackendUsageBuilderImpl(commonElements); | 457 _backendUsageBuilder = new BackendUsageBuilderImpl(commonElements); |
| 474 _checkedModeHelpers = new CheckedModeHelpers(commonElements); | 458 _checkedModeHelpers = new CheckedModeHelpers(commonElements); |
| 475 emitter = | 459 emitter = |
| 476 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter); | 460 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter); |
| 477 | |
| 478 _typeVariableResolutionAnalysis = new TypeVariableResolutionAnalysis( | |
| 479 compiler.frontendStrategy.elementEnvironment, | |
| 480 impacts, | |
| 481 _backendUsageBuilder); | |
| 482 jsInteropAnalysis = new JsInteropAnalysis(this); | 461 jsInteropAnalysis = new JsInteropAnalysis(this); |
| 483 _mirrorsResolutionAnalysis = | 462 _mirrorsResolutionAnalysis = |
| 484 compiler.frontendStrategy.createMirrorsResolutionAnalysis(this); | 463 compiler.frontendStrategy.createMirrorsResolutionAnalysis(this); |
| 485 lookupMapResolutionAnalysis = new LookupMapResolutionAnalysis( | 464 lookupMapResolutionAnalysis = new LookupMapResolutionAnalysis( |
| 486 reporter, compiler.frontendStrategy.elementEnvironment); | 465 reporter, compiler.frontendStrategy.elementEnvironment); |
| 487 | 466 |
| 488 noSuchMethodRegistry = new NoSuchMethodRegistry( | 467 noSuchMethodRegistry = new NoSuchMethodRegistry( |
| 489 commonElements, compiler.frontendStrategy.createNoSuchMethodResolver()); | 468 commonElements, compiler.frontendStrategy.createNoSuchMethodResolver()); |
| 490 kernelTask = new KernelTask(compiler); | 469 kernelTask = new KernelTask(compiler); |
| 491 patchResolverTask = new PatchResolverTask(compiler); | 470 patchResolverTask = new PatchResolverTask(compiler); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 517 /// Codegen support for generating table of interceptors and | 496 /// Codegen support for generating table of interceptors and |
| 518 /// constructors for custom elements. | 497 /// constructors for custom elements. |
| 519 CustomElementsCodegenAnalysis get customElementsCodegenAnalysis { | 498 CustomElementsCodegenAnalysis get customElementsCodegenAnalysis { |
| 520 assert( | 499 assert( |
| 521 _customElementsCodegenAnalysis != null, | 500 _customElementsCodegenAnalysis != null, |
| 522 failedAt(NO_LOCATION_SPANNABLE, | 501 failedAt(NO_LOCATION_SPANNABLE, |
| 523 "CustomElementsCodegenAnalysis has not been created yet.")); | 502 "CustomElementsCodegenAnalysis has not been created yet.")); |
| 524 return _customElementsCodegenAnalysis; | 503 return _customElementsCodegenAnalysis; |
| 525 } | 504 } |
| 526 | 505 |
| 527 NativeBasicData get nativeBasicData { | |
| 528 assert( | |
| 529 _nativeBasicData != null, | |
| 530 failedAt(NO_LOCATION_SPANNABLE, | |
| 531 "NativeBasicData has not been computed yet.")); | |
| 532 return _nativeBasicData; | |
| 533 } | |
| 534 | |
| 535 NativeBasicDataBuilder get nativeBasicDataBuilder => _nativeBasicDataBuilder; | |
| 536 | |
| 537 /// Resolution analysis for tracking reflective access to type variables. | |
| 538 TypeVariableResolutionAnalysis get typeVariableResolutionAnalysis { | |
| 539 assert( | |
| 540 _typeVariableCodegenAnalysis == null, | |
| 541 failedAt(NO_LOCATION_SPANNABLE, | |
| 542 "TypeVariableHandler has already been created.")); | |
| 543 return _typeVariableResolutionAnalysis; | |
| 544 } | |
| 545 | |
| 546 /// Codegen handler for reflective access to type variables. | 506 /// Codegen handler for reflective access to type variables. |
| 547 TypeVariableCodegenAnalysis get typeVariableCodegenAnalysis { | 507 TypeVariableCodegenAnalysis get typeVariableCodegenAnalysis { |
| 548 assert( | 508 assert( |
| 549 _typeVariableCodegenAnalysis != null, | 509 _typeVariableCodegenAnalysis != null, |
| 550 failedAt(NO_LOCATION_SPANNABLE, | 510 failedAt(NO_LOCATION_SPANNABLE, |
| 551 "TypeVariableHandler has not been created yet.")); | 511 "TypeVariableHandler has not been created yet.")); |
| 552 return _typeVariableCodegenAnalysis; | 512 return _typeVariableCodegenAnalysis; |
| 553 } | 513 } |
| 554 | 514 |
| 555 MirrorsData get mirrorsData => _mirrorsData; | 515 MirrorsData get mirrorsData => _mirrorsData; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 579 } | 539 } |
| 580 | 540 |
| 581 OneShotInterceptorData get oneShotInterceptorData { | 541 OneShotInterceptorData get oneShotInterceptorData { |
| 582 assert( | 542 assert( |
| 583 _oneShotInterceptorData != null, | 543 _oneShotInterceptorData != null, |
| 584 failedAt(NO_LOCATION_SPANNABLE, | 544 failedAt(NO_LOCATION_SPANNABLE, |
| 585 "OneShotInterceptorData has not been prepared yet.")); | 545 "OneShotInterceptorData has not been prepared yet.")); |
| 586 return _oneShotInterceptorData; | 546 return _oneShotInterceptorData; |
| 587 } | 547 } |
| 588 | 548 |
| 589 RuntimeTypesNeed get rtiNeed { | 549 RuntimeTypesChecksBuilder get rtiChecksBuilder { |
| 590 assert( | 550 assert( |
| 591 _rtiNeed != null, | 551 _rti != null, |
| 592 failedAt(NO_LOCATION_SPANNABLE, | 552 failedAt(NO_LOCATION_SPANNABLE, |
| 593 "RuntimeTypesNeed has not been computed yet.")); | 553 "RuntimeTypesChecksBuilder has not been created yet.")); |
| 594 return _rtiNeed; | |
| 595 } | |
| 596 | |
| 597 RuntimeTypesNeedBuilder get rtiNeedBuilder { | |
| 598 assert( | |
| 599 _rtiNeed == null, | |
| 600 failedAt(NO_LOCATION_SPANNABLE, | |
| 601 "RuntimeTypesNeed has already been computed.")); | |
| 602 return _rtiNeedBuilder; | |
| 603 } | |
| 604 | |
| 605 RuntimeTypesChecksBuilder get rtiChecksBuilder { | |
| 606 assert( | 554 assert( |
| 607 !_rti.rtiChecksBuilderClosed, | 555 !_rti.rtiChecksBuilderClosed, |
| 608 failedAt(NO_LOCATION_SPANNABLE, | 556 failedAt(NO_LOCATION_SPANNABLE, |
| 609 "RuntimeTypesChecks has already been computed.")); | 557 "RuntimeTypesChecks has already been computed.")); |
| 610 return _rti; | 558 return _rti; |
| 611 } | 559 } |
| 612 | 560 |
| 613 RuntimeTypesSubstitutions get rtiSubstitutions => _rti; | 561 RuntimeTypesSubstitutions get rtiSubstitutions { |
| 562 assert( |
| 563 _rti != null, |
| 564 failedAt(NO_LOCATION_SPANNABLE, |
| 565 "RuntimeTypesSubstitutions has not been created yet.")); |
| 566 return _rti; |
| 567 } |
| 614 | 568 |
| 615 RuntimeTypesEncoder get rtiEncoder { | 569 RuntimeTypesEncoder get rtiEncoder { |
| 616 assert( | 570 assert( |
| 617 _rtiEncoder != null, | 571 _rtiEncoder != null, |
| 618 failedAt(NO_LOCATION_SPANNABLE, | 572 failedAt(NO_LOCATION_SPANNABLE, |
| 619 "RuntimeTypesEncoder has not been created.")); | 573 "RuntimeTypesEncoder has not been created.")); |
| 620 return _rtiEncoder; | 574 return _rtiEncoder; |
| 621 } | 575 } |
| 622 | 576 |
| 623 CheckedModeHelpers get checkedModeHelpers => _checkedModeHelpers; | 577 CheckedModeHelpers get checkedModeHelpers => _checkedModeHelpers; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 | 673 |
| 720 validateInterceptorImplementsAllObjectMethods( | 674 validateInterceptorImplementsAllObjectMethods( |
| 721 frontendStrategy.commonElements.jsInterceptorClass); | 675 frontendStrategy.commonElements.jsInterceptorClass); |
| 722 // The null-interceptor must also implement *all* methods. | 676 // The null-interceptor must also implement *all* methods. |
| 723 validateInterceptorImplementsAllObjectMethods( | 677 validateInterceptorImplementsAllObjectMethods( |
| 724 frontendStrategy.commonElements.jsNullClass); | 678 frontendStrategy.commonElements.jsNullClass); |
| 725 } | 679 } |
| 726 | 680 |
| 727 /// Called when the resolution queue has been closed. | 681 /// Called when the resolution queue has been closed. |
| 728 void onResolutionEnd() { | 682 void onResolutionEnd() { |
| 729 frontendStrategy.annotationProcesser | 683 frontendStrategy.annotationProcesser.processJsInteropAnnotations( |
| 730 .processJsInteropAnnotations(nativeBasicData, nativeDataBuilder); | 684 frontendStrategy.nativeBasicData, nativeDataBuilder); |
| 731 } | 685 } |
| 732 | 686 |
| 733 /// Called when the closed world from resolution has been computed. | 687 /// Called when the closed world from resolution has been computed. |
| 734 void onResolutionClosedWorld( | 688 void onResolutionClosedWorld( |
| 735 ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) { | 689 ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) { |
| 736 for (MemberEntity entity | 690 for (MemberEntity entity |
| 737 in compiler.enqueuer.resolution.processedEntities) { | 691 in compiler.enqueuer.resolution.processedEntities) { |
| 738 processAnnotations(closedWorld.elementEnvironment, | 692 processAnnotations(closedWorld.elementEnvironment, |
| 739 closedWorld.commonElements, entity, closedWorldRefiner); | 693 closedWorld.commonElements, entity, closedWorldRefiner); |
| 740 } | 694 } |
| 741 mirrorsDataBuilder.computeMembersNeededForReflection( | 695 mirrorsDataBuilder.computeMembersNeededForReflection( |
| 742 compiler.enqueuer.resolution.worldBuilder, closedWorld); | 696 compiler.enqueuer.resolution.worldBuilder, closedWorld); |
| 743 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( | |
| 744 compiler.enqueuer.resolution.worldBuilder, | |
| 745 closedWorld, | |
| 746 compiler.frontendStrategy.dartTypes, | |
| 747 enableTypeAssertions: compiler.options.enableTypeAssertions); | |
| 748 mirrorsResolutionAnalysis.onResolutionComplete(); | 697 mirrorsResolutionAnalysis.onResolutionComplete(); |
| 749 } | 698 } |
| 750 | 699 |
| 751 void onTypeInferenceComplete(GlobalTypeInferenceResults results) { | 700 void onTypeInferenceComplete(GlobalTypeInferenceResults results) { |
| 752 noSuchMethodRegistry.onTypeInferenceComplete(results); | 701 noSuchMethodRegistry.onTypeInferenceComplete(results); |
| 753 } | 702 } |
| 754 | 703 |
| 755 /// Called when resolving a call to a foreign function. | 704 /// Called when resolving a call to a foreign function. |
| 756 native.NativeBehavior resolveForeignCall(Send node, Element element, | 705 native.NativeBehavior resolveForeignCall(Send node, Element element, |
| 757 CallStructure callStructure, ForeignResolver resolver) { | 706 CallStructure callStructure, ForeignResolver resolver) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 782 } | 731 } |
| 783 // No native behavior for this call. | 732 // No native behavior for this call. |
| 784 return null; | 733 return null; |
| 785 } | 734 } |
| 786 | 735 |
| 787 ResolutionEnqueuer createResolutionEnqueuer( | 736 ResolutionEnqueuer createResolutionEnqueuer( |
| 788 CompilerTask task, Compiler compiler) { | 737 CompilerTask task, Compiler compiler) { |
| 789 ElementEnvironment elementEnvironment = | 738 ElementEnvironment elementEnvironment = |
| 790 compiler.frontendStrategy.elementEnvironment; | 739 compiler.frontendStrategy.elementEnvironment; |
| 791 CommonElements commonElements = compiler.frontendStrategy.commonElements; | 740 CommonElements commonElements = compiler.frontendStrategy.commonElements; |
| 792 _nativeBasicData = nativeBasicDataBuilder.close(elementEnvironment); | 741 NativeBasicData nativeBasicData = compiler.frontendStrategy.nativeBasicData; |
| 742 RuntimeTypesNeedBuilder rtiNeedBuilder = |
| 743 compiler.frontendStrategy.createRuntimeTypesNeedBuilder(); |
| 744 BackendImpacts impacts = |
| 745 new BackendImpacts(compiler.options, commonElements); |
| 746 TypeVariableResolutionAnalysis typeVariableResolutionAnalysis = |
| 747 new TypeVariableResolutionAnalysis( |
| 748 compiler.frontendStrategy.elementEnvironment, |
| 749 impacts, |
| 750 _backendUsageBuilder); |
| 793 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer( | 751 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer( |
| 794 compiler.options, | 752 compiler.options, |
| 795 elementEnvironment, | 753 elementEnvironment, |
| 796 commonElements, | 754 commonElements, |
| 797 compiler.frontendStrategy.dartTypes, | 755 compiler.frontendStrategy.dartTypes, |
| 798 _backendUsageBuilder, | 756 _backendUsageBuilder, |
| 799 compiler.frontendStrategy.createNativeClassFinder(nativeBasicData)); | 757 compiler.frontendStrategy.createNativeClassFinder(nativeBasicData)); |
| 800 _nativeDataBuilder = new NativeDataBuilderImpl(nativeBasicData); | 758 _nativeDataBuilder = new NativeDataBuilderImpl(nativeBasicData); |
| 801 _customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis( | 759 _customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis( |
| 802 constantSystem, | 760 constantSystem, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 mirrorsResolutionAnalysis, | 799 mirrorsResolutionAnalysis, |
| 842 typeVariableResolutionAnalysis, | 800 typeVariableResolutionAnalysis, |
| 843 _nativeResolutionEnqueuer, | 801 _nativeResolutionEnqueuer, |
| 844 compiler.deferredLoadTask, | 802 compiler.deferredLoadTask, |
| 845 kernelTask), | 803 kernelTask), |
| 846 compiler.frontendStrategy.createResolutionWorldBuilder( | 804 compiler.frontendStrategy.createResolutionWorldBuilder( |
| 847 nativeBasicData, | 805 nativeBasicData, |
| 848 _nativeDataBuilder, | 806 _nativeDataBuilder, |
| 849 interceptorDataBuilder, | 807 interceptorDataBuilder, |
| 850 _backendUsageBuilder, | 808 _backendUsageBuilder, |
| 809 rtiNeedBuilder, |
| 810 _nativeResolutionEnqueuer, |
| 851 const OpenWorldStrategy()), | 811 const OpenWorldStrategy()), |
| 852 compiler.frontendStrategy.createResolutionWorkItemBuilder( | 812 compiler.frontendStrategy.createResolutionWorkItemBuilder( |
| 853 nativeBasicData, _nativeDataBuilder, impactTransformer)); | 813 nativeBasicData, _nativeDataBuilder, impactTransformer)); |
| 854 } | 814 } |
| 855 | 815 |
| 856 /// Creates an [Enqueuer] for code generation specific to this backend. | 816 /// Creates an [Enqueuer] for code generation specific to this backend. |
| 857 CodegenEnqueuer createCodegenEnqueuer( | 817 CodegenEnqueuer createCodegenEnqueuer( |
| 858 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { | 818 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { |
| 859 ElementEnvironment elementEnvironment = closedWorld.elementEnvironment; | 819 ElementEnvironment elementEnvironment = closedWorld.elementEnvironment; |
| 860 CommonElements commonElements = closedWorld.commonElements; | 820 CommonElements commonElements = closedWorld.commonElements; |
| 821 BackendImpacts impacts = |
| 822 new BackendImpacts(compiler.options, commonElements); |
| 861 _typeVariableCodegenAnalysis = new TypeVariableCodegenAnalysis( | 823 _typeVariableCodegenAnalysis = new TypeVariableCodegenAnalysis( |
| 862 closedWorld.elementEnvironment, this, commonElements, mirrorsData); | 824 closedWorld.elementEnvironment, this, commonElements, mirrorsData); |
| 863 _lookupMapAnalysis = new LookupMapAnalysis( | 825 _lookupMapAnalysis = new LookupMapAnalysis( |
| 864 reporter, | 826 reporter, |
| 865 constantSystem, | 827 constantSystem, |
| 866 constants, | 828 constants, |
| 867 elementEnvironment, | 829 elementEnvironment, |
| 868 commonElements, | 830 commonElements, |
| 869 lookupMapResolutionAnalysis); | 831 lookupMapResolutionAnalysis); |
| 870 _mirrorsCodegenAnalysis = mirrorsResolutionAnalysis.close(); | 832 _mirrorsCodegenAnalysis = mirrorsResolutionAnalysis.close(); |
| 871 _customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis( | 833 _customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis( |
| 872 constantSystem, commonElements, elementEnvironment, nativeBasicData); | 834 constantSystem, |
| 835 commonElements, |
| 836 elementEnvironment, |
| 837 closedWorld.nativeData); |
| 873 _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer( | 838 _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer( |
| 874 compiler.options, | 839 compiler.options, |
| 875 elementEnvironment, | 840 elementEnvironment, |
| 876 commonElements, | 841 commonElements, |
| 877 compiler.frontendStrategy.dartTypes, | 842 closedWorld.dartTypes, |
| 878 emitter, | 843 emitter, |
| 879 _nativeResolutionEnqueuer, | 844 closedWorld.liveNativeClasses, |
| 880 closedWorld.nativeData); | 845 closedWorld.nativeData); |
| 881 return new CodegenEnqueuer( | 846 return new CodegenEnqueuer( |
| 882 task, | 847 task, |
| 883 compiler.options, | 848 compiler.options, |
| 884 const TreeShakingEnqueuerStrategy(), | 849 const TreeShakingEnqueuerStrategy(), |
| 885 compiler.backendStrategy.createCodegenWorldBuilder( | 850 compiler.backendStrategy.createCodegenWorldBuilder( |
| 886 nativeBasicData, closedWorld, const TypeMaskStrategy()), | 851 closedWorld.nativeData, closedWorld, const TypeMaskStrategy()), |
| 887 compiler.backendStrategy.createCodegenWorkItemBuilder(closedWorld), | 852 compiler.backendStrategy.createCodegenWorkItemBuilder(closedWorld), |
| 888 new CodegenEnqueuerListener( | 853 new CodegenEnqueuerListener( |
| 889 elementEnvironment, | 854 elementEnvironment, |
| 890 commonElements, | 855 commonElements, |
| 891 impacts, | 856 impacts, |
| 892 closedWorld.backendUsage, | 857 closedWorld.backendUsage, |
| 893 rtiNeed, | 858 closedWorld.rtiNeed, |
| 894 customElementsCodegenAnalysis, | 859 customElementsCodegenAnalysis, |
| 895 typeVariableCodegenAnalysis, | 860 typeVariableCodegenAnalysis, |
| 896 lookupMapAnalysis, | 861 lookupMapAnalysis, |
| 897 mirrorsCodegenAnalysis, | 862 mirrorsCodegenAnalysis, |
| 898 nativeCodegenEnqueuer)); | 863 nativeCodegenEnqueuer)); |
| 899 } | 864 } |
| 900 | 865 |
| 901 WorldImpact codegen(CodegenWorkItem work, ClosedWorld closedWorld) { | 866 WorldImpact codegen(CodegenWorkItem work, ClosedWorld closedWorld) { |
| 902 MemberEntity element = work.element; | 867 MemberEntity element = work.element; |
| 903 if (compiler.elementHasCompileTimeError(element)) { | 868 if (compiler.elementHasCompileTimeError(element)) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 931 .transformCodegenImpact(work.registry.worldImpact); | 896 .transformCodegenImpact(work.registry.worldImpact); |
| 932 compiler.dumpInfoTask.registerImpact(element, worldImpact); | 897 compiler.dumpInfoTask.registerImpact(element, worldImpact); |
| 933 return worldImpact; | 898 return worldImpact; |
| 934 } | 899 } |
| 935 | 900 |
| 936 native.NativeResolutionEnqueuer get nativeResolutionEnqueuerForTesting => | 901 native.NativeResolutionEnqueuer get nativeResolutionEnqueuerForTesting => |
| 937 _nativeResolutionEnqueuer; | 902 _nativeResolutionEnqueuer; |
| 938 | 903 |
| 939 native.NativeEnqueuer get nativeCodegenEnqueuer => _nativeCodegenEnqueuer; | 904 native.NativeEnqueuer get nativeCodegenEnqueuer => _nativeCodegenEnqueuer; |
| 940 | 905 |
| 941 ClassElement defaultSuperclass( | 906 ClassElement defaultSuperclass(CommonElements commonElements, |
| 942 CommonElements commonElements, ClassElement element) { | 907 NativeBasicData nativeBasicData, ClassElement element) { |
| 943 if (nativeBasicData.isJsInteropClass(element)) { | 908 if (nativeBasicData.isJsInteropClass(element)) { |
| 944 return commonElements.jsJavaScriptObjectClass; | 909 return commonElements.jsJavaScriptObjectClass; |
| 945 } | 910 } |
| 946 // Native classes inherit from Interceptor. | 911 // Native classes inherit from Interceptor. |
| 947 return nativeBasicData.isNativeClass(element) | 912 return nativeBasicData.isNativeClass(element) |
| 948 ? commonElements.jsInterceptorClass | 913 ? commonElements.jsInterceptorClass |
| 949 : commonElements.objectClass; | 914 : commonElements.objectClass; |
| 950 } | 915 } |
| 951 | 916 |
| 952 /** | 917 /** |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 element == commonElements.jsUnmodifiableArrayClass; | 984 element == commonElements.jsUnmodifiableArrayClass; |
| 1020 } | 985 } |
| 1021 | 986 |
| 1022 /// This method is called immediately after the [library] and its parts have | 987 /// This method is called immediately after the [library] and its parts have |
| 1023 /// been loaded. | 988 /// been loaded. |
| 1024 void setAnnotations(LibraryEntity library) { | 989 void setAnnotations(LibraryEntity library) { |
| 1025 if (!compiler.serialization.isDeserialized(library)) { | 990 if (!compiler.serialization.isDeserialized(library)) { |
| 1026 AnnotationProcessor processor = | 991 AnnotationProcessor processor = |
| 1027 compiler.frontendStrategy.annotationProcesser; | 992 compiler.frontendStrategy.annotationProcesser; |
| 1028 if (canLibraryUseNative(library)) { | 993 if (canLibraryUseNative(library)) { |
| 1029 processor.extractNativeAnnotations(library, nativeBasicDataBuilder); | 994 processor.extractNativeAnnotations(library); |
| 1030 } | 995 } |
| 1031 processor.extractJsInteropAnnotations(library, nativeBasicDataBuilder); | 996 processor.extractJsInteropAnnotations(library); |
| 1032 } | 997 } |
| 1033 Uri uri = library.canonicalUri; | 998 Uri uri = library.canonicalUri; |
| 1034 if (uri == Uris.dart_html) { | 999 if (uri == Uris.dart_html) { |
| 1035 htmlLibraryIsLoaded = true; | 1000 htmlLibraryIsLoaded = true; |
| 1036 } else if (uri == LookupMapResolutionAnalysis.PACKAGE_LOOKUP_MAP) { | 1001 } else if (uri == LookupMapResolutionAnalysis.PACKAGE_LOOKUP_MAP) { |
| 1037 lookupMapResolutionAnalysis.init(library); | 1002 lookupMapResolutionAnalysis.init(library); |
| 1038 } | 1003 } |
| 1039 } | 1004 } |
| 1040 | 1005 |
| 1041 /// This method is called when all new libraries loaded through | 1006 /// This method is called when all new libraries loaded through |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1059 WorldImpact onCodegenStart(ClosedWorld closedWorld, | 1024 WorldImpact onCodegenStart(ClosedWorld closedWorld, |
| 1060 CodegenWorldBuilder codegenWorldBuilder, Sorter sorter) { | 1025 CodegenWorldBuilder codegenWorldBuilder, Sorter sorter) { |
| 1061 functionCompiler.onCodegenStart(); | 1026 functionCompiler.onCodegenStart(); |
| 1062 _oneShotInterceptorData = new OneShotInterceptorData( | 1027 _oneShotInterceptorData = new OneShotInterceptorData( |
| 1063 closedWorld.interceptorData, closedWorld.commonElements); | 1028 closedWorld.interceptorData, closedWorld.commonElements); |
| 1064 _namer = determineNamer(closedWorld, codegenWorldBuilder); | 1029 _namer = determineNamer(closedWorld, codegenWorldBuilder); |
| 1065 tracer = new Tracer(closedWorld, namer, compiler); | 1030 tracer = new Tracer(closedWorld, namer, compiler); |
| 1066 _rtiEncoder = _namer.rtiEncoder = new RuntimeTypesEncoderImpl( | 1031 _rtiEncoder = _namer.rtiEncoder = new RuntimeTypesEncoderImpl( |
| 1067 namer, closedWorld.elementEnvironment, closedWorld.commonElements); | 1032 namer, closedWorld.elementEnvironment, closedWorld.commonElements); |
| 1068 emitter.createEmitter(namer, closedWorld, codegenWorldBuilder, sorter); | 1033 emitter.createEmitter(namer, closedWorld, codegenWorldBuilder, sorter); |
| 1034 // TODO(johnniwinther): Share the impact object created in |
| 1035 // createCodegenEnqueuer. |
| 1036 BackendImpacts impacts = |
| 1037 new BackendImpacts(compiler.options, closedWorld.commonElements); |
| 1038 _rti = new RuntimeTypesImpl( |
| 1039 closedWorld.elementEnvironment, closedWorld.dartTypes); |
| 1069 _codegenImpactTransformer = new CodegenImpactTransformer( | 1040 _codegenImpactTransformer = new CodegenImpactTransformer( |
| 1070 compiler.options, | 1041 compiler.options, |
| 1071 closedWorld.elementEnvironment, | 1042 closedWorld.elementEnvironment, |
| 1072 closedWorld.commonElements, | 1043 closedWorld.commonElements, |
| 1073 impacts, | 1044 impacts, |
| 1074 checkedModeHelpers, | 1045 checkedModeHelpers, |
| 1075 closedWorld.nativeData, | 1046 closedWorld.nativeData, |
| 1076 closedWorld.backendUsage, | 1047 closedWorld.backendUsage, |
| 1077 rtiNeed, | 1048 closedWorld.rtiNeed, |
| 1078 nativeCodegenEnqueuer, | 1049 nativeCodegenEnqueuer, |
| 1079 namer, | 1050 namer, |
| 1080 oneShotInterceptorData, | 1051 oneShotInterceptorData, |
| 1081 lookupMapAnalysis, | 1052 lookupMapAnalysis, |
| 1082 rtiChecksBuilder); | 1053 rtiChecksBuilder); |
| 1083 return const WorldImpact(); | 1054 return const WorldImpact(); |
| 1084 } | 1055 } |
| 1085 | 1056 |
| 1086 /// Called when code generation has been completed. | 1057 /// Called when code generation has been completed. |
| 1087 void onCodegenEnd() { | 1058 void onCodegenEnd() { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 return _backend.resolveForeignCall(node, element, callStructure, resolver); | 1326 return _backend.resolveForeignCall(node, element, callStructure, resolver); |
| 1356 } | 1327 } |
| 1357 | 1328 |
| 1358 @override | 1329 @override |
| 1359 bool isDefaultNoSuchMethod(MethodElement element) { | 1330 bool isDefaultNoSuchMethod(MethodElement element) { |
| 1360 return _commonElements.isDefaultNoSuchMethodImplementation(element); | 1331 return _commonElements.isDefaultNoSuchMethodImplementation(element); |
| 1361 } | 1332 } |
| 1362 | 1333 |
| 1363 @override | 1334 @override |
| 1364 ClassElement defaultSuperclass(ClassElement element) { | 1335 ClassElement defaultSuperclass(ClassElement element) { |
| 1365 return _backend.defaultSuperclass(_commonElements, element); | 1336 return _backend.defaultSuperclass( |
| 1337 _commonElements, _backend.frontendStrategy.nativeBasicData, element); |
| 1366 } | 1338 } |
| 1367 | 1339 |
| 1368 @override | 1340 @override |
| 1369 bool isNativeClass(ClassEntity element) => | 1341 bool isNativeClass(ClassEntity element) => |
| 1370 _backend.nativeBasicData.isNativeClass(element); | 1342 _backend.compiler.frontendStrategy.nativeBasicData.isNativeClass(element); |
| 1371 | 1343 |
| 1372 @override | 1344 @override |
| 1373 bool isForeign(Element element) => | 1345 bool isForeign(Element element) => |
| 1374 _backend.isForeign(_commonElements, element); | 1346 _backend.isForeign(_commonElements, element); |
| 1375 } | 1347 } |
| 1376 | 1348 |
| 1377 class SuperMemberData { | 1349 class SuperMemberData { |
| 1378 /// A set of member that are called from subclasses via `super`. | 1350 /// A set of member that are called from subclasses via `super`. |
| 1379 final Set<MemberEntity> _aliasedSuperMembers = new Setlet<MemberEntity>(); | 1351 final Set<MemberEntity> _aliasedSuperMembers = new Setlet<MemberEntity>(); |
| 1380 | 1352 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1391 | 1363 |
| 1392 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { | 1364 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { |
| 1393 return !selector.isGetter; | 1365 return !selector.isGetter; |
| 1394 } | 1366 } |
| 1395 | 1367 |
| 1396 /// Returns `true` if [member] is called from a subclass via `super`. | 1368 /// Returns `true` if [member] is called from a subclass via `super`. |
| 1397 bool isAliasedSuperMember(MemberEntity member) { | 1369 bool isAliasedSuperMember(MemberEntity member) { |
| 1398 return _aliasedSuperMembers.contains(member); | 1370 return _aliasedSuperMembers.contains(member); |
| 1399 } | 1371 } |
| 1400 } | 1372 } |
| OLD | NEW |