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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2535323002: Recognise x.==(null) and generate HIdentical (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698