Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (revision 31017) |
| +++ sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (working copy) |
| @@ -229,6 +229,19 @@ |
| } |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler); |
| + |
| + |
|
kasperl
2013/12/10 14:22:54
Too much whitespace.
ngeoffray
2013/12/10 15:26:17
Done.
|
| + Selector renameToOptimizedSelector(String name, |
| + Selector selector, |
| + Compiler compiler) { |
| + if (selector.name == name) return selector; |
| + return new TypedSelector( |
| + selector.mask, |
| + new Selector(SelectorKind.CALL, |
| + name, |
| + compiler.interceptorsLibrary, |
| + selector.argumentCount)); |
| + } |
| } |
| class AddSpecializer extends BinaryArithmeticSpecializer { |
| @@ -359,10 +372,36 @@ |
| return super.computeTypeFromInputTypes(instruction, compiler); |
| } |
| + bool isNotZero(HInstruction instruction, Compiler compiler) { |
| + if (!instruction.isConstantInteger()) return false; |
| + HConstant rightConstant = instruction; |
| + IntConstant intConstant = rightConstant.constant; |
| + int count = intConstant.value; |
| + return count != 0; |
| + } |
| + |
| + HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + if (isBuiltin(instruction, compiler)) { |
| + if (right.isUInt32(compiler) && isNotZero(right, compiler)) { |
|
floitsch
2013/12/10 15:45:16
Right side only needs to be an integer != 0.
ngeoffray
2013/12/10 15:48:15
Done.
|
| + if (left.isUInt32(compiler)) { |
|
floitsch
2013/12/10 15:45:16
left.isUInt31, or left.isInt32
ngeoffray
2013/12/10 15:48:15
Changed to left.isUInt31 (we don't have isInt32).
|
| + return newBuiltinVariant(instruction, compiler); |
| + } |
| + clearAllSideEffects(instruction); |
| + instruction.selector = renameToOptimizedSelector( |
|
kasperl
2013/12/10 14:22:54
Add a comment that explains what the contract for
ngeoffray
2013/12/10 15:26:17
Done.
|
| + '_tdivFast', instruction.selector, compiler); |
| + } |
| + } |
| + return null; |
| + } |
| + |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, |
| Compiler compiler) { |
| - // Truncating divide does not have a JS equivalent. |
| - return null; |
| + return new HTruncatingDivide( |
| + instruction.inputs[1], instruction.inputs[2], |
| + instruction.selector, computeTypeFromInputTypes(instruction, compiler)); |
| } |
| } |
| @@ -415,6 +454,11 @@ |
| // the instruction does not have any side effect, and that it |
| // can be GVN'ed. |
| clearAllSideEffects(instruction); |
| + Selector selector = instruction.selector; |
| + if (isPositive(right, compiler)) { |
| + instruction.selector = renameToOptimizedSelector( |
| + '_shlPositive', instruction.selector, compiler); |
| + } |
| } |
| return null; |
| } |
| @@ -452,6 +496,16 @@ |
| // the instruction does not have any side effect, and that it |
| // can be GVN'ed. |
| clearAllSideEffects(instruction); |
| + if (isPositive(right, compiler) && isPositive(left, compiler)) { |
| + instruction.selector = renameToOptimizedSelector( |
| + '_shrBothPositive', instruction.selector, compiler); |
| + } else if (isPositive(left, compiler) && right.isNumber(compiler)) { |
| + instruction.selector = renameToOptimizedSelector( |
| + '_shrReceiverPositive', instruction.selector, compiler); |
| + } else if (isPositive(right, compiler)) { |
| + instruction.selector = renameToOptimizedSelector( |
| + '_shrOtherPositive', instruction.selector, compiler); |
| + } |
| } |
| return null; |
| } |