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

Side by Side Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 10697068: Change dart2js to follow the new spec on the equality operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 interface OptimizationPhase { 5 interface OptimizationPhase {
6 String get name(); 6 String get name();
7 void visitGraph(HGraph graph); 7 void visitGraph(HGraph graph);
8 } 8 }
9 9
10 class SsaOptimizerTask extends CompilerTask { 10 class SsaOptimizerTask extends CompilerTask {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } else { 453 } else {
454 // We can just emit an identity check because the type does 454 // We can just emit an identity check because the type does
455 // not implement operator=. 455 // not implement operator=.
456 return foldBuiltinEqualsCheck(node); 456 return foldBuiltinEqualsCheck(node);
457 } 457 }
458 } 458 }
459 459
460 if (right.isConstantNull()) { 460 if (right.isConstantNull()) {
461 if (left.propagatedType.isPrimitive()) { 461 if (left.propagatedType.isPrimitive()) {
462 return graph.addConstantBool(false); 462 return graph.addConstantBool(false);
463 } else {
464 // TODO(floitsch): cache interceptors.
465 Interceptors interceptors = backend.builder.interceptors;
466 Element equalsElement = interceptors.getEqualsInterceptor();
467 // If we have a different element than [equalsElement], we
468 // don't need to optimize this instruction to use another
469 // element: we know the element is either eqNull or eqNullB.
470 if (node.element === equalsElement) {
471 Element targetElement = interceptors.getEqualsNullInterceptor();
472 bool onlyUsedInBoolify = allUsersAreBoolifies(node);
473 if (onlyUsedInBoolify) {
474 targetElement = interceptors.getBoolifiedVersionOf(targetElement);
475 }
476 HStatic target = new HStatic(targetElement);
477 node.block.addBefore(node, target);
478 HEquals result = new HEquals(target, node.left, node.right);
479 if (onlyUsedInBoolify) {
480 result.usesBoolifiedInterceptor = true;
481 result.propagatedType = HType.BOOLEAN;
482 }
483 return result;
484 }
485 } 463 }
486 } 464 }
487 465
488 // All other cases are dealt with by the [visitRelational] and 466 // All other cases are dealt with by the [visitRelational] and
489 // [visitInvokeBinary], which are visited by invoking the [super]'s 467 // [visitInvokeBinary], which are visited by invoking the [super]'s
490 // visit method. 468 // visit method.
491 return super.visitEquals(node); 469 return super.visitEquals(node);
492 } 470 }
493 471
494 HInstruction visitTypeGuard(HTypeGuard node) { 472 HInstruction visitTypeGuard(HTypeGuard node) {
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 break; 1245 break;
1268 default: 1246 default:
1269 assert(false); 1247 assert(false);
1270 break; 1248 break;
1271 } 1249 }
1272 } 1250 }
1273 } 1251 }
1274 } 1252 }
1275 1253
1276 } 1254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698