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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 : new MinifyNamer(closedWorld, codegenWorldBuilder) | 660 : new MinifyNamer(closedWorld, codegenWorldBuilder) |
661 : new Namer(closedWorld, codegenWorldBuilder); | 661 : new Namer(closedWorld, codegenWorldBuilder); |
662 } | 662 } |
663 | 663 |
664 /// Returns true if global optimizations such as type inferencing can apply to | 664 /// Returns true if global optimizations such as type inferencing can apply to |
665 /// the field [element]. | 665 /// the field [element]. |
666 /// | 666 /// |
667 /// One category of elements that do not apply is runtime helpers that the | 667 /// One category of elements that do not apply is runtime helpers that the |
668 /// backend calls, but the optimizations don't see those calls. | 668 /// backend calls, but the optimizations don't see those calls. |
669 bool canFieldBeUsedForGlobalOptimizations( | 669 bool canFieldBeUsedForGlobalOptimizations( |
670 FieldElement element, ClosedWorld closedWorld) { | 670 FieldEntity element, ClosedWorld closedWorld) { |
671 return !closedWorld.backendUsage.isFieldUsedByBackend(element) && | 671 if (closedWorld.backendUsage.isFieldUsedByBackend(element)) { |
672 !mirrorsData.invokedReflectively(element); | 672 return false; |
| 673 } |
| 674 if ((element.isTopLevel || element.isStatic) && !element.isAssignable) { |
| 675 return true; |
| 676 } |
| 677 return !mirrorsData.isMemberAccessibleByReflection(element); |
673 } | 678 } |
674 | 679 |
675 /// Returns true if global optimizations such as type inferencing can apply to | 680 /// Returns true if global optimizations such as type inferencing can apply to |
676 /// the parameter [element]. | 681 /// the parameter [element]. |
677 /// | 682 /// |
678 /// One category of elements that do not apply is runtime helpers that the | 683 /// One category of elements that do not apply is runtime helpers that the |
679 /// backend calls, but the optimizations don't see those calls. | 684 /// backend calls, but the optimizations don't see those calls. |
680 bool canFunctionParametersBeUsedForGlobalOptimizations( | 685 bool canFunctionParametersBeUsedForGlobalOptimizations( |
681 FunctionElement element, ClosedWorld closedWorld) { | 686 FunctionEntity function, ClosedWorld closedWorld) { |
682 if (element.isLocal) return true; | 687 return !closedWorld.backendUsage.isFunctionUsedByBackend(function) && |
683 MethodElement method = element; | 688 !mirrorsData.isMemberAccessibleByReflection(function); |
684 return !closedWorld.backendUsage.isFunctionUsedByBackend(method) && | |
685 !mirrorsData.invokedReflectively(method); | |
686 } | 689 } |
687 | 690 |
688 bool operatorEqHandlesNullArgument(FunctionEntity operatorEqfunction) { | 691 bool operatorEqHandlesNullArgument(FunctionEntity operatorEqfunction) { |
689 return specialOperatorEqClasses.contains(operatorEqfunction.enclosingClass); | 692 return specialOperatorEqClasses.contains(operatorEqfunction.enclosingClass); |
690 } | 693 } |
691 | 694 |
692 void validateInterceptorImplementsAllObjectMethods( | 695 void validateInterceptorImplementsAllObjectMethods( |
693 ClassEntity interceptorClass) { | 696 ClassEntity interceptorClass) { |
694 if (interceptorClass == null) return; | 697 if (interceptorClass == null) return; |
695 ClassEntity objectClass = frontendStrategy.commonElements.objectClass; | 698 ClassEntity objectClass = frontendStrategy.commonElements.objectClass; |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 | 1402 |
1400 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { | 1403 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { |
1401 return !selector.isGetter; | 1404 return !selector.isGetter; |
1402 } | 1405 } |
1403 | 1406 |
1404 /// Returns `true` if [member] is called from a subclass via `super`. | 1407 /// Returns `true` if [member] is called from a subclass via `super`. |
1405 bool isAliasedSuperMember(MemberEntity member) { | 1408 bool isAliasedSuperMember(MemberEntity member) { |
1406 return _aliasedSuperMembers.contains(member); | 1409 return _aliasedSuperMembers.contains(member); |
1407 } | 1410 } |
1408 } | 1411 } |
OLD | NEW |