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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 50313007: Implement dynamic function checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r30897. Created 7 years 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: dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index 384ca4e161031bab157385ace6a22772f855362e..9644ba2e92e2dc5d54413abbe35cd57160b9e11d 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -89,36 +89,6 @@ class SubtypeCheckedModeHelper extends CheckedModeHelper {
}
}
-class FunctionTypeCheckedModeHelper extends CheckedModeHelper {
- const FunctionTypeCheckedModeHelper(String name) : super(name);
-
- void generateAdditionalArguments(SsaCodeGenerator codegen,
- HTypeConversion node,
- List<jsAst.Expression> arguments) {
- DartType type = node.typeExpression;
- String signatureName = codegen.backend.namer.getFunctionTypeName(type);
- arguments.add(js.string(signatureName));
-
- if (type.containsTypeVariables) {
- ClassElement contextClass = Types.getClassContext(type);
- // TODO(ahe): Creating a string here is unfortunate. It is slow (due to
- // string concatenation in the implementation), and may prevent
- // segmentation of '$'.
- String contextName = codegen.backend.namer.getNameForRti(contextClass);
- arguments.add(js.string(contextName));
-
- if (node.contextIsTypeArguments) {
- arguments.add(new jsAst.LiteralNull());
- codegen.use(node.context);
- arguments.add(codegen.pop());
- } else {
- codegen.use(node.context);
- arguments.add(codegen.pop());
- }
- }
- }
-}
-
/*
* Invariants:
* canInline(function) implies canInline(function, insideLoop:true)
@@ -397,8 +367,6 @@ class JavaScriptBackend extends Backend {
const SubtypeCheckedModeHelper('assertSubtype'),
const TypeVariableCheckedModeHelper('subtypeOfRuntimeTypeCast'),
const TypeVariableCheckedModeHelper('assertSubtypeOfRuntimeType'),
- const FunctionTypeCheckedModeHelper('functionSubtypeCast'),
- const FunctionTypeCheckedModeHelper('assertFunctionSubtype'),
const PropertyCheckedModeHelper('propertyTypeCast'),
const PropertyCheckedModeHelper('propertyTypeCheck') ];
@@ -1066,7 +1034,8 @@ class JavaScriptBackend extends Backend {
enqueueClass(world, compiler.listClass, elements);
}
if (type is FunctionType) {
- enqueueInResolution(getCheckFunctionSubtype(), elements);
+ enqueueInResolution(
+ compiler.findHelper('functionTypeTestMetaHelper'), elements);
}
if (type.element.isNative()) {
// We will neeed to add the "$is" and "$as" properties on the
@@ -1484,9 +1453,7 @@ class JavaScriptBackend extends Backend {
? 'subtypeOfRuntimeTypeCast'
: 'assertSubtypeOfRuntimeType';
} else if (type.kind == TypeKind.FUNCTION) {
- return typeCast
- ? 'functionSubtypeCast'
- : 'assertFunctionSubtype';
+ return null;
} else {
if (nativeCheck) {
// TODO(karlklose): can we get rid of this branch when we use
@@ -1621,10 +1588,6 @@ class JavaScriptBackend extends Backend {
return compiler.findHelper('assertSubtypeOfRuntimeType');
}
- Element getCheckFunctionSubtype() {
- return compiler.findHelper('checkFunctionSubtype');
- }
-
Element getThrowNoSuchMethod() {
return compiler.findHelper('throwNoSuchMethod');
}

Powered by Google App Engine
This is Rietveld 408576698