| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * [InvokeDynamicSpecializer] and its subclasses are helpers to | 8 * [InvokeDynamicSpecializer] and its subclasses are helpers to |
| 9 * optimize intercepted dynamic calls. It knows what input types | 9 * optimize intercepted dynamic calls. It knows what input types |
| 10 * would be beneficial for performance, and how to change a invoke | 10 * would be beneficial for performance, and how to change a invoke |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // The index should be an int when the receiver is a string or array. | 93 // The index should be an int when the receiver is a string or array. |
| 94 // However it turns out that inserting an integer check in the optimized | 94 // However it turns out that inserting an integer check in the optimized |
| 95 // version is cheaper than having another bailout case. This is true, | 95 // version is cheaper than having another bailout case. This is true, |
| 96 // because the integer check will simply throw if it fails. | 96 // because the integer check will simply throw if it fails. |
| 97 return HType.UNKNOWN; | 97 return HType.UNKNOWN; |
| 98 } | 98 } |
| 99 | 99 |
| 100 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, | 100 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| 101 Compiler compiler) { | 101 Compiler compiler) { |
| 102 if (instruction.inputs[1].isMutableIndexable(compiler)) { | 102 if (instruction.inputs[1].isMutableIndexable(compiler)) { |
| 103 if (!instruction.inputs[2].isInteger() && compiler.enableTypeAssertions) { |
| 104 // We want the right checked mode error. |
| 105 return null; |
| 106 } |
| 103 return new HIndexAssign(instruction.inputs[1], | 107 return new HIndexAssign(instruction.inputs[1], |
| 104 instruction.inputs[2], | 108 instruction.inputs[2], |
| 105 instruction.inputs[3], | 109 instruction.inputs[3], |
| 106 instruction.selector); | 110 instruction.selector); |
| 107 } | 111 } |
| 108 return null; | 112 return null; |
| 109 } | 113 } |
| 110 } | 114 } |
| 111 | 115 |
| 112 class IndexSpecializer extends InvokeDynamicSpecializer { | 116 class IndexSpecializer extends InvokeDynamicSpecializer { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 123 // The index should be an int when the receiver is a string or array. | 127 // The index should be an int when the receiver is a string or array. |
| 124 // However it turns out that inserting an integer check in the optimized | 128 // However it turns out that inserting an integer check in the optimized |
| 125 // version is cheaper than having another bailout case. This is true, | 129 // version is cheaper than having another bailout case. This is true, |
| 126 // because the integer check will simply throw if it fails. | 130 // because the integer check will simply throw if it fails. |
| 127 return HType.UNKNOWN; | 131 return HType.UNKNOWN; |
| 128 } | 132 } |
| 129 | 133 |
| 130 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, | 134 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| 131 Compiler compiler) { | 135 Compiler compiler) { |
| 132 if (instruction.inputs[1].isIndexable(compiler)) { | 136 if (instruction.inputs[1].isIndexable(compiler)) { |
| 137 if (!instruction.inputs[2].isInteger() && compiler.enableTypeAssertions) { |
| 138 // We want the right checked mode error. |
| 139 return null; |
| 140 } |
| 133 HInstruction index = new HIndex( | 141 HInstruction index = new HIndex( |
| 134 instruction.inputs[1], instruction.inputs[2], instruction.selector); | 142 instruction.inputs[1], instruction.inputs[2], instruction.selector); |
| 135 index.instructionType = | 143 index.instructionType = |
| 136 new HType.inferredTypeForSelector(instruction.selector, compiler); | 144 new HType.inferredTypeForSelector(instruction.selector, compiler); |
| 137 return index; | 145 return index; |
| 138 } | 146 } |
| 139 return null; | 147 return null; |
| 140 } | 148 } |
| 141 } | 149 } |
| 142 | 150 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 632 |
| 625 BinaryOperation operation(ConstantSystem constantSystem) { | 633 BinaryOperation operation(ConstantSystem constantSystem) { |
| 626 return constantSystem.lessEqual; | 634 return constantSystem.lessEqual; |
| 627 } | 635 } |
| 628 | 636 |
| 629 HInstruction newBuiltinVariant(HInvokeDynamic instruction) { | 637 HInstruction newBuiltinVariant(HInvokeDynamic instruction) { |
| 630 return new HLessEqual( | 638 return new HLessEqual( |
| 631 instruction.inputs[1], instruction.inputs[2], instruction.selector); | 639 instruction.inputs[1], instruction.inputs[2], instruction.selector); |
| 632 } | 640 } |
| 633 } | 641 } |
| OLD | NEW |