| 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 |
| 11 * dynamic to a builtin instruction (e.g. HIndex, HBitNot). | 11 * dynamic to a builtin instruction (e.g. HIndex, HBitNot). |
| 12 */ | 12 */ |
| 13 class InvokeDynamicSpecializer { | 13 class InvokeDynamicSpecializer { |
| 14 const InvokeDynamicSpecializer(); | 14 const InvokeDynamicSpecializer(); |
| 15 | 15 |
| 16 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, | 16 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| 17 Compiler compiler) { | 17 Compiler compiler) { |
| 18 return TypeMaskFactory.inferredTypeForSelector( | 18 return TypeMaskFactory.inferredTypeForSelector( |
| 19 instruction.selector, instruction.mask, compiler); | 19 instruction.selector, instruction.mask, compiler); |
| 20 } | 20 } |
| 21 | 21 |
| 22 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, | 22 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| 23 Compiler compiler) { | 23 Compiler compiler) { |
| 24 return null; | 24 return null; |
| 25 } | 25 } |
| 26 | 26 |
| 27 Operation operation(ConstantSystem constantSystem) => null; | 27 Operation operation(ConstantSystem constantSystem) => null; |
| 28 | 28 |
| 29 static InvokeDynamicSpecializer lookupSpecializer(Selector selector) { | 29 static InvokeDynamicSpecializer lookupSpecializer(Selector selector) { |
| 30 if (selector.kind == SelectorKind.INDEX) { | 30 if (selector.isIndex) { |
| 31 return selector.name == '[]' | 31 return const IndexSpecializer(); |
| 32 ? const IndexSpecializer() | 32 } else if (selector.isIndexSet) { |
| 33 : const IndexAssignSpecializer(); | 33 return const IndexAssignSpecializer(); |
| 34 } else if (selector.kind == SelectorKind.OPERATOR) { | 34 } else if (selector.isOperator) { |
| 35 if (selector.name == 'unary-') { | 35 if (selector.name == 'unary-') { |
| 36 return const UnaryNegateSpecializer(); | 36 return const UnaryNegateSpecializer(); |
| 37 } else if (selector.name == '~') { | 37 } else if (selector.name == '~') { |
| 38 return const BitNotSpecializer(); | 38 return const BitNotSpecializer(); |
| 39 } else if (selector.name == '+') { | 39 } else if (selector.name == '+') { |
| 40 return const AddSpecializer(); | 40 return const AddSpecializer(); |
| 41 } else if (selector.name == '-') { | 41 } else if (selector.name == '-') { |
| 42 return const SubtractSpecializer(); | 42 return const SubtractSpecializer(); |
| 43 } else if (selector.name == '*') { | 43 } else if (selector.name == '*') { |
| 44 return const MultiplySpecializer(); | 44 return const MultiplySpecializer(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 62 return const EqualsSpecializer(); | 62 return const EqualsSpecializer(); |
| 63 } else if (selector.name == '<') { | 63 } else if (selector.name == '<') { |
| 64 return const LessSpecializer(); | 64 return const LessSpecializer(); |
| 65 } else if (selector.name == '<=') { | 65 } else if (selector.name == '<=') { |
| 66 return const LessEqualSpecializer(); | 66 return const LessEqualSpecializer(); |
| 67 } else if (selector.name == '>') { | 67 } else if (selector.name == '>') { |
| 68 return const GreaterSpecializer(); | 68 return const GreaterSpecializer(); |
| 69 } else if (selector.name == '>=') { | 69 } else if (selector.name == '>=') { |
| 70 return const GreaterEqualSpecializer(); | 70 return const GreaterEqualSpecializer(); |
| 71 } | 71 } |
| 72 } else if (selector.kind == SelectorKind.CALL) { | 72 } else if (selector.isCall) { |
| 73 if (selector.argumentCount == 1 && selector.namedArguments.length == 0) { | 73 if (selector.argumentCount == 1 && selector.namedArguments.length == 0) { |
| 74 if (selector.name == 'codeUnitAt') { | 74 if (selector.name == 'codeUnitAt') { |
| 75 return const CodeUnitAtSpecializer(); | 75 return const CodeUnitAtSpecializer(); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 return const InvokeDynamicSpecializer(); | 79 return const InvokeDynamicSpecializer(); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return left.isUInt31(compiler) && right.isUInt31(compiler); | 231 return left.isUInt31(compiler) && right.isUInt31(compiler); |
| 232 } | 232 } |
| 233 | 233 |
| 234 HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler); | 234 HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler); |
| 235 | 235 |
| 236 Selector renameToOptimizedSelector(String name, | 236 Selector renameToOptimizedSelector(String name, |
| 237 Selector selector, | 237 Selector selector, |
| 238 Compiler compiler) { | 238 Compiler compiler) { |
| 239 if (selector.name == name) return selector; | 239 if (selector.name == name) return selector; |
| 240 JavaScriptBackend backend = compiler.backend; | 240 JavaScriptBackend backend = compiler.backend; |
| 241 return new Selector( | 241 return new Selector.call(new Name(name, backend.interceptorsLibrary), |
| 242 SelectorKind.CALL, new Name(name, backend.interceptorsLibrary), | |
| 243 new CallStructure(selector.argumentCount)); | 242 new CallStructure(selector.argumentCount)); |
| 244 } | 243 } |
| 245 } | 244 } |
| 246 | 245 |
| 247 class AddSpecializer extends BinaryArithmeticSpecializer { | 246 class AddSpecializer extends BinaryArithmeticSpecializer { |
| 248 const AddSpecializer(); | 247 const AddSpecializer(); |
| 249 | 248 |
| 250 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, | 249 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| 251 Compiler compiler) { | 250 Compiler compiler) { |
| 252 if (inputsAreUInt31(instruction, compiler)) { | 251 if (inputsAreUInt31(instruction, compiler)) { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 return constantSystem.codeUnitAt; | 760 return constantSystem.codeUnitAt; |
| 762 } | 761 } |
| 763 | 762 |
| 764 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, | 763 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| 765 Compiler compiler) { | 764 Compiler compiler) { |
| 766 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index | 765 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index |
| 767 // bounds checking optimizations as for HIndex. | 766 // bounds checking optimizations as for HIndex. |
| 768 return null; | 767 return null; |
| 769 } | 768 } |
| 770 } | 769 } |
| OLD | NEW |