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

Unified Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 10078008: Fix folding of == when a type defines operator=. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/optimize.dart
===================================================================
--- lib/compiler/implementation/ssa/optimize.dart (revision 6728)
+++ lib/compiler/implementation/ssa/optimize.dart (working copy)
@@ -245,6 +245,27 @@
return visitInvokeBinary(node);
}
+ if (left.isNonPrimitive()) {
+ HNonPrimitiveType type = left.propagatedType;
+ Element element = type.lookupMember(Namer.OPERATOR_EQUALS);
+ if (element !== null) {
+ // If the left-hand side is guaranteed to be a non-primitive
+ // type and and it defines operator==, we emit a call to that
+ // operator.
+ return visitInvokeBinary(node);
+ } else if (right.isConstantNull()) {
+ return graph.addConstantBool(false);
+ } else {
+ // We can just emit an identity check because the type does
+ // not implement operator=.
+ // TODO(floitsch): cache interceptors.
+ HStatic target = new HStatic(
+ compiler.builder.interceptors.getTripleEqualsInterceptor());
+ return new HIdentity(target, left, right);
+ }
+ }
+
+
if (right.isConstantNull()) {
if (left.propagatedType.isUseful()) {
return graph.addConstantBool(false);
@@ -257,20 +278,6 @@
}
}
- if (left.isNonPrimitive()) {
- // If the left-hand side is guaranteed to be a non-primitive
- // type and and it does not define operator==, we can just emit
- // an identity check.
- HNonPrimitiveType type = left.propagatedType;
- Element element = type.lookupMember(Namer.OPERATOR_EQUALS);
- if (element === null) {
- // TODO(floitsch): cache interceptors.
- HStatic target = new HStatic(
- compiler.builder.interceptors.getTripleEqualsInterceptor());
- return new HIdentity(target, left, right);
- }
- }
-
// All other cases are dealt with by the [visitInvokeBinary].
return visitInvokeBinary(node);
}
« 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