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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1153603006: dart2js cps: Type casts and related changes to type propagation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Another typo in SExpression unstrngifier Created 5 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index b852418c70ef4530cc69fdb509c7f6935e16895b..9a05a589e8227ad157530bf829e44da0241278ef 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -355,23 +355,21 @@ class CodeGenerator extends tree_ir.StatementVisitor
js.Expression visitTypeOperator(tree_ir.TypeOperator node) {
js.Expression value = visitExpression(node.value);
List<js.Expression> typeArguments = visitExpressionList(node.typeArguments);
- if (!node.isTypeTest) {
- giveup(node, 'type casts not implemented.');
- }
DartType type = node.type;
- // Note that the trivial (but special) cases of Object, dynamic, and Null
- // are handled at build-time and must not occur in a TypeOperator.
- assert(!type.isObject && !type.isDynamic);
if (type is InterfaceType) {
glue.registerIsCheck(type, registry);
ClassElement clazz = type.element;
- // We use the helper:
+ // We use one of the two helpers:
//
// checkSubtype(value, $isT, typeArgs, $asT)
+ // subtypeCast(value, $isT, typeArgs, $asT)
//
// Any of the last two arguments may be null if there are no type
// arguments, and/or if no substitution is required.
+ Element function = node.isTypeTest
+ ? glue.getCheckSubtype()
+ : glue.getSubtypeCast();
js.Expression isT = js.string(glue.getTypeTestTag(type));
@@ -384,14 +382,20 @@ class CodeGenerator extends tree_ir.StatementVisitor
: new js.LiteralNull();
return buildStaticHelperInvocation(
- glue.getCheckSubtype(),
+ function,
<js.Expression>[value, isT, typeArgumentArray, asT]);
} else if (type is TypeVariableType) {
glue.registerIsCheck(type, registry);
+
+ Element function = node.isTypeTest
+ ? glue.getCheckSubtypeOfRuntimeType()
+ : glue.getSubtypeOfRuntimeTypeCast();
+
// The only type argument is the type held in the type variable.
js.Expression typeValue = typeArguments.single;
+
return buildStaticHelperInvocation(
- glue.getCheckSubtypeOfRuntime(),
+ function,
<js.Expression>[value, typeValue]);
}
return giveup(node, 'type check unimplemented for $type.');
@@ -547,6 +551,12 @@ class CodeGenerator extends tree_ir.StatementVisitor
}
@override
+ void visitUnreachable(tree_ir.Unreachable node) {
+ // Output nothing.
+ // TODO(asgerf): Emit a throw/return to assist local analysis in the VM?
+ }
+
+ @override
void visitTry(tree_ir.Try node) {
js.Block tryBlock = buildBodyBlock(node.tryBody);
tree_ir.Variable exceptionVariable = node.catchParameters.first;
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698