Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class SsaOptimizerTask extends CompilerTask { | 5 class SsaOptimizerTask extends CompilerTask { |
| 6 SsaOptimizerTask(Compiler compiler) : super(compiler); | 6 SsaOptimizerTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA optimizer'; | 7 String get name() => 'SSA optimizer'; |
| 8 | 8 |
| 9 void optimize(HGraph graph) { | 9 void optimize(HGraph graph) { |
| 10 measure(() { | 10 measure(() { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 HInstruction visitInvokeUnary(HInvokeUnary node) => node.fold(); | 82 HInstruction visitInvokeUnary(HInvokeUnary node) => node.fold(); |
| 83 HInstruction visitInvokeInterceptor(HInvokeInterceptor node) | 83 HInstruction visitInvokeInterceptor(HInvokeInterceptor node) |
| 84 => node.fold(); | 84 => node.fold(); |
| 85 | 85 |
| 86 HInstruction visitAdd(HAdd node) { | 86 HInstruction visitAdd(HAdd node) { |
| 87 // String + is defined for all literals. We don't need to know which | 87 // String + is defined for all literals. We don't need to know which |
| 88 // literal type the right-hand side is. | 88 // literal type the right-hand side is. |
| 89 // TODO(floitsch): is String + literal a compile-time expression? If not | 89 // TODO(floitsch): is String + literal a compile-time expression? If not |
| 90 // we must pay attention not to canonicalize the concatenated string with | 90 // we must pay attention not to canonicalize the concatenated string with |
| 91 // an already existing string. | 91 // an already existing string. |
| 92 if (node.left.isLiteralString() && node.right is HLiteral) { | 92 if (node.left.isString() && node.right is HLiteral) { |
|
karlklose
2012/01/06 09:58:38
Remove accidental edit.
Lasse Reichstein
2012/01/06 10:01:07
Done.
| |
| 93 // TODO(lrn): Perform concatenation in Dart. | 93 // TODO(lrn): Perform concatenation in Dart. |
| 94 } | 94 } |
| 95 return visitInvokeBinary(node); | 95 return visitInvokeBinary(node); |
| 96 } | 96 } |
| 97 | 97 |
| 98 HInstruction visitEquals(HEquals node) { | 98 HInstruction visitEquals(HEquals node) { |
| 99 if (node.left is HLiteral && node.right is HLiteral) { | 99 if (node.left is HLiteral && node.right is HLiteral) { |
| 100 HLiteral op1 = node.left; | 100 HLiteral op1 = node.left; |
| 101 HLiteral op2 = node.right; | 101 HLiteral op2 = node.right; |
| 102 return new HLiteral(op1.value == op2.value, HType.BOOLEAN); | 102 if (op1.isLiteralString()) { |
| 103 if (op2.isLiteralString() && op1.value.definitlyEquals(op2.value)) { | |
| 104 return new HLiteral(true, HType.BOOLEAN); | |
| 105 } | |
| 106 } else { | |
| 107 return new HLiteral(op1.value == op2.value, HType.BOOLEAN); | |
| 108 } | |
| 103 } | 109 } |
| 104 return node; | 110 return node; |
| 105 } | 111 } |
| 106 | 112 |
| 107 HInstruction visitTypeGuard(HTypeGuard node) { | 113 HInstruction visitTypeGuard(HTypeGuard node) { |
| 108 HInstruction value = node.inputs[0]; | 114 HInstruction value = node.inputs[0]; |
| 109 return (value.type.combine(node.type) == value.type) ? value : node; | 115 return (value.type.combine(node.type) == value.type) ? value : node; |
| 110 } | 116 } |
| 111 | 117 |
| 112 HInstruction visitIntegerCheck(HIntegerCheck node) { | 118 HInstruction visitIntegerCheck(HIntegerCheck node) { |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 } | 638 } |
| 633 } | 639 } |
| 634 if (!canBeMoved) continue; | 640 if (!canBeMoved) continue; |
| 635 | 641 |
| 636 // This is safe because we are running after GVN. | 642 // This is safe because we are running after GVN. |
| 637 // TODO(ngeoffray): ensure GVN has been run. | 643 // TODO(ngeoffray): ensure GVN has been run. |
| 638 set_.add(current); | 644 set_.add(current); |
| 639 } | 645 } |
| 640 } | 646 } |
| 641 } | 647 } |
| OLD | NEW |