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 30705) |
| +++ sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (working copy) |
| @@ -226,6 +226,18 @@ |
| class AddSpecializer extends BinaryArithmeticSpecializer { |
| const AddSpecializer(); |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
|
kasperl
2013/11/28 09:09:47
Share this code between add, modulo, multiply, tru
ngeoffray
2013/11/28 11:21:47
Done.
|
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isPositiveIntegerOrNull(compiler) |
| + && right.isPositiveIntegerOrNull(compiler)) { |
| + return backend.positiveIntType; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| BinaryOperation operation(ConstantSystem constantSystem) { |
| return constantSystem.add; |
| } |
| @@ -267,6 +279,18 @@ |
| class ModuloSpecializer extends BinaryArithmeticSpecializer { |
| const ModuloSpecializer(); |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isPositiveIntegerOrNull(compiler) |
| + && right.isPositiveIntegerOrNull(compiler)) { |
| + return backend.positiveIntType; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| BinaryOperation operation(ConstantSystem constantSystem) { |
| return constantSystem.modulo; |
| } |
| @@ -285,6 +309,18 @@ |
| return constantSystem.multiply; |
| } |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isPositiveIntegerOrNull(compiler) |
| + && right.isPositiveIntegerOrNull(compiler)) { |
| + return backend.positiveIntType; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, |
| Compiler compiler) { |
| return new HMultiply( |
| @@ -315,6 +351,18 @@ |
| return constantSystem.truncatingDivide; |
| } |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isPositiveIntegerOrNull(compiler) |
| + && right.isPositiveIntegerOrNull(compiler)) { |
| + return backend.positiveIntType; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, |
| Compiler compiler) { |
| // Truncating divide does not have a JS equivalent. |
| @@ -348,7 +396,7 @@ |
| bool isPositive(HInstruction instruction, Compiler compiler) { |
| // TODO: We should use the value range analysis. Currently, ranges |
| // are discarded just after the analysis. |
| - return instruction.isUInt32(compiler); |
| + return instruction.isPositiveInteger(compiler); |
| } |
| } |