| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 451 |
| 452 HInstruction visitTypeGuard(HTypeGuard node) { | 452 HInstruction visitTypeGuard(HTypeGuard node) { |
| 453 HInstruction value = node.guarded; | 453 HInstruction value = node.guarded; |
| 454 // If the union of the types is still the guarded type than the incoming | 454 // If the union of the types is still the guarded type than the incoming |
| 455 // type was a subtype of the guarded type, and no check is required. | 455 // type was a subtype of the guarded type, and no check is required. |
| 456 HType combinedType = value.propagatedType.union(node.guardedType); | 456 HType combinedType = value.propagatedType.union(node.guardedType); |
| 457 return (combinedType == value.propagatedType) ? value : node; | 457 return (combinedType == value.propagatedType) ? value : node; |
| 458 } | 458 } |
| 459 | 459 |
| 460 HInstruction visitIs(HIs node) { | 460 HInstruction visitIs(HIs node) { |
| 461 Type type = node.typeName; | 461 Type type = node.typeExpression; |
| 462 Element element = type.element; | 462 Element element = type.element; |
| 463 if (element.kind === ElementKind.TYPE_VARIABLE) { | 463 if (element.kind === ElementKind.TYPE_VARIABLE) { |
| 464 compiler.unimplemented("visitIs for type variables"); | 464 compiler.unimplemented("visitIs for type variables"); |
| 465 } | 465 } |
| 466 | 466 |
| 467 HType expressionType = node.expression.propagatedType; | 467 HType expressionType = node.expression.propagatedType; |
| 468 if (element === compiler.objectClass | 468 if (element === compiler.objectClass |
| 469 || element === compiler.dynamicClass) { | 469 || element === compiler.dynamicClass) { |
| 470 return graph.addConstantBool(true); | 470 return graph.addConstantBool(true); |
| 471 } else if (expressionType.isInteger()) { | 471 } else if (expressionType.isInteger()) { |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 if (!canBeMoved) continue; | 977 if (!canBeMoved) continue; |
| 978 | 978 |
| 979 // This is safe because we are running after GVN. | 979 // This is safe because we are running after GVN. |
| 980 // TODO(ngeoffray): ensure GVN has been run. | 980 // TODO(ngeoffray): ensure GVN has been run. |
| 981 set_.add(current); | 981 set_.add(current); |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 } | 984 } |
| OLD | NEW |