| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 return visitInvokeBinary(node); | 339 return visitInvokeBinary(node); |
| 340 } | 340 } |
| 341 | 341 |
| 342 HInstruction visitTypeGuard(HTypeGuard node) { | 342 HInstruction visitTypeGuard(HTypeGuard node) { |
| 343 HInstruction value = node.guarded; | 343 HInstruction value = node.guarded; |
| 344 HType combinedType = value.propagatedType.combine(node.guardedType); | 344 HType combinedType = value.propagatedType.combine(node.guardedType); |
| 345 return (combinedType == value.propagatedType) ? value : node; | 345 return (combinedType == value.propagatedType) ? value : node; |
| 346 } | 346 } |
| 347 | 347 |
| 348 HInstruction visitIs(HIs node) { | 348 HInstruction visitIs(HIs node) { |
| 349 Type type = node.typeName; | 349 Type type = node.typeExpression; |
| 350 Element element = type.element; | 350 Element element = type.element; |
| 351 if (element.kind === ElementKind.TYPE_VARIABLE) { | 351 if (element.kind === ElementKind.TYPE_VARIABLE) { |
| 352 compiler.unimplemented("visitIs for type variables"); | 352 compiler.unimplemented("visitIs for type variables"); |
| 353 } | 353 } |
| 354 | 354 |
| 355 HType expressionType = node.expression.propagatedType; | 355 HType expressionType = node.expression.propagatedType; |
| 356 if (element === compiler.objectClass | 356 if (element === compiler.objectClass |
| 357 || element === compiler.dynamicClass) { | 357 || element === compiler.dynamicClass) { |
| 358 return graph.addConstantBool(true); | 358 return graph.addConstantBool(true); |
| 359 } else if (expressionType.isInteger()) { | 359 } else if (expressionType.isInteger()) { |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 } | 863 } |
| 864 } | 864 } |
| 865 if (!canBeMoved) continue; | 865 if (!canBeMoved) continue; |
| 866 | 866 |
| 867 // This is safe because we are running after GVN. | 867 // This is safe because we are running after GVN. |
| 868 // TODO(ngeoffray): ensure GVN has been run. | 868 // TODO(ngeoffray): ensure GVN has been run. |
| 869 set_.add(current); | 869 set_.add(current); |
| 870 } | 870 } |
| 871 } | 871 } |
| 872 } | 872 } |
| OLD | NEW |