| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // Note that we still have to call [super] to make sure that we end up | 391 // Note that we still have to call [super] to make sure that we end up |
| 392 // in the remaining optimizations. | 392 // in the remaining optimizations. |
| 393 return super.visitRelational(node); | 393 return super.visitRelational(node); |
| 394 } | 394 } |
| 395 | 395 |
| 396 HInstruction handleIdentityCheck(HInvokeBinary node) { | 396 HInstruction handleIdentityCheck(HInvokeBinary node) { |
| 397 HInstruction left = node.left; | 397 HInstruction left = node.left; |
| 398 HInstruction right = node.right; | 398 HInstruction right = node.right; |
| 399 HType leftType = types[left]; | 399 HType leftType = types[left]; |
| 400 HType rightType = types[right]; | 400 HType rightType = types[right]; |
| 401 assert(!leftType.isConflicting() && !rightType.isConflicting()); | |
| 402 | 401 |
| 403 // We don't optimize on numbers to preserve the runtime semantics. | 402 // We don't optimize on numbers to preserve the runtime semantics. |
| 404 if (!(left.isNumberOrNull(types) && right.isNumberOrNull(types)) && | 403 if (!(left.isNumberOrNull(types) && right.isNumberOrNull(types)) && |
| 405 leftType.intersection(rightType, compiler).isConflicting()) { | 404 leftType.intersection(rightType, compiler).isConflicting()) { |
| 406 return graph.addConstantBool(false, constantSystem); | 405 return graph.addConstantBool(false, constantSystem); |
| 407 } | 406 } |
| 408 | 407 |
| 409 if (left.isConstantBoolean() && right.isBoolean(types)) { | 408 if (left.isConstantBoolean() && right.isBoolean(types)) { |
| 410 HConstant constant = left; | 409 HConstant constant = left; |
| 411 if (constant.constant.isTrue()) { | 410 if (constant.constant.isTrue()) { |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 SsaDeadCodeEliminator(this.types); | 744 SsaDeadCodeEliminator(this.types); |
| 746 | 745 |
| 747 bool isDeadCode(HInstruction instruction) { | 746 bool isDeadCode(HInstruction instruction) { |
| 748 return !instruction.hasSideEffects(types) | 747 return !instruction.hasSideEffects(types) |
| 749 && instruction.usedBy.isEmpty | 748 && instruction.usedBy.isEmpty |
| 750 // A dynamic getter that has no side effect can still throw | 749 // A dynamic getter that has no side effect can still throw |
| 751 // a NoSuchMethodError or a NullPointerException. | 750 // a NoSuchMethodError or a NullPointerException. |
| 752 && instruction is !HInvokeDynamicGetter | 751 && instruction is !HInvokeDynamicGetter |
| 753 && instruction is !HCheck | 752 && instruction is !HCheck |
| 754 && instruction is !HTypeGuard | 753 && instruction is !HTypeGuard |
| 754 && instruction is !HParameterValue |
| 755 && !instruction.isControlFlow(); | 755 && !instruction.isControlFlow(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void visitGraph(HGraph graph) { | 758 void visitGraph(HGraph graph) { |
| 759 visitPostDominatorTree(graph); | 759 visitPostDominatorTree(graph); |
| 760 } | 760 } |
| 761 | 761 |
| 762 void visitBasicBlock(HBasicBlock block) { | 762 void visitBasicBlock(HBasicBlock block) { |
| 763 HInstruction instruction = block.last; | 763 HInstruction instruction = block.last; |
| 764 while (instruction != null) { | 764 while (instruction != null) { |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 // For other fields having setters in the generative constructor body, set | 1352 // For other fields having setters in the generative constructor body, set |
| 1353 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1353 // the type to UNKNOWN to avoid relying on the type set in the initializer |
| 1354 // list. | 1354 // list. |
| 1355 allSetters.forEach((Element element) { | 1355 allSetters.forEach((Element element) { |
| 1356 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1356 backend.registerFieldConstructor(element, HType.UNKNOWN); |
| 1357 }); | 1357 }); |
| 1358 } | 1358 } |
| 1359 } | 1359 } |
| OLD | NEW |