| 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 HType computeTypeFromInputTypes(HInvokeDynamic instruction, | 16 HType computeTypeFromInputTypes(HInvokeDynamic instruction, |
| 17 Compiler compiler) { | 17 Compiler compiler) { |
| 18 HType receiverType = instruction.getDartReceiver(compiler).instructionType; | 18 Selector selector = instruction.selector; |
| 19 Selector refined = receiverType.refine(instruction.selector, compiler); | 19 HType type = new HType.inferredTypeForSelector(selector, compiler); |
| 20 HType type = new HType.inferredTypeForSelector(refined, compiler); | |
| 21 // TODO(ngeoffray): Because we don't know yet the side effects of | 20 // TODO(ngeoffray): Because we don't know yet the side effects of |
| 22 // a JS call, we sometimes know more in the compiler about the | 21 // a JS call, we sometimes know more in the compiler about the |
| 23 // side effects of an element (for example operator% on the int | 22 // side effects of an element (for example operator% on the int |
| 24 // class). We should remove this check once we analyze JS calls. | 23 // class). We should remove this check once we analyze JS calls. |
| 25 if (!instruction.useGvn()) { | 24 if (!instruction.useGvn()) { |
| 26 instruction.sideEffects = | 25 instruction.sideEffects = |
| 27 compiler.world.getSideEffectsOfSelector(refined); | 26 compiler.world.getSideEffectsOfSelector(selector); |
| 28 } | 27 } |
| 29 return type; | 28 return type; |
| 30 } | 29 } |
| 31 | 30 |
| 32 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, | 31 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| 33 Compiler compiler) { | 32 Compiler compiler) { |
| 34 return null; | 33 return null; |
| 35 } | 34 } |
| 36 | 35 |
| 37 Operation operation(ConstantSystem constantSystem) => null; | 36 Operation operation(ConstantSystem constantSystem) => null; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 489 |
| 491 BinaryOperation operation(ConstantSystem constantSystem) { | 490 BinaryOperation operation(ConstantSystem constantSystem) { |
| 492 return constantSystem.lessEqual; | 491 return constantSystem.lessEqual; |
| 493 } | 492 } |
| 494 | 493 |
| 495 HInstruction newBuiltinVariant(HInvokeDynamic instruction) { | 494 HInstruction newBuiltinVariant(HInvokeDynamic instruction) { |
| 496 return new HLessEqual( | 495 return new HLessEqual( |
| 497 instruction.inputs[1], instruction.inputs[2], instruction.selector); | 496 instruction.inputs[1], instruction.inputs[2], instruction.selector); |
| 498 } | 497 } |
| 499 } | 498 } |
| OLD | NEW |