Chromium Code Reviews| Index: src/arm/lithium-codegen-arm.cc |
| diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
| index fab5a1b7a07d3ddb9a3bcefba6be68813644def5..f985da34a4af592cbf772ab941d98620e8385b02 100644 |
| --- a/src/arm/lithium-codegen-arm.cc |
| +++ b/src/arm/lithium-codegen-arm.cc |
| @@ -499,8 +499,17 @@ bool LCodeGen::IsSmi(LConstantOperand* op) const { |
| int LCodeGen::ToInteger32(LConstantOperand* op) const { |
|
Sven Panne
2013/07/25 11:48:53
Hmmm, this was here before, but the return type lo
|
| + return ToRepresentation(op, Representation::Integer32()); |
| +} |
| + |
| + |
| +int32_t LCodeGen::ToRepresentation(LConstantOperand* op, |
| + const Representation& r) const { |
| HConstant* constant = chunk_->LookupConstant(op); |
| - return constant->Integer32Value(); |
| + int32_t value = constant->Integer32Value(); |
| + if (r.IsInteger32()) return value; |
| + ASSERT(r.IsSmiOrTagged()); |
| + return reinterpret_cast<int32_t>(Smi::FromInt(value)); |
| } |
| @@ -522,7 +531,10 @@ Operand LCodeGen::ToOperand(LOperand* op) { |
| LConstantOperand* const_op = LConstantOperand::cast(op); |
| HConstant* constant = chunk()->LookupConstant(const_op); |
| Representation r = chunk_->LookupLiteralRepresentation(const_op); |
| - if (r.IsInteger32()) { |
| + if (r.IsSmi()) { |
| + ASSERT(constant->HasSmiValue()); |
| + return Operand(Smi::FromInt(constant->Integer32Value())); |
| + } else if (r.IsInteger32()) { |
| ASSERT(constant->HasInteger32Value()); |
| return Operand(constant->Integer32Value()); |
| } else if (r.IsDouble()) { |
| @@ -1544,7 +1556,9 @@ void LCodeGen::DoMulI(LMulI* instr) { |
| if (right_op->IsConstantOperand() && !can_overflow) { |
| // Use optimized code for specific constants. |
| - int32_t constant = ToInteger32(LConstantOperand::cast(right_op)); |
| + int32_t constant = ToRepresentation( |
| + LConstantOperand::cast(right_op), |
| + instr->hydrogen()->right()->representation()); |
| if (bailout_on_minus_zero && (constant < 0)) { |
| // The case of a null constant will be handled separately. |
| @@ -1608,11 +1622,21 @@ void LCodeGen::DoMulI(LMulI* instr) { |
| if (can_overflow) { |
| // scratch:result = left * right. |
| - __ smull(result, scratch, left, right); |
| + if (instr->hydrogen()->representation().IsSmi()) { |
| + __ SmiUntag(result, left); |
| + __ smull(result, scratch, result, right); |
| + } else { |
| + __ smull(result, scratch, left, right); |
| + } |
| __ cmp(scratch, Operand(result, ASR, 31)); |
| DeoptimizeIf(ne, instr->environment()); |
| } else { |
| - __ mul(result, left, right); |
| + if (instr->hydrogen()->representation().IsSmi()) { |
| + __ SmiUntag(result, left); |
| + __ mul(result, result, right); |
| + } else { |
| + __ mul(result, left, right); |
| + } |
| } |
| if (bailout_on_minus_zero) { |
| @@ -1967,7 +1991,7 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) { |
| LOperand* left = instr->left(); |
| LOperand* right = instr->right(); |
| HMathMinMax::Operation operation = instr->hydrogen()->operation(); |
| - if (instr->hydrogen()->representation().IsInteger32()) { |
| + if (instr->hydrogen()->representation().IsSmiOrInteger32()) { |
| Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge; |
| Register left_reg = ToRegister(left); |
| Operand right_op = (right->IsRegister() || right->IsConstantOperand()) |