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

Unified Diff: pkg/compiler/lib/src/js_emitter/native_emitter.dart

Issue 878553002: dart2js: native classes go through the normal code path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_emitter/native_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/native_emitter.dart b/pkg/compiler/lib/src/js_emitter/native_emitter.dart
index 90c2521709fde9aa2b7a585df74830bd489bb1fe..34a604d598f13e5fd9e442a451f3dfb43f9cbf02 100644
--- a/pkg/compiler/lib/src/js_emitter/native_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/native_emitter.dart
@@ -43,7 +43,7 @@ class NativeEmitter {
}
/**
- * Prepares native classes for emission. Returns the reduced list of classes.
+ * Prepares native classes for emission. Returns the unneeded classes.
herhut 2015/01/26 14:58:08 Why is this better? Do you expect that this set is
floitsch 2015/01/26 17:57:50 I think it's smaller, but more importantly it's a
*
* Removes trivial classes (that can be represented by a super type) and
* generates properties that have to be added to classes (native or not).
@@ -60,22 +60,21 @@ class NativeEmitter {
* improves performance when more classes can be treated as leaves.
*
* [classes] contains native classes, mixin applications, and user subclasses
- * of native classes. *Only* the native classes are returned. The order of
- * the returned classes is unchanged. (That is, the returned output might
- * just have classes removed).
+ * of native classes.
*
* [allAdditionalProperties] is used to collect properties that are pushed up
* from the above optimizations onto a non-native class, e.g, `Interceptor`.
*/
- List<Class> prepareNativeClasses(
+ Set<Class> prepareNativeClasses(
List<Class> classes,
Map<Class, Map<String, jsAst.Expression>> allAdditionalProperties) {
- // Compute a pre-order traversal of the subclass forest. We actually want a
- // post-order traversal but it is easier to compute the pre-order and use it
- // in reverse.
+ assert(classes.every((Class cls) => cls != null));
herhut 2015/01/26 14:58:08 Why is this needed?
floitsch 2015/01/26 17:57:50 If the mapping from classElement to Class fails in
herhut 2015/01/27 09:50:29 I was just curious how this could happen.
hasNativeClasses = classes.isNotEmpty;
+ // Compute a pre-order traversal of the subclass forest. We actually want a
+ // post-order traversal but it is easier to compute the pre-order and use it
+ // in reverse.
List<Class> preOrder = <Class>[];
Set<Class> seen = new Set<Class>();
@@ -229,8 +228,8 @@ class NativeEmitter {
//assert(!classElement.hasBackendMembers);
return classes
- .where((Class cls) => cls.isNative && neededClasses.contains(cls))
- .toList();
+ .where((Class cls) => cls.isNative && !neededClasses.contains(cls))
+ .toSet();
}
/**
@@ -278,12 +277,6 @@ class NativeEmitter {
!cls.fields.any(needsAccessor);
}
- void finishGenerateNativeClasses() {
- // TODO(sra): Put specialized version of getNativeMethods on
- // `Object.prototype` to avoid checking in `getInterceptor` and
- // specializations.
- }
-
void potentiallyConvertDartClosuresToJs(
List<jsAst.Statement> statements,
FunctionElement member,

Powered by Google App Engine
This is Rietveld 408576698