Index: pkg/compiler/lib/src/ssa/builder_kernel.dart |
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
index 46e5002e6ae86963495bff2853fb7693b56f8c43..ef30c202237a5269965c9cfc1b75f8c8e8c988ab 100644 |
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
@@ -1498,6 +1498,30 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
// TODO(het): Decide when to inline |
@override |
void visitMethodInvocation(ir.MethodInvocation invocation) { |
+ // Handle `x == null` specially. |
Emily Fortuna
2016/11/29 20:57:45
can you elaborate in this comment why x == null is
sra1
2016/11/29 23:07:18
Done.
|
+ if (invocation.name.name == '==') { |
+ ir.Arguments arguments = invocation.arguments; |
+ if (arguments.types.isEmpty && |
+ arguments.positional.length == 1 && |
+ arguments.named.isEmpty) { |
+ void finishCheckNull(ir.Expression comparand) { |
+ comparand.accept(this); |
+ pushCheckNull(pop()); |
+ } |
+ |
+ ir.Expression receiver = invocation.receiver; |
+ ir.Expression argument = arguments.positional.first; |
+ if (argument is ir.NullLiteral) { |
+ finishCheckNull(receiver); |
+ return; |
+ } |
+ if (receiver is ir.NullLiteral) { |
+ finishCheckNull(argument); |
+ return; |
+ } |
+ } |
Emily Fortuna
2016/11/29 20:57:45
consider making this code block its own function j
sra1
2016/11/29 23:07:18
Done.
|
+ } |
+ |
invocation.receiver.accept(this); |
HInstruction receiver = pop(); |