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

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

Issue 2609063002: Further reduce use of Element in codegen. (Closed)
Patch Set: Created 3 years, 11 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 '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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 new Set<ClassElement>(); 402 new Set<ClassElement>();
403 403
404 /** 404 /**
405 * Set of classes whose `operator ==` methods handle `null` themselves. 405 * Set of classes whose `operator ==` methods handle `null` themselves.
406 */ 406 */
407 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); 407 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>();
408 408
409 /** 409 /**
410 * A set of members that are called from subclasses via `super`. 410 * A set of members that are called from subclasses via `super`.
411 */ 411 */
412 final Set<FunctionElement> aliasedSuperMembers = 412 final Set<MethodElement> aliasedSuperMembers = new Setlet<MethodElement>();
413 new Setlet<FunctionElement>();
414 413
415 List<CompilerTask> get tasks { 414 List<CompilerTask> get tasks {
416 List<CompilerTask> result = functionCompiler.tasks; 415 List<CompilerTask> result = functionCompiler.tasks;
417 result.add(emitter); 416 result.add(emitter);
418 result.add(patchResolverTask); 417 result.add(patchResolverTask);
419 result.add(kernelTask); 418 result.add(kernelTask);
420 return result; 419 return result;
421 } 420 }
422 421
423 final RuntimeTypes rti; 422 final RuntimeTypes rti;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 if (!oneShotInterceptors.containsKey(name)) { 749 if (!oneShotInterceptors.containsKey(name)) {
751 registerSpecializedGetInterceptor(classes); 750 registerSpecializedGetInterceptor(classes);
752 oneShotInterceptors[name] = selector; 751 oneShotInterceptors[name] = selector;
753 } 752 }
754 return name; 753 return name;
755 } 754 }
756 755
757 /** 756 /**
758 * Record that [method] is called from a subclass via `super`. 757 * Record that [method] is called from a subclass via `super`.
759 */ 758 */
760 bool maybeRegisterAliasedSuperMember(Element member, Selector selector) { 759 bool maybeRegisterAliasedSuperMember(
760 MemberElement member, Selector selector) {
761 if (!canUseAliasedSuperMember(member, selector)) { 761 if (!canUseAliasedSuperMember(member, selector)) {
762 // Invoking a super getter isn't supported, this would require changes to 762 // Invoking a super getter isn't supported, this would require changes to
763 // compact field descriptors in the emitter. 763 // compact field descriptors in the emitter.
764 // We also turn off this optimization in incremental compilation, to 764 // We also turn off this optimization in incremental compilation, to
765 // avoid having to regenerate a method just because someone started 765 // avoid having to regenerate a method just because someone started
766 // calling it through super. 766 // calling it through super.
767 return false; 767 return false;
768 } 768 }
769 aliasedSuperMembers.add(member); 769 aliasedSuperMembers.add(member);
770 return true; 770 return true;
(...skipping 12 matching lines...) Expand all
783 783
784 /// Returns `true` if [element] is part of JsInterop. 784 /// Returns `true` if [element] is part of JsInterop.
785 @override 785 @override
786 bool isJsInterop(Element element) => nativeData.isJsInterop(element); 786 bool isJsInterop(Element element) => nativeData.isJsInterop(element);
787 787
788 /// Whether [element] corresponds to a native JavaScript construct either 788 /// Whether [element] corresponds to a native JavaScript construct either
789 /// through the native mechanism (`@Native(...)` or the `native` pseudo 789 /// through the native mechanism (`@Native(...)` or the `native` pseudo
790 /// keyword) which is only allowed for internal libraries or via the typed 790 /// keyword) which is only allowed for internal libraries or via the typed
791 /// JavaScriptInterop mechanism which is allowed for user libraries. 791 /// JavaScriptInterop mechanism which is allowed for user libraries.
792 @override 792 @override
793 bool isNative(Element element) => nativeData.isNative(element); 793 bool isNative(Entity element) => nativeData.isNative(element);
794 794
795 /// Returns the [NativeBehavior] for calling the native [method]. 795 /// Returns the [NativeBehavior] for calling the native [method].
796 native.NativeBehavior getNativeMethodBehavior(FunctionElement method) { 796 native.NativeBehavior getNativeMethodBehavior(FunctionElement method) {
797 return nativeData.getNativeMethodBehavior(method); 797 return nativeData.getNativeMethodBehavior(method);
798 } 798 }
799 799
800 /// Returns the [NativeBehavior] for reading from the native [field]. 800 /// Returns the [NativeBehavior] for reading from the native [field].
801 native.NativeBehavior getNativeFieldLoadBehavior(FieldElement field) { 801 native.NativeBehavior getNativeFieldLoadBehavior(FieldElement field) {
802 return nativeData.getNativeFieldLoadBehavior(field); 802 return nativeData.getNativeFieldLoadBehavior(field);
803 } 803 }
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 element == commonElements.boolClass) { 1658 element == commonElements.boolClass) {
1659 if (nativeCheckOnly) return null; 1659 if (nativeCheckOnly) return null;
1660 return typeCast ? 'boolTypeCast' : 'boolTypeCheck'; 1660 return typeCast ? 'boolTypeCast' : 'boolTypeCheck';
1661 } else if (element == helpers.jsIntClass || 1661 } else if (element == helpers.jsIntClass ||
1662 element == commonElements.intClass || 1662 element == commonElements.intClass ||
1663 element == helpers.jsUInt32Class || 1663 element == helpers.jsUInt32Class ||
1664 element == helpers.jsUInt31Class || 1664 element == helpers.jsUInt31Class ||
1665 element == helpers.jsPositiveIntClass) { 1665 element == helpers.jsPositiveIntClass) {
1666 if (nativeCheckOnly) return null; 1666 if (nativeCheckOnly) return null;
1667 return typeCast ? 'intTypeCast' : 'intTypeCheck'; 1667 return typeCast ? 'intTypeCast' : 'intTypeCheck';
1668 } else if (Elements.isNumberOrStringSupertype(element, commonElements)) { 1668 } else if (commonElements.isNumberOrStringSupertype(element)) {
1669 if (nativeCheck) { 1669 if (nativeCheck) {
1670 return typeCast 1670 return typeCast
1671 ? 'numberOrStringSuperNativeTypeCast' 1671 ? 'numberOrStringSuperNativeTypeCast'
1672 : 'numberOrStringSuperNativeTypeCheck'; 1672 : 'numberOrStringSuperNativeTypeCheck';
1673 } else { 1673 } else {
1674 return typeCast 1674 return typeCast
1675 ? 'numberOrStringSuperTypeCast' 1675 ? 'numberOrStringSuperTypeCast'
1676 : 'numberOrStringSuperTypeCheck'; 1676 : 'numberOrStringSuperTypeCheck';
1677 } 1677 }
1678 } else if (Elements.isStringOnlySupertype(element, commonElements)) { 1678 } else if (commonElements.isStringOnlySupertype(element)) {
1679 if (nativeCheck) { 1679 if (nativeCheck) {
1680 return typeCast 1680 return typeCast
1681 ? 'stringSuperNativeTypeCast' 1681 ? 'stringSuperNativeTypeCast'
1682 : 'stringSuperNativeTypeCheck'; 1682 : 'stringSuperNativeTypeCheck';
1683 } else { 1683 } else {
1684 return typeCast ? 'stringSuperTypeCast' : 'stringSuperTypeCheck'; 1684 return typeCast ? 'stringSuperTypeCast' : 'stringSuperTypeCheck';
1685 } 1685 }
1686 } else if ((element == commonElements.listClass || 1686 } else if ((element == commonElements.listClass ||
1687 element == helpers.jsArrayClass) && 1687 element == helpers.jsArrayClass) &&
1688 type.treatAsRaw) { 1688 type.treatAsRaw) {
1689 if (nativeCheckOnly) return null; 1689 if (nativeCheckOnly) return null;
1690 return typeCast ? 'listTypeCast' : 'listTypeCheck'; 1690 return typeCast ? 'listTypeCast' : 'listTypeCheck';
1691 } else { 1691 } else {
1692 if (Elements.isListSupertype(element, commonElements)) { 1692 if (commonElements.isListSupertype(element)) {
1693 if (nativeCheck) { 1693 if (nativeCheck) {
1694 return typeCast 1694 return typeCast
1695 ? 'listSuperNativeTypeCast' 1695 ? 'listSuperNativeTypeCast'
1696 : 'listSuperNativeTypeCheck'; 1696 : 'listSuperNativeTypeCheck';
1697 } else { 1697 } else {
1698 return typeCast ? 'listSuperTypeCast' : 'listSuperTypeCheck'; 1698 return typeCast ? 'listSuperTypeCast' : 'listSuperTypeCheck';
1699 } 1699 }
1700 } else { 1700 } else {
1701 if (type.isInterfaceType && !type.treatAsRaw) { 1701 if (type.isInterfaceType && !type.treatAsRaw) {
1702 return typeCast ? 'subtypeCast' : 'assertSubtype'; 1702 return typeCast ? 'subtypeCast' : 'assertSubtype';
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 @override 3268 @override
3269 bool isInterceptorClass(ClassElement cls) { 3269 bool isInterceptorClass(ClassElement cls) {
3270 return helpers.backend.isInterceptorClass(cls); 3270 return helpers.backend.isInterceptorClass(cls);
3271 } 3271 }
3272 3272
3273 @override 3273 @override
3274 bool isNative(Element element) { 3274 bool isNative(Element element) {
3275 return helpers.backend.isNative(element); 3275 return helpers.backend.isNative(element);
3276 } 3276 }
3277 } 3277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698