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

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

Issue 2045223002: Compute and cache element NativeBehavior during resolution. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Temporarily skip compilation subtest Created 4 years, 6 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 part of js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 @override 729 @override
730 bool isJsInterop(Element element) => nativeData.isJsInterop(element); 730 bool isJsInterop(Element element) => nativeData.isJsInterop(element);
731 731
732 /// Whether [element] corresponds to a native JavaScript construct either 732 /// Whether [element] corresponds to a native JavaScript construct either
733 /// through the native mechanism (`@Native(...)` or the `native` pseudo 733 /// through the native mechanism (`@Native(...)` or the `native` pseudo
734 /// keyword) which is only allowed for internal libraries or via the typed 734 /// keyword) which is only allowed for internal libraries or via the typed
735 /// JavaScriptInterop mechanism which is allowed for user libraries. 735 /// JavaScriptInterop mechanism which is allowed for user libraries.
736 @override 736 @override
737 bool isNative(Element element) => nativeData.isNative(element); 737 bool isNative(Element element) => nativeData.isNative(element);
738 738
739 /// Returns the [NativeBehavior] for calling the native [method].
740 native.NativeBehavior getNativeMethodBehavior(FunctionElement method) {
741 return nativeData.getNativeMethodBehavior(method);
742 }
743
744 /// Returns the [NativeBehavior] for reading from the native [field].
745 native.NativeBehavior getNativeFieldLoadBehavior(FieldElement field) {
746 return nativeData.getNativeFieldLoadBehavior(field);
747 }
748
749 /// Returns the [NativeBehavior] for writing to the native [field].
750 native.NativeBehavior getNativeFieldStoreBehavior(FieldElement field) {
751 return nativeData.getNativeFieldStoreBehavior(field);
752 }
753
754 @override
755 void resolveNativeElement(Element element, NativeRegistry registry) {
756 if (element.isFunction ||
757 element.isConstructor ||
758 element.isGetter ||
759 element.isSetter) {
760 compiler.enqueuer.resolution.nativeEnqueuer
761 .handleMethodAnnotations(element);
762 if (isNative(element)) {
763 native.NativeBehavior behavior =
764 native.NativeBehavior.ofMethod(element, compiler);
765 nativeData.setNativeMethodBehavior(element, behavior);
766 registry.registerNativeData(behavior);
767 }
768 } else if (element.isField) {
769 compiler.enqueuer.resolution.nativeEnqueuer
770 .handleFieldAnnotations(element);
771 if (isNative(element)) {
772 native.NativeBehavior fieldLoadBehavior =
773 native.NativeBehavior.ofFieldLoad(element, compiler);
774 native.NativeBehavior fieldStoreBehavior =
775 native.NativeBehavior.ofFieldStore(element, compiler);
776 nativeData.setNativeFieldLoadBehavior(element, fieldLoadBehavior);
777 nativeData.setNativeFieldStoreBehavior(element, fieldStoreBehavior);
778
779 // TODO(sra): Process fields for storing separately.
780 // We have to handle both loading and storing to the field because we
781 // only get one look at each member and there might be a load or store
782 // we have not seen yet.
783 registry.registerNativeData(fieldLoadBehavior);
784 registry.registerNativeData(fieldStoreBehavior);
785 }
786 }
787 }
788
739 bool isNativeOrExtendsNative(ClassElement element) { 789 bool isNativeOrExtendsNative(ClassElement element) {
740 if (element == null) return false; 790 if (element == null) return false;
741 if (isNative(element) || isJsInterop(element)) { 791 if (isNative(element) || isJsInterop(element)) {
742 return true; 792 return true;
743 } 793 }
744 assert(element.isResolved); 794 assert(element.isResolved);
745 return isNativeOrExtendsNative(element.superclass); 795 return isNativeOrExtendsNative(element.superclass);
746 } 796 }
747 797
748 bool isInterceptedMethod(Element element) { 798 bool isInterceptedMethod(Element element) {
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 3075
3026 @override 3076 @override
3027 void onImpactUsed(ImpactUseCase impactUse) { 3077 void onImpactUsed(ImpactUseCase impactUse) {
3028 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { 3078 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) {
3029 // TODO(johnniwinther): Allow emptying when serialization has been 3079 // TODO(johnniwinther): Allow emptying when serialization has been
3030 // performed. 3080 // performed.
3031 resolution.emptyCache(); 3081 resolution.emptyCache();
3032 } 3082 }
3033 } 3083 }
3034 } 3084 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698