Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
index 37e3b148248397ebd0b30e7fa551511e12bea678..cc3b312f01ccdd27e38cd8b857a18adb88c15326 100644 |
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
@@ -1627,8 +1627,10 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
HInstruction original, DartType type, |
{ int kind: HTypeConversion.CHECKED_MODE_CHECK }) { |
if (!compiler.enableTypeAssertions) return original; |
+ type = type.unalias(compiler); |
HInstruction other = original.convertType(compiler, type, kind); |
if (other != original) add(other); |
+ compiler.enqueuer.codegen.registerIsCheck(type, work.resolutionTree); |
return other; |
} |
@@ -2231,6 +2233,12 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
compiler.functionClass.computeType(compiler), |
compiler); |
push(new HForeignNew(closureClassElement, type, capturedVariables)); |
+ |
+ Element methodElement = nestedClosureData.closureElement; |
+ if (compiler.backend.methodNeedsRti(methodElement)) { |
+ compiler.backend.registerGenericClosure( |
+ methodElement, compiler.enqueuer.codegen, work.resolutionTree); |
+ } |
} |
visitFunctionDeclaration(FunctionDeclaration node) { |
@@ -2609,7 +2617,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
} |
} |
- visitOperatorSend(node) { |
+ visitOperatorSend(Send node) { |
Operator op = node.selector; |
if (const SourceString("[]") == op.source) { |
visitDynamicSend(node); |
@@ -2654,6 +2662,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
isNot = true; |
} |
DartType type = elements.getType(typeAnnotation); |
+ type = type.unalias(compiler); |
if (type.isMalformed) { |
String reasons = Types.fetchReasonsFromMalformedType(type); |
if (compiler.enableTypeAssertions) { |
@@ -2665,7 +2674,39 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
} |
HInstruction instruction; |
- if (type.kind == TypeKind.TYPE_VARIABLE) { |
+ if (type.kind == TypeKind.FUNCTION) { |
+ Element checkFunctionSubtype = backend.getCheckFunctionSubtype(); |
+ HInstruction isFuncSubtypeCall = new HStatic(checkFunctionSubtype); |
+ add(isFuncSubtypeCall); |
+ |
+ HInstruction signatureName = graph.addConstantString( |
+ new DartString.literal(backend.namer.getFunctionTypeName(type)), |
+ node, constantSystem); |
+ |
+ HInstruction context; |
+ HInstruction contextName; |
+ if (type.containsTypeVariables) { |
+ context = localsHandler.readThis(); |
+ |
+ ClassElement contextClass = Types.getClassContext(type); |
+ contextName = graph.addConstantString( |
+ new DartString.literal(backend.namer.getName(contextClass)), |
+ node, constantSystem); |
+ } else { |
+ context = graph.addConstantNull(constantSystem); |
+ contextName = graph.addConstantNull(constantSystem); |
+ } |
+ |
+ List<HInstruction> inputs = <HInstruction>[isFuncSubtypeCall, |
+ expression, |
+ signatureName, |
+ context, |
+ contextName]; |
+ HInstruction call = new HInvokeStatic(inputs, HType.UNKNOWN); |
+ add(call); |
+ instruction = new HIs(type, <HInstruction>[expression, call], |
+ HIs.COMPOUND_CHECK); |
+ } else if (type.kind == TypeKind.TYPE_VARIABLE) { |
HInstruction runtimeType = addTypeVariableReference(type); |
Element helper = backend.getGetObjectIsSubtype(); |
HInstruction helperCall = new HStatic(helper); |
@@ -3041,6 +3082,28 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
stack.add(addConstantString(node, backend.namer.operatorIsPrefix())); |
} else if (name == const SourceString('JS_OPERATOR_AS_PREFIX')) { |
stack.add(addConstantString(node, backend.namer.operatorAsPrefix())); |
+ } else if (name == const SourceString('JS_SIGNATURE_NAME')) { |
+ stack.add(addConstantString(node, backend.namer.operatorSignature())); |
+ } else if (name == const SourceString('JS_FUNCTION_TYPE_TAG')) { |
+ stack.add(addConstantString(node, backend.namer.functionTypeTag())); |
+ } else if (name == const SourceString('JS_FUNCTION_TYPE_VOID_RETURN_TAG')) { |
+ stack.add(addConstantString(node, |
+ backend.namer.functionTypeVoidReturnTag())); |
+ } else if (name == const SourceString('JS_FUNCTION_TYPE_RETURN_TYPE_TAG')) { |
+ stack.add(addConstantString(node, |
+ backend.namer.functionTypeReturnTypeTag())); |
+ } else if (name == |
+ const SourceString('JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG')) { |
+ stack.add(addConstantString(node, |
+ backend.namer.functionTypeRequiredParametersTag())); |
+ } else if (name == |
+ const SourceString('JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG')) { |
+ stack.add(addConstantString(node, |
+ backend.namer.functionTypeOptionalParametersTag())); |
+ } else if (name == |
+ const SourceString('JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG')) { |
+ stack.add(addConstantString(node, |
+ backend.namer.functionTypeNamedParametersTag())); |
} else if (name == const SourceString('JS_DART_OBJECT_CONSTRUCTOR')) { |
handleForeignDartObjectJsConstructorFunction(node); |
} else { |