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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index e8f43caacde74554686dbbd4aa6dc6a1f375e545..e04aa6c8a991b49aea15f26be89224a53ecfd80c 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -736,6 +736,56 @@ class JavaScriptBackend extends Backend {
@override
bool isNative(Element element) => nativeData.isNative(element);
+ /// Returns the [NativeBehavior] for calling the native [method].
+ native.NativeBehavior getNativeMethodBehavior(FunctionElement method) {
+ return nativeData.getNativeMethodBehavior(method);
+ }
+
+ /// Returns the [NativeBehavior] for reading from the native [field].
+ native.NativeBehavior getNativeFieldLoadBehavior(FieldElement field) {
+ return nativeData.getNativeFieldLoadBehavior(field);
+ }
+
+ /// Returns the [NativeBehavior] for writing to the native [field].
+ native.NativeBehavior getNativeFieldStoreBehavior(FieldElement field) {
+ return nativeData.getNativeFieldStoreBehavior(field);
+ }
+
+ @override
+ void resolveNativeElement(Element element, NativeRegistry registry) {
+ if (element.isFunction ||
+ element.isConstructor ||
+ element.isGetter ||
+ element.isSetter) {
+ compiler.enqueuer.resolution.nativeEnqueuer
+ .handleMethodAnnotations(element);
+ if (isNative(element)) {
+ native.NativeBehavior behavior =
+ native.NativeBehavior.ofMethod(element, compiler);
+ nativeData.setNativeMethodBehavior(element, behavior);
+ registry.registerNativeData(behavior);
+ }
+ } else if (element.isField) {
+ compiler.enqueuer.resolution.nativeEnqueuer
+ .handleFieldAnnotations(element);
+ if (isNative(element)) {
+ native.NativeBehavior fieldLoadBehavior =
+ native.NativeBehavior.ofFieldLoad(element, compiler);
+ native.NativeBehavior fieldStoreBehavior =
+ native.NativeBehavior.ofFieldStore(element, compiler);
+ nativeData.setNativeFieldLoadBehavior(element, fieldLoadBehavior);
+ nativeData.setNativeFieldStoreBehavior(element, fieldStoreBehavior);
+
+ // TODO(sra): Process fields for storing separately.
+ // We have to handle both loading and storing to the field because we
+ // only get one look at each member and there might be a load or store
+ // we have not seen yet.
+ registry.registerNativeData(fieldLoadBehavior);
+ registry.registerNativeData(fieldStoreBehavior);
+ }
+ }
+ }
+
bool isNativeOrExtendsNative(ClassElement element) {
if (element == null) return false;
if (isNative(element) || isJsInterop(element)) {
« 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