| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 Register dividend = ToRegister(instr->dividend()); | 1154 Register dividend = ToRegister(instr->dividend()); |
| 1155 int32_t divisor = instr->divisor(); | 1155 int32_t divisor = instr->divisor(); |
| 1156 Register result = ToRegister(instr->result()); | 1156 Register result = ToRegister(instr->result()); |
| 1157 ASSERT(!dividend.is(result)); | 1157 ASSERT(!dividend.is(result)); |
| 1158 | 1158 |
| 1159 if (divisor == 0) { | 1159 if (divisor == 0) { |
| 1160 DeoptimizeIf(al, instr->environment()); | 1160 DeoptimizeIf(al, instr->environment()); |
| 1161 return; | 1161 return; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 __ FlooringDiv(result, dividend, Abs(divisor)); | 1164 __ TruncatingDiv(result, dividend, Abs(divisor)); |
| 1165 __ add(result, result, Operand(dividend, LSR, 31)); | |
| 1166 __ mov(ip, Operand(Abs(divisor))); | 1165 __ mov(ip, Operand(Abs(divisor))); |
| 1167 __ smull(result, ip, result, ip); | 1166 __ smull(result, ip, result, ip); |
| 1168 __ sub(result, dividend, result, SetCC); | 1167 __ sub(result, dividend, result, SetCC); |
| 1169 | 1168 |
| 1170 // Check for negative zero. | 1169 // Check for negative zero. |
| 1171 HMod* hmod = instr->hydrogen(); | 1170 HMod* hmod = instr->hydrogen(); |
| 1172 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1171 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1173 Label remainder_not_zero; | 1172 Label remainder_not_zero; |
| 1174 __ b(ne, &remainder_not_zero); | 1173 __ b(ne, &remainder_not_zero); |
| 1175 __ cmp(dividend, Operand::Zero()); | 1174 __ cmp(dividend, Operand::Zero()); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 return; | 1341 return; |
| 1343 } | 1342 } |
| 1344 | 1343 |
| 1345 // Check for (0 / -x) that will produce negative zero. | 1344 // Check for (0 / -x) that will produce negative zero. |
| 1346 HDiv* hdiv = instr->hydrogen(); | 1345 HDiv* hdiv = instr->hydrogen(); |
| 1347 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1346 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
| 1348 __ cmp(dividend, Operand::Zero()); | 1347 __ cmp(dividend, Operand::Zero()); |
| 1349 DeoptimizeIf(eq, instr->environment()); | 1348 DeoptimizeIf(eq, instr->environment()); |
| 1350 } | 1349 } |
| 1351 | 1350 |
| 1352 __ FlooringDiv(result, dividend, Abs(divisor)); | 1351 __ TruncatingDiv(result, dividend, Abs(divisor)); |
| 1353 __ add(result, result, Operand(dividend, LSR, 31)); | |
| 1354 if (divisor < 0) __ rsb(result, result, Operand::Zero()); | 1352 if (divisor < 0) __ rsb(result, result, Operand::Zero()); |
| 1355 | 1353 |
| 1356 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { | 1354 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { |
| 1357 __ mov(ip, Operand(divisor)); | 1355 __ mov(ip, Operand(divisor)); |
| 1358 __ smull(scratch0(), ip, result, ip); | 1356 __ smull(scratch0(), ip, result, ip); |
| 1359 __ sub(scratch0(), scratch0(), dividend, SetCC); | 1357 __ sub(scratch0(), scratch0(), dividend, SetCC); |
| 1360 DeoptimizeIf(ne, instr->environment()); | 1358 DeoptimizeIf(ne, instr->environment()); |
| 1361 } | 1359 } |
| 1362 } | 1360 } |
| 1363 | 1361 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 return; | 1500 return; |
| 1503 } | 1501 } |
| 1504 | 1502 |
| 1505 // Check for (0 / -x) that will produce negative zero. | 1503 // Check for (0 / -x) that will produce negative zero. |
| 1506 HMathFloorOfDiv* hdiv = instr->hydrogen(); | 1504 HMathFloorOfDiv* hdiv = instr->hydrogen(); |
| 1507 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1505 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
| 1508 __ cmp(dividend, Operand::Zero()); | 1506 __ cmp(dividend, Operand::Zero()); |
| 1509 DeoptimizeIf(eq, instr->environment()); | 1507 DeoptimizeIf(eq, instr->environment()); |
| 1510 } | 1508 } |
| 1511 | 1509 |
| 1512 __ FlooringDiv(result, dividend, divisor); | 1510 // TODO(svenpanne) Add correction terms. |
| 1511 __ TruncatingDiv(result, dividend, divisor); |
| 1513 } | 1512 } |
| 1514 | 1513 |
| 1515 | 1514 |
| 1516 void LCodeGen::DoMulI(LMulI* instr) { | 1515 void LCodeGen::DoMulI(LMulI* instr) { |
| 1517 Register result = ToRegister(instr->result()); | 1516 Register result = ToRegister(instr->result()); |
| 1518 // Note that result may alias left. | 1517 // Note that result may alias left. |
| 1519 Register left = ToRegister(instr->left()); | 1518 Register left = ToRegister(instr->left()); |
| 1520 LOperand* right_op = instr->right(); | 1519 LOperand* right_op = instr->right(); |
| 1521 | 1520 |
| 1522 bool bailout_on_minus_zero = | 1521 bool bailout_on_minus_zero = |
| (...skipping 4192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5715 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5714 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5716 __ ldr(result, FieldMemOperand(scratch, | 5715 __ ldr(result, FieldMemOperand(scratch, |
| 5717 FixedArray::kHeaderSize - kPointerSize)); | 5716 FixedArray::kHeaderSize - kPointerSize)); |
| 5718 __ bind(&done); | 5717 __ bind(&done); |
| 5719 } | 5718 } |
| 5720 | 5719 |
| 5721 | 5720 |
| 5722 #undef __ | 5721 #undef __ |
| 5723 | 5722 |
| 5724 } } // namespace v8::internal | 5723 } } // namespace v8::internal |
| OLD | NEW |