Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
index 4f14f5064533f0250cdcdaea653d49c14863a715..bd98b6bc0f4473e696e7dba1acd0f7939d23bf0f 100644 |
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
@@ -255,6 +255,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
} |
void preGenerateMethod(HGraph graph) { |
+ new SsaInstructionSelection(compiler).visitGraph(graph); |
new SsaTypeKnownRemover().visitGraph(graph); |
new SsaInstructionMerger(generateAtUseSite, compiler).visitGraph(graph); |
new SsaConditionMerger( |
@@ -1199,10 +1200,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
} |
} |
- void emitIdentityComparison(HInstruction left, |
- HInstruction right, |
- bool inverse) { |
- String op = singleIdentityComparison(left, right, compiler); |
+ void emitIdentityComparison(HIdentity instruction, bool inverse) { |
+ String op = instruction.singleComparisonOp; |
+ HInstruction left = instruction.left; |
+ HInstruction right = instruction.right; |
if (op != null) { |
use(left); |
js.Expression jsLeft = pop(); |
@@ -1227,7 +1228,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
} |
visitIdentity(HIdentity node) { |
- emitIdentityComparison(node.left, node.right, false); |
+ emitIdentityComparison(node, false); |
} |
visitAdd(HAdd node) => visitInvokeBinary(node, '+'); |
@@ -1812,11 +1813,12 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
handledBySpecialCase = true; |
if (input is HIs) { |
emitIs(input, '!=='); |
+ } else if (input is HIsViaInterceptor) { |
+ emitIsViaInterceptor(input, true); |
} else if (input is HNot) { |
use(input.inputs[0]); |
} else if (input is HIdentity) { |
- HIdentity identity = input; |
- emitIdentityComparison(identity.left, identity.right, true); |
+ emitIdentityComparison(input, true); |
} else if (input is HBoolify) { |
use(input.inputs[0]); |
push(new js.Binary("!==", pop(), newLiteralBool(true)), input); |
@@ -2240,13 +2242,17 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
return; |
} |
if (interceptor != null) { |
- use(interceptor); |
+ checkTypeViaProperty(interceptor, type, negative); |
} else { |
- use(input); |
+ checkTypeViaProperty(input, type, negative); |
} |
+ } |
+ void checkTypeViaProperty(HInstruction input, DartType type, bool negative) { |
world.registerIsCheck(type, work.resolutionTree); |
+ use(input); |
+ |
js.PropertyAccess field = |
new js.PropertyAccess.field(pop(), backend.namer.operatorIsType(type)); |
// We always negate at least once so that the result is boolified. |
@@ -2319,6 +2325,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
emitIs(node, "==="); |
} |
+ void visitIsViaInterceptor(HIsViaInterceptor node) { |
+ emitIsViaInterceptor(node, false); |
+ } |
+ |
void emitIs(HIs node, String relation) { |
DartType type = node.typeExpression; |
world.registerIsCheck(type, work.resolutionTree); |
@@ -2398,6 +2408,11 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
} |
} |
+ void emitIsViaInterceptor(HIsViaInterceptor node, bool negative) { |
+ checkTypeViaProperty(node.interceptor, node.typeExpression, negative); |
+ attachLocationToLast(node); |
+ } |
+ |
js.Expression generateTest(HInstruction input, TypeMask checkedType) { |
TypeMask receiver = input.instructionType; |
// Figure out if it is beneficial to turn this into a null check. |
@@ -2651,20 +2666,3 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
return backend.namer.elementAccess(helper); |
} |
} |
- |
-String singleIdentityComparison(HInstruction left, |
- HInstruction right, |
- Compiler compiler) { |
- // Returns the single identity comparison (== or ===) or null if a more |
- // complex expression is required. |
- if (left.canBeNull() && right.canBeNull()) { |
- if (left.isConstantNull() || right.isConstantNull() || |
- (left.isPrimitive(compiler) && |
- left.instructionType == right.instructionType)) { |
- return '=='; |
- } |
- return null; |
- } else { |
- return '==='; |
- } |
-} |