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

Unified Diff: sdk/lib/_internal/compiler/implementation/enqueue.dart

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle function types in checked mode. Created 7 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: sdk/lib/_internal/compiler/implementation/enqueue.dart
diff --git a/sdk/lib/_internal/compiler/implementation/enqueue.dart b/sdk/lib/_internal/compiler/implementation/enqueue.dart
index 116036ada62ed5f336f7cdc495a37c95470b12a5..5188f9c3b1741343dae444966a6c182fa202931d 100644
--- a/sdk/lib/_internal/compiler/implementation/enqueue.dart
+++ b/sdk/lib/_internal/compiler/implementation/enqueue.dart
@@ -129,7 +129,7 @@ abstract class Enqueuer {
if (element.isGetter() && element.name == Compiler.RUNTIME_TYPE) {
compiler.enabledRuntimeType = true;
// TODO(ahe): Record precise dependency here.
- compiler.backend.registerRuntimeType(compiler.globalDependencies);
+ compiler.backend.registerRuntimeType(this, compiler.globalDependencies);
} else if (element == compiler.functionApplyMethod) {
compiler.enabledFunctionApply = true;
} else if (element == compiler.invokeOnMethod) {
@@ -252,10 +252,21 @@ abstract class Enqueuer {
if (member.name == Compiler.NO_SUCH_METHOD) {
enableNoSuchMethod(member);
}
+ if (member.name == Compiler.CALL_OPERATOR_NAME) {
+ if (!cls.typeVariables.isEmpty) {
+ registerGenericCallMethod(member, compiler.globalDependencies);
+ }
+ }
+ if (universe.hasInvocation(member, compiler)) {
+ return addToWorkList(member);
+ }
// If there is a property access with the same name as a method we
// need to emit the method.
if (universe.hasInvokedGetter(member, compiler)) {
- // We will emit a closure, so make sure the bound closure class is
+ if (!cls.typeVariables.isEmpty) {
+ registerGenericClosure(member, compiler.globalDependencies);
+ }
+ // We will emit a closure, so make sure the closure class is
// generated.
registerInstantiatedClass(compiler.boundClosureClass,
// Precise dependency is not important here.
@@ -411,11 +422,12 @@ abstract class Enqueuer {
String memberName = n.slowToString();
Link<Element> members = map[memberName];
if (members != null) {
+ map[memberName] = const Link<Element>();
LinkBuilder<Element> remaining = new LinkBuilder<Element>();
for (; !members.isEmpty; members = members.tail) {
if (!f(members.head)) remaining.addLast(members.head);
}
- map[memberName] = remaining.toLink();
+ map[memberName] = remaining.toLink(map[memberName]);
}
}
@@ -430,6 +442,11 @@ abstract class Enqueuer {
void handleUnseenSelector(SourceString methodName, Selector selector) {
processInstanceMembers(methodName, (Element member) {
if (selector.appliesUnnamed(member, compiler)) {
+ if (member.isFunction() && selector.isGetter()) {
+ if (!member.getEnclosingClass().typeVariables.isEmpty) {
+ registerGenericClosure(member, compiler.globalDependencies);
+ }
+ }
if (member.isField() && member.getEnclosingClass().isNative()) {
if (selector.isGetter() || selector.isCall()) {
nativeEnqueuer.registerFieldLoad(member);
@@ -540,12 +557,15 @@ abstract class Enqueuer {
}
void registerIsCheck(DartType type, TreeElements elements) {
+ type = type.unalias(compiler);
// Even in checked mode, type annotations for return type and argument
// types do not imply type checks, so there should never be a check
// against the type variable of a typedef.
assert(type.kind != TypeKind.TYPE_VARIABLE ||
!type.element.enclosingElement.isTypedef());
- universe.isChecks.add(type);
+ if (!type.isMalformed) {
+ universe.isChecks.add(type);
+ }
compiler.backend.registerIsCheck(type, this, elements);
}
@@ -563,6 +583,16 @@ abstract class Enqueuer {
compiler.backend.registerAsCheck(type, elements);
}
+ void registerGenericCallMethod(Element element, TreeElements elements) {
+ compiler.backend.registerGenericCallMethod(element, this, elements);
+ universe.genericCallMethods.add(element);
+ }
+
+ void registerGenericClosure(Element element, TreeElements elements) {
+ compiler.backend.registerGenericClosure(element, this, elements);
+ universe.closurizedGenericMembers.add(element);
+ }
+
void forEach(f(WorkItem work));
void forEachPostProcessTask(f(PostProcessTask work)) {}

Powered by Google App Engine
This is Rietveld 408576698