| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 HInstruction array, | 870 HInstruction array, |
| 871 HInstruction indexArgument) { | 871 HInstruction indexArgument) { |
| 872 Compiler compiler = backend.compiler; | 872 Compiler compiler = backend.compiler; |
| 873 bool isAssignable = | 873 bool isAssignable = |
| 874 !array.isFixedArray(compiler) && !array.isString(compiler); | 874 !array.isFixedArray(compiler) && !array.isString(compiler); |
| 875 HFieldGet length = new HFieldGet( | 875 HFieldGet length = new HFieldGet( |
| 876 backend.jsIndexableLength, array, isAssignable: isAssignable); | 876 backend.jsIndexableLength, array, isAssignable: isAssignable); |
| 877 length.instructionType = HType.INTEGER; | 877 length.instructionType = HType.INTEGER; |
| 878 indexNode.block.addBefore(indexNode, length); | 878 indexNode.block.addBefore(indexNode, length); |
| 879 | 879 |
| 880 HBoundsCheck check = new HBoundsCheck(indexArgument, length); | 880 HBoundsCheck check = new HBoundsCheck(indexArgument, length, array); |
| 881 indexNode.block.addBefore(indexNode, check); | 881 indexNode.block.addBefore(indexNode, check); |
| 882 // If the index input to the bounds check was not known to be an integer | 882 // If the index input to the bounds check was not known to be an integer |
| 883 // then we replace its uses with the bounds check, which is known to be an | 883 // then we replace its uses with the bounds check, which is known to be an |
| 884 // integer. However, if the input was already an integer we don't do this | 884 // integer. However, if the input was already an integer we don't do this |
| 885 // because putting in a check instruction might obscure the real nature of | 885 // because putting in a check instruction might obscure the real nature of |
| 886 // the index eg. if it is a constant. The range information from the | 886 // the index eg. if it is a constant. The range information from the |
| 887 // BoundsCheck instruction is attached to the input directly by | 887 // BoundsCheck instruction is attached to the input directly by |
| 888 // visitBoundsCheck in the SsaValueRangeAnalyzer. | 888 // visitBoundsCheck in the SsaValueRangeAnalyzer. |
| 889 if (!indexArgument.isInteger()) { | 889 if (!indexArgument.isInteger()) { |
| 890 indexArgument.replaceAllUsersDominatedBy(indexNode, check); | 890 indexArgument.replaceAllUsersDominatedBy(indexNode, check); |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 // that knows it is not of a specific Type. | 1504 // that knows it is not of a specific Type. |
| 1505 } | 1505 } |
| 1506 | 1506 |
| 1507 for (HIf ifUser in notIfUsers) { | 1507 for (HIf ifUser in notIfUsers) { |
| 1508 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); | 1508 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); |
| 1509 // TODO(ngeoffray): Also change uses for the then block on a HType | 1509 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1510 // that knows it is not of a specific Type. | 1510 // that knows it is not of a specific Type. |
| 1511 } | 1511 } |
| 1512 } | 1512 } |
| 1513 } | 1513 } |
| OLD | NEW |