| 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 | 7 |
| 8 class ValueRangeInfo { | 8 class ValueRangeInfo { |
| 9 final ConstantSystem constantSystem; | 9 final ConstantSystem constantSystem; |
| 10 | 10 |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 * save them here in order to remove them once the phase is done. | 543 * save them here in order to remove them once the phase is done. |
| 544 */ | 544 */ |
| 545 final List<HRangeConversion> conversions = <HRangeConversion>[]; | 545 final List<HRangeConversion> conversions = <HRangeConversion>[]; |
| 546 | 546 |
| 547 /** | 547 /** |
| 548 * Value ranges for integer instructions. This map gets populated by | 548 * Value ranges for integer instructions. This map gets populated by |
| 549 * the dominator tree visit. | 549 * the dominator tree visit. |
| 550 */ | 550 */ |
| 551 final Map<HInstruction, Range> ranges = new Map<HInstruction, Range>(); | 551 final Map<HInstruction, Range> ranges = new Map<HInstruction, Range>(); |
| 552 | 552 |
| 553 final Compiler compiler; |
| 553 final ConstantSystem constantSystem; | 554 final ConstantSystem constantSystem; |
| 554 final ValueRangeInfo info; | 555 final ValueRangeInfo info; |
| 555 | 556 |
| 556 CodegenWorkItem work; | 557 CodegenWorkItem work; |
| 557 HGraph graph; | 558 HGraph graph; |
| 558 | 559 |
| 559 SsaValueRangeAnalyzer(constantSystem, this.work) | 560 SsaValueRangeAnalyzer(this.compiler, constantSystem, this.work) |
| 560 : info = new ValueRangeInfo(constantSystem), | 561 : info = new ValueRangeInfo(constantSystem), |
| 561 this.constantSystem = constantSystem; | 562 this.constantSystem = constantSystem; |
| 562 | 563 |
| 563 void visitGraph(HGraph graph) { | 564 void visitGraph(HGraph graph) { |
| 564 this.graph = graph; | 565 this.graph = graph; |
| 565 visitDominatorTree(graph); | 566 visitDominatorTree(graph); |
| 566 // We remove the range conversions after visiting the graph so | 567 // We remove the range conversions after visiting the graph so |
| 567 // that the graph does not get polluted with these instructions | 568 // that the graph does not get polluted with these instructions |
| 568 // only necessary for this phase. | 569 // only necessary for this phase. |
| 569 removeRangeConversion(); | 570 removeRangeConversion(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 623 |
| 623 Range visitConstant(HConstant constant) { | 624 Range visitConstant(HConstant constant) { |
| 624 if (!constant.isInteger()) return info.newUnboundRange(); | 625 if (!constant.isInteger()) return info.newUnboundRange(); |
| 625 IntConstant constantInt = constant.constant; | 626 IntConstant constantInt = constant.constant; |
| 626 Value value = info.newIntValue(constantInt.value); | 627 Value value = info.newIntValue(constantInt.value); |
| 627 return info.newNormalizedRange(value, value); | 628 return info.newNormalizedRange(value, value); |
| 628 } | 629 } |
| 629 | 630 |
| 630 Range visitFieldGet(HFieldGet fieldGet) { | 631 Range visitFieldGet(HFieldGet fieldGet) { |
| 631 if (!fieldGet.isInteger()) return info.newUnboundRange(); | 632 if (!fieldGet.isInteger()) return info.newUnboundRange(); |
| 632 if (!fieldGet.receiver.isIndexablePrimitive()) { | 633 if (!fieldGet.receiver.isIndexable(compiler)) { |
| 633 return visitInstruction(fieldGet); | 634 return visitInstruction(fieldGet); |
| 634 } | 635 } |
| 635 LengthValue value = info.newLengthValue(fieldGet); | 636 LengthValue value = info.newLengthValue(fieldGet); |
| 636 // We know this range is above zero. To simplify the analysis, we | 637 // We know this range is above zero. To simplify the analysis, we |
| 637 // put the zero value as the lower bound of this range. This | 638 // put the zero value as the lower bound of this range. This |
| 638 // allows to easily remove the second bound check in the following | 639 // allows to easily remove the second bound check in the following |
| 639 // expression: a[1] + a[0]. | 640 // expression: a[1] + a[0]. |
| 640 return info.newNormalizedRange(info.intZero, value); | 641 return info.newNormalizedRange(info.intZero, value); |
| 641 } | 642 } |
| 642 | 643 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 if (instruction is HPhi && !instruction.block.isLoopHeader()) { | 984 if (instruction is HPhi && !instruction.block.isLoopHeader()) { |
| 984 HInstruction result = unwrap(instruction.inputs[0]); | 985 HInstruction result = unwrap(instruction.inputs[0]); |
| 985 for (int i = 1; i < instruction.inputs.length; i++) { | 986 for (int i = 1; i < instruction.inputs.length; i++) { |
| 986 if (result != unwrap(instruction.inputs[i])) return instruction; | 987 if (result != unwrap(instruction.inputs[i])) return instruction; |
| 987 } | 988 } |
| 988 return result; | 989 return result; |
| 989 } | 990 } |
| 990 return instruction; | 991 return instruction; |
| 991 } | 992 } |
| 992 } | 993 } |
| OLD | NEW |