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 30666) |
| +++ sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (working copy) |
| @@ -135,7 +135,7 @@ |
| // integer or throw an error. |
| JavaScriptBackend backend = compiler.backend; |
| if (instruction.inputs[1].isPrimitiveOrNull(compiler)) { |
| - return backend.intType; |
| + return backend.uint32Type; |
| } |
| return super.computeTypeFromInputTypes(instruction, compiler); |
| } |
| @@ -145,7 +145,8 @@ |
| JavaScriptBackend backend = compiler.backend; |
| HInstruction input = instruction.inputs[1]; |
| if (input.isNumber(compiler)) { |
| - return new HBitNot(input, instruction.selector, backend.intType); |
| + return new HBitNot(input, instruction.selector, |
| + computeTypeFromInputTypes(instruction, compiler)); |
| } |
| return null; |
| } |
| @@ -331,7 +332,7 @@ |
| HInstruction left = instruction.inputs[1]; |
| JavaScriptBackend backend = compiler.backend; |
| if (left.isPrimitiveOrNull(compiler)) { |
| - return backend.intType; |
| + return backend.uint32Type; |
| } |
| return super.computeTypeFromInputTypes(instruction, compiler); |
| } |
| @@ -344,10 +345,10 @@ |
| return count >= 0 && count <= 31; |
| } |
| - bool isPositive(HInstruction instruction) { |
| + bool isPositive(HInstruction instruction, Compiler compiler) { |
| // TODO: We should use the value range analysis. Currently, ranges |
| // are discarded just after the analysis. |
| - return instruction is HBinaryBitOp; |
| + return instruction.isUInt32(compiler); |
| } |
| } |
| @@ -379,19 +380,30 @@ |
| JavaScriptBackend backend = compiler.backend; |
| return new HShiftLeft( |
| instruction.inputs[1], instruction.inputs[2], |
| - instruction.selector, backend.intType); |
| + instruction.selector, computeTypeFromInputTypes(instruction, compiler)); |
| } |
| } |
| class ShiftRightSpecializer extends BinaryBitOpSpecializer { |
| const ShiftRightSpecializer(); |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isUInt31(compiler) && right.isUInt31(compiler)) { |
|
kasperl
2013/11/26 14:58:40
Isn't it enough if right is positive?
ngeoffray
2013/11/26 15:19:12
You mean left, right? :-) Done.
|
| + return backend.uint31Type; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, |
| Compiler compiler) { |
| HInstruction left = instruction.inputs[1]; |
| HInstruction right = instruction.inputs[2]; |
| if (left.isNumber(compiler)) { |
| - if (argumentLessThan32(right) && isPositive(left)) { |
| + if (argumentLessThan32(right) && isPositive(left, compiler)) { |
| return newBuiltinVariant(instruction, compiler); |
| } |
| // Even if there is no builtin equivalent instruction, we know |
| @@ -407,7 +419,7 @@ |
| JavaScriptBackend backend = compiler.backend; |
| return new HShiftRight( |
| instruction.inputs[1], instruction.inputs[2], |
| - instruction.selector, backend.intType); |
| + instruction.selector, computeTypeFromInputTypes(instruction, compiler)); |
| } |
| BinaryOperation operation(ConstantSystem constantSystem) { |
| @@ -422,12 +434,23 @@ |
| return constantSystem.bitOr; |
| } |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isUInt31(compiler) && right.isUInt31(compiler)) { |
| + return backend.uint31Type; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, |
| Compiler compiler) { |
| JavaScriptBackend backend = compiler.backend; |
| return new HBitOr( |
| instruction.inputs[1], instruction.inputs[2], |
| - instruction.selector, backend.intType); |
| + instruction.selector, computeTypeFromInputTypes(instruction, compiler)); |
| } |
| } |
| @@ -438,12 +461,23 @@ |
| return constantSystem.bitAnd; |
| } |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isUInt31(compiler) || right.isUInt31(compiler)) { |
| + return backend.uint31Type; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, |
| Compiler compiler) { |
| JavaScriptBackend backend = compiler.backend; |
| return new HBitAnd( |
| instruction.inputs[1], instruction.inputs[2], |
| - instruction.selector, backend.intType); |
| + instruction.selector, computeTypeFromInputTypes(instruction, compiler)); |
| } |
| } |
| @@ -454,12 +488,23 @@ |
| return constantSystem.bitXor; |
| } |
| + TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, |
| + Compiler compiler) { |
| + HInstruction left = instruction.inputs[1]; |
| + HInstruction right = instruction.inputs[2]; |
| + JavaScriptBackend backend = compiler.backend; |
| + if (left.isUInt31(compiler) && right.isUInt31(compiler)) { |
| + return backend.uint31Type; |
| + } |
| + return super.computeTypeFromInputTypes(instruction, compiler); |
| + } |
| + |
| HInstruction newBuiltinVariant(HInvokeDynamic instruction, |
| Compiler compiler) { |
| JavaScriptBackend backend = compiler.backend; |
| return new HBitXor( |
| instruction.inputs[1], instruction.inputs[2], |
| - instruction.selector, backend.intType); |
| + instruction.selector, computeTypeFromInputTypes(instruction, compiler)); |
| } |
| } |