| OLD | NEW |
| 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 Loading... |
| 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 } |
| 463 } | 485 } |
| 464 } | 486 } |
| 465 | 487 |
| 466 // All other cases are dealt with by the [visitRelational] and | 488 // All other cases are dealt with by the [visitRelational] and |
| 467 // [visitInvokeBinary], which are visited by invoking the [super]'s | 489 // [visitInvokeBinary], which are visited by invoking the [super]'s |
| 468 // visit method. | 490 // visit method. |
| 469 return super.visitEquals(node); | 491 return super.visitEquals(node); |
| 470 } | 492 } |
| 471 | 493 |
| 472 HInstruction visitTypeGuard(HTypeGuard node) { | 494 HInstruction visitTypeGuard(HTypeGuard node) { |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 break; | 1267 break; |
| 1246 default: | 1268 default: |
| 1247 assert(false); | 1269 assert(false); |
| 1248 break; | 1270 break; |
| 1249 } | 1271 } |
| 1250 } | 1272 } |
| 1251 } | 1273 } |
| 1252 } | 1274 } |
| 1253 | 1275 |
| 1254 } | 1276 } |
| OLD | NEW |