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 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 return new HEquals(target, node.left, node.right); | 282 return new HEquals(target, node.left, node.right); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 // All other cases are dealt with by the [visitInvokeBinary]. | 286 // All other cases are dealt with by the [visitInvokeBinary]. |
| 287 return visitInvokeBinary(node); | 287 return visitInvokeBinary(node); |
| 288 } | 288 } |
| 289 | 289 |
| 290 HInstruction visitTypeGuard(HTypeGuard node) { | 290 HInstruction visitTypeGuard(HTypeGuard node) { |
| 291 HInstruction value = node.guarded; | 291 HInstruction value = node.guarded; |
| 292 HType combinedType = value.propagatedType.combine(node.guardedType); | 292 HType combinedType = value.propagatedType.intersect(node.guardedType); |
|
ngeoffray
2012/04/23 10:19:21
Please add a simple comment or example on why this
floitsch
2012/04/24 15:25:18
Good thing you made me do this. Should have been u
| |
| 293 return (combinedType == value.propagatedType) ? value : node; | 293 return (combinedType == value.propagatedType) ? value : node; |
| 294 } | 294 } |
| 295 | 295 |
| 296 HInstruction visitIntegerCheck(HIntegerCheck node) { | 296 HInstruction visitIntegerCheck(HIntegerCheck node) { |
| 297 HInstruction value = node.value; | 297 HInstruction value = node.value; |
| 298 return value.isInteger() ? value : node; | 298 return value.isInteger() ? value : node; |
| 299 } | 299 } |
| 300 | 300 |
| 301 HInstruction visitIs(HIs node) { | 301 HInstruction visitIs(HIs node) { |
| 302 Type type = node.typeName; | 302 Type type = node.typeName; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 return check; | 396 return check; |
| 397 } | 397 } |
| 398 | 398 |
| 399 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { | 399 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { |
| 400 HIntegerCheck check = new HIntegerCheck(value); | 400 HIntegerCheck check = new HIntegerCheck(value); |
| 401 node.block.addBefore(node, check); | 401 node.block.addBefore(node, check); |
| 402 return check; | 402 return check; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void visitIndex(HIndex node) { | 405 void visitIndex(HIndex node) { |
| 406 if (!node.receiver.isStringOrArray()) return; | 406 if (!node.receiver.isIndexablePrimitive()) return; |
| 407 HInstruction index = node.index; | 407 HInstruction index = node.index; |
| 408 if (index is HBoundsCheck) return; | 408 if (index is HBoundsCheck) return; |
| 409 if (!node.index.isInteger()) { | 409 if (!node.index.isInteger()) { |
| 410 index = insertIntegerCheck(node, index); | 410 index = insertIntegerCheck(node, index); |
| 411 } | 411 } |
| 412 index = insertBoundsCheck(node, node.receiver, index); | 412 index = insertBoundsCheck(node, node.receiver, index); |
| 413 HIndex newInstruction = new HIndex(node.target, node.receiver, index); | 413 HIndex newInstruction = new HIndex(node.target, node.receiver, index); |
| 414 node.block.addBefore(node, newInstruction); | 414 node.block.addBefore(node, newInstruction); |
| 415 node.block.rewrite(node, newInstruction); | 415 node.block.rewrite(node, newInstruction); |
| 416 node.block.remove(node); | 416 node.block.remove(node); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 } | 816 } |
| 817 } | 817 } |
| 818 if (!canBeMoved) continue; | 818 if (!canBeMoved) continue; |
| 819 | 819 |
| 820 // This is safe because we are running after GVN. | 820 // This is safe because we are running after GVN. |
| 821 // TODO(ngeoffray): ensure GVN has been run. | 821 // TODO(ngeoffray): ensure GVN has been run. |
| 822 set_.add(current); | 822 set_.add(current); |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 } | 825 } |
| OLD | NEW |