Chromium Code Reviews| Index: src/arm/lithium-arm.cc |
| diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc |
| index d3ac5e0dfebf67c4ed54481d8669852b842c1c83..9d25c23178d42157361f53c64924deb16f53e208 100644 |
| --- a/src/arm/lithium-arm.cc |
| +++ b/src/arm/lithium-arm.cc |
| @@ -710,51 +710,44 @@ LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
| LInstruction* LChunkBuilder::DoShift(Token::Value op, |
| HBitwiseBinaryOperation* instr) { |
| - if (instr->representation().IsTagged()) { |
| - ASSERT(instr->left()->representation().IsTagged()); |
| - ASSERT(instr->right()->representation().IsTagged()); |
| - |
| - LOperand* left = UseFixed(instr->left(), r1); |
| - LOperand* right = UseFixed(instr->right(), r0); |
| - LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); |
| - return MarkAsCall(DefineFixed(result, r0), instr); |
| - } |
| - |
| - ASSERT(instr->representation().IsSmiOrInteger32()); |
| - ASSERT(instr->left()->representation().Equals(instr->representation())); |
| - ASSERT(instr->right()->representation().Equals(instr->representation())); |
| - LOperand* left = UseRegisterAtStart(instr->left()); |
| + if (instr->representation().IsSmiOrInteger32()) { |
| + ASSERT(instr->left()->representation().Equals(instr->representation())); |
| + ASSERT(instr->right()->representation().Equals(instr->representation())); |
| + LOperand* left = UseRegisterAtStart(instr->left()); |
| - HValue* right_value = instr->right(); |
| - LOperand* right = NULL; |
| - int constant_value = 0; |
| - bool does_deopt = false; |
| - if (right_value->IsConstant()) { |
| - HConstant* constant = HConstant::cast(right_value); |
| - right = chunk_->DefineConstantOperand(constant); |
| - constant_value = constant->Integer32Value() & 0x1f; |
| - // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| - // truncated to smi. |
| - if (instr->representation().IsSmi() && constant_value > 0) { |
| - does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); |
| + HValue* right_value = instr->right(); |
| + LOperand* right = NULL; |
| + int constant_value = 0; |
| + bool does_deopt = false; |
| + if (right_value->IsConstant()) { |
| + HConstant* constant = HConstant::cast(right_value); |
| + right = chunk_->DefineConstantOperand(constant); |
| + constant_value = constant->Integer32Value() & 0x1f; |
| + // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| + // truncated to smi. |
| + if (instr->representation().IsSmi() && constant_value > 0) { |
| + does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); |
| + } |
| + } else { |
| + right = UseRegisterAtStart(right_value); |
| } |
| - } else { |
| - right = UseRegisterAtStart(right_value); |
| - } |
| - // Shift operations can only deoptimize if we do a logical shift |
| - // by 0 and the result cannot be truncated to int32. |
| - if (op == Token::SHR && constant_value == 0) { |
| - if (FLAG_opt_safe_uint32_operations) { |
| - does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
| - } else { |
| - does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32); |
| + // Shift operations can only deoptimize if we do a logical shift |
| + // by 0 and the result cannot be truncated to int32. |
| + if (op == Token::SHR && constant_value == 0) { |
| + if (FLAG_opt_safe_uint32_operations) { |
| + does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
| + } else { |
| + does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32); |
| + } |
| } |
| - } |
| - LInstruction* result = |
| - DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt)); |
| - return does_deopt ? AssignEnvironment(result) : result; |
| + LInstruction* result = |
| + DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt)); |
| + return does_deopt ? AssignEnvironment(result) : result; |
| + } else { |
| + return DoArithmeticT(op, instr); |
| + } |
| } |
| @@ -763,21 +756,24 @@ LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| ASSERT(instr->representation().IsDouble()); |
| ASSERT(instr->left()->representation().IsDouble()); |
| ASSERT(instr->right()->representation().IsDouble()); |
| - ASSERT(op != Token::MOD); |
| - LOperand* left = UseRegisterAtStart(instr->left()); |
| - LOperand* right = UseRegisterAtStart(instr->right()); |
| + LOperand* left = (op == Token::MOD) |
|
Sven Panne
2013/09/16 13:10:32
Refactor this into
if (op == Token::MOD) {
...
}
|
| + ? UseFixedDouble(instr->left(), d1) |
| + : UseRegisterAtStart(instr->left()); |
| + LOperand* right = (op == Token::MOD) |
| + ? UseFixedDouble(instr->right(), d2) |
| + : UseRegisterAtStart(instr->right()); |
| LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); |
| + |
| + // We call a C function for double modulo. It can't trigger a GC. We need |
| + // to use fixed result register for the call. |
| + // TODO(fschneider): Allow any register as input registers. |
| + if (op == Token::MOD) return MarkAsCall(DefineFixedDouble(result, d1), instr); |
| return DefineAsRegister(result); |
| } |
| LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
| - HArithmeticBinaryOperation* instr) { |
| - ASSERT(op == Token::ADD || |
| - op == Token::DIV || |
| - op == Token::MOD || |
| - op == Token::MUL || |
| - op == Token::SUB); |
| + HBinaryOperation* instr) { |
| HValue* left = instr->left(); |
| HValue* right = instr->right(); |
| ASSERT(left->representation().IsTagged()); |
| @@ -1347,27 +1343,19 @@ LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
| if (instr->representation().IsSmiOrInteger32()) { |
| ASSERT(instr->left()->representation().Equals(instr->representation())); |
| ASSERT(instr->right()->representation().Equals(instr->representation())); |
| + ASSERT(instr->CheckFlag(HValue::kTruncatingToInt32)); |
| LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
| return DefineAsRegister(new(zone()) LBitI(left, right)); |
| } else { |
| - ASSERT(instr->representation().IsTagged()); |
| - ASSERT(instr->left()->representation().IsTagged()); |
| - ASSERT(instr->right()->representation().IsTagged()); |
| - |
| - LOperand* left = UseFixed(instr->left(), r1); |
| - LOperand* right = UseFixed(instr->right(), r0); |
| - LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
| - return MarkAsCall(DefineFixed(result, r0), instr); |
| + return DoArithmeticT(instr->op(), instr); |
| } |
| } |
| LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
| - if (instr->representation().IsDouble()) { |
| - return DoArithmeticD(Token::DIV, instr); |
| - } else if (instr->representation().IsSmiOrInteger32()) { |
| + if (instr->representation().IsSmiOrInteger32()) { |
| ASSERT(instr->left()->representation().Equals(instr->representation())); |
| ASSERT(instr->right()->representation().Equals(instr->representation())); |
| if (instr->HasPowerOf2Divisor()) { |
| @@ -1381,6 +1369,8 @@ LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
| LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d4); |
| LDivI* div = new(zone()) LDivI(dividend, divisor, temp); |
| return AssignEnvironment(DefineAsRegister(div)); |
| + } else if (instr->representation().IsDouble()) { |
| + return DoArithmeticD(Token::DIV, instr); |
| } else { |
| return DoArithmeticT(Token::DIV, instr); |
| } |
| @@ -1501,17 +1491,10 @@ LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
| ? AssignEnvironment(result) |
| : result; |
| } |
| - } else if (instr->representation().IsTagged()) { |
| - return DoArithmeticT(Token::MOD, instr); |
| + } else if (instr->representation().IsDouble()) { |
| + return DoArithmeticD(Token::MOD, instr); |
| } else { |
| - ASSERT(instr->representation().IsDouble()); |
| - // We call a C function for double modulo. It can't trigger a GC. We need |
| - // to use fixed result register for the call. |
| - // TODO(fschneider): Allow any register as input registers. |
| - LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD, |
| - UseFixedDouble(left, d1), |
| - UseFixedDouble(right, d2)); |
| - return MarkAsCall(DefineFixedDouble(mod, d1), instr); |
| + return DoArithmeticT(Token::MOD, instr); |
| } |
| } |
| @@ -1678,7 +1661,6 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
| return DoArithmeticD(Token::ADD, instr); |
| } else { |
| - ASSERT(instr->representation().IsTagged()); |
| return DoArithmeticT(Token::ADD, instr); |
| } |
| } |