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 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 void LCodeGen::DoModByConstI(LModByConstI* instr) { | 1407 void LCodeGen::DoModByConstI(LModByConstI* instr) { |
1408 Register dividend = ToRegister(instr->dividend()); | 1408 Register dividend = ToRegister(instr->dividend()); |
1409 int32_t divisor = instr->divisor(); | 1409 int32_t divisor = instr->divisor(); |
1410 ASSERT(ToRegister(instr->result()).is(eax)); | 1410 ASSERT(ToRegister(instr->result()).is(eax)); |
1411 | 1411 |
1412 if (divisor == 0) { | 1412 if (divisor == 0) { |
1413 DeoptimizeIf(no_condition, instr->environment()); | 1413 DeoptimizeIf(no_condition, instr->environment()); |
1414 return; | 1414 return; |
1415 } | 1415 } |
1416 | 1416 |
1417 __ FlooringDiv(dividend, Abs(divisor)); | 1417 __ TruncatingDiv(dividend, Abs(divisor)); |
1418 __ mov(eax, dividend); | |
1419 __ shr(eax, 31); | |
1420 __ add(edx, eax); | |
1421 __ imul(edx, edx, Abs(divisor)); | 1418 __ imul(edx, edx, Abs(divisor)); |
1422 __ mov(eax, dividend); | 1419 __ mov(eax, dividend); |
1423 __ sub(eax, edx); | 1420 __ sub(eax, edx); |
1424 | 1421 |
1425 // Check for negative zero. | 1422 // Check for negative zero. |
1426 HMod* hmod = instr->hydrogen(); | 1423 HMod* hmod = instr->hydrogen(); |
1427 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1424 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1428 Label remainder_not_zero; | 1425 Label remainder_not_zero; |
1429 __ j(not_zero, &remainder_not_zero, Label::kNear); | 1426 __ j(not_zero, &remainder_not_zero, Label::kNear); |
1430 __ cmp(dividend, Immediate(0)); | 1427 __ cmp(dividend, Immediate(0)); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 return; | 1534 return; |
1538 } | 1535 } |
1539 | 1536 |
1540 // Check for (0 / -x) that will produce negative zero. | 1537 // Check for (0 / -x) that will produce negative zero. |
1541 HDiv* hdiv = instr->hydrogen(); | 1538 HDiv* hdiv = instr->hydrogen(); |
1542 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1539 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
1543 __ test(dividend, dividend); | 1540 __ test(dividend, dividend); |
1544 DeoptimizeIf(zero, instr->environment()); | 1541 DeoptimizeIf(zero, instr->environment()); |
1545 } | 1542 } |
1546 | 1543 |
1547 __ FlooringDiv(dividend, Abs(divisor)); | 1544 __ TruncatingDiv(dividend, Abs(divisor)); |
1548 __ mov(eax, dividend); | |
1549 __ shr(eax, 31); | |
1550 __ add(edx, eax); | |
1551 if (divisor < 0) __ neg(edx); | 1545 if (divisor < 0) __ neg(edx); |
1552 | 1546 |
1553 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { | 1547 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { |
1554 __ mov(eax, edx); | 1548 __ mov(eax, edx); |
1555 __ imul(eax, eax, divisor); | 1549 __ imul(eax, eax, divisor); |
1556 __ sub(eax, dividend); | 1550 __ sub(eax, dividend); |
1557 DeoptimizeIf(not_equal, instr->environment()); | 1551 DeoptimizeIf(not_equal, instr->environment()); |
1558 } | 1552 } |
1559 } | 1553 } |
1560 | 1554 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 return; | 1658 return; |
1665 } | 1659 } |
1666 | 1660 |
1667 // Check for (0 / -x) that will produce negative zero. | 1661 // Check for (0 / -x) that will produce negative zero. |
1668 HMathFloorOfDiv* hdiv = instr->hydrogen(); | 1662 HMathFloorOfDiv* hdiv = instr->hydrogen(); |
1669 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1663 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { |
1670 __ test(dividend, dividend); | 1664 __ test(dividend, dividend); |
1671 DeoptimizeIf(zero, instr->environment()); | 1665 DeoptimizeIf(zero, instr->environment()); |
1672 } | 1666 } |
1673 | 1667 |
1674 __ FlooringDiv(dividend, divisor); | 1668 // TODO(svenpanne) Add correction terms. |
| 1669 __ TruncatingDiv(dividend, divisor); |
1675 } | 1670 } |
1676 | 1671 |
1677 | 1672 |
1678 void LCodeGen::DoMulI(LMulI* instr) { | 1673 void LCodeGen::DoMulI(LMulI* instr) { |
1679 Register left = ToRegister(instr->left()); | 1674 Register left = ToRegister(instr->left()); |
1680 LOperand* right = instr->right(); | 1675 LOperand* right = instr->right(); |
1681 | 1676 |
1682 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1677 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1683 __ mov(ToRegister(instr->temp()), left); | 1678 __ mov(ToRegister(instr->temp()), left); |
1684 } | 1679 } |
(...skipping 4651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6336 FixedArray::kHeaderSize - kPointerSize)); | 6331 FixedArray::kHeaderSize - kPointerSize)); |
6337 __ bind(&done); | 6332 __ bind(&done); |
6338 } | 6333 } |
6339 | 6334 |
6340 | 6335 |
6341 #undef __ | 6336 #undef __ |
6342 | 6337 |
6343 } } // namespace v8::internal | 6338 } } // namespace v8::internal |
6344 | 6339 |
6345 #endif // V8_TARGET_ARCH_IA32 | 6340 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |