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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1160763002: dart2js cps: 'is'-check directly against type variables. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index 717bc066de9e57009f9b8ca12f1e1c682cae61b2..5fd20b7339aceed812f37551b75a812195266e85 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -2670,9 +2670,9 @@ class JsIrBuilder extends IrBuilder {
{bool isTypeTest}) {
assert(isOpen);
assert(isTypeTest != null);
+ // For type tests, we must treat specially the rare cases where `null`
karlklose 2015/05/28 07:42:30 Move comment back into the if branch? Also, the t
asgerf 2015/05/28 08:52:55 It should be clear that this is not an optimizatio
+ // satisfies the test (which otherwise never satisfies a type test).
if (isTypeTest) {
- // The TypeOperator node does not allow the Object, dynamic, and Null types,
- // because the null value satisfies them. These must be handled here.
if (type.isObject || type.isDynamic) {
// `x is Object` and `x is dynamic` are always true, even if x is null.
return buildBooleanConstant(true);
@@ -2682,10 +2682,11 @@ class JsIrBuilder extends IrBuilder {
return addPrimitive(new ir.Identical(value, buildNullConstant()));
}
}
- // Null cannot not satisfy the check. Use a standard subtype check.
List<ir.Primitive> typeArguments = const <ir.Primitive>[];
if (type is GenericType && type.typeArguments.isNotEmpty) {
typeArguments = type.typeArguments.map(buildTypeExpression).toList();
+ } else if (type is TypeVariableType) {
+ typeArguments = <ir.Primitive>[buildTypeVariableAccess(type)];
}
ir.Primitive check = _continueWithExpression(
(k) => new ir.TypeOperator(value,
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698