| 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 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // operator. | 254 // operator. |
| 255 return visitInvokeBinary(node); | 255 return visitInvokeBinary(node); |
| 256 } else if (right.isConstantNull()) { | 256 } else if (right.isConstantNull()) { |
| 257 return graph.addConstantBool(false); | 257 return graph.addConstantBool(false); |
| 258 } else { | 258 } else { |
| 259 // We can just emit an identity check because the type does | 259 // We can just emit an identity check because the type does |
| 260 // not implement operator=. | 260 // not implement operator=. |
| 261 // TODO(floitsch): cache interceptors. | 261 // TODO(floitsch): cache interceptors. |
| 262 HStatic target = new HStatic( | 262 HStatic target = new HStatic( |
| 263 compiler.builder.interceptors.getTripleEqualsInterceptor()); | 263 compiler.builder.interceptors.getTripleEqualsInterceptor()); |
| 264 node.block.addBefore(node, target); |
| 264 return new HIdentity(target, left, right); | 265 return new HIdentity(target, left, right); |
| 265 } | 266 } |
| 266 } | 267 } |
| 267 | 268 |
| 268 | 269 |
| 269 if (right.isConstantNull()) { | 270 if (right.isConstantNull()) { |
| 270 if (left.propagatedType.isUseful()) { | 271 if (left.propagatedType.isUseful()) { |
| 271 return graph.addConstantBool(false); | 272 return graph.addConstantBool(false); |
| 272 } else { | 273 } else { |
| 273 // TODO(floitsch): cache interceptors. | 274 // TODO(floitsch): cache interceptors. |
| 274 HStatic target = new HStatic( | 275 HStatic target = new HStatic( |
| 275 compiler.builder.interceptors.getEqualsNullInterceptor()); | 276 compiler.builder.interceptors.getEqualsNullInterceptor()); |
| 276 node.block.addBefore(node,target); | 277 node.block.addBefore(node, target); |
| 277 return new HEquals(target, node.left, node.right); | 278 return new HEquals(target, node.left, node.right); |
| 278 } | 279 } |
| 279 } | 280 } |
| 280 | 281 |
| 281 // All other cases are dealt with by the [visitInvokeBinary]. | 282 // All other cases are dealt with by the [visitInvokeBinary]. |
| 282 return visitInvokeBinary(node); | 283 return visitInvokeBinary(node); |
| 283 } | 284 } |
| 284 | 285 |
| 285 HInstruction visitTypeGuard(HTypeGuard node) { | 286 HInstruction visitTypeGuard(HTypeGuard node) { |
| 286 HInstruction value = node.guarded; | 287 HInstruction value = node.guarded; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 } | 812 } |
| 812 } | 813 } |
| 813 if (!canBeMoved) continue; | 814 if (!canBeMoved) continue; |
| 814 | 815 |
| 815 // This is safe because we are running after GVN. | 816 // This is safe because we are running after GVN. |
| 816 // TODO(ngeoffray): ensure GVN has been run. | 817 // TODO(ngeoffray): ensure GVN has been run. |
| 817 set_.add(current); | 818 set_.add(current); |
| 818 } | 819 } |
| 819 } | 820 } |
| 820 } | 821 } |
| OLD | NEW |