OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
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 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 | 1423 |
1424 if (bailout_on_minus_zero && (constant < 0)) { | 1424 if (bailout_on_minus_zero && (constant < 0)) { |
1425 // The case of a null constant will be handled separately. | 1425 // The case of a null constant will be handled separately. |
1426 // If constant is negative and left is null, the result should be -0. | 1426 // If constant is negative and left is null, the result should be -0. |
1427 DeoptimizeIf(eq, instr, Deoptimizer::kMinusZero, left, Operand(zero_reg)); | 1427 DeoptimizeIf(eq, instr, Deoptimizer::kMinusZero, left, Operand(zero_reg)); |
1428 } | 1428 } |
1429 | 1429 |
1430 switch (constant) { | 1430 switch (constant) { |
1431 case -1: | 1431 case -1: |
1432 if (overflow) { | 1432 if (overflow) { |
1433 __ SubuAndCheckForOverflow(result, zero_reg, left, scratch); | 1433 Label no_overflow; |
1434 DeoptimizeIf(lt, instr, Deoptimizer::kOverflow, scratch, | 1434 __ SubBranchNoOvf(result, zero_reg, Operand(left), &no_overflow); |
1435 Operand(zero_reg)); | 1435 DeoptimizeIf(al, instr); |
| 1436 __ bind(&no_overflow); |
1436 } else { | 1437 } else { |
1437 __ Subu(result, zero_reg, left); | 1438 __ Subu(result, zero_reg, left); |
1438 } | 1439 } |
1439 break; | 1440 break; |
1440 case 0: | 1441 case 0: |
1441 if (bailout_on_minus_zero) { | 1442 if (bailout_on_minus_zero) { |
1442 // If left is strictly negative and the constant is null, the | 1443 // If left is strictly negative and the constant is null, the |
1443 // result is -0. Deoptimize if required, otherwise return 0. | 1444 // result is -0. Deoptimize if required, otherwise return 0. |
1444 DeoptimizeIf(lt, instr, Deoptimizer::kMinusZero, left, | 1445 DeoptimizeIf(lt, instr, Deoptimizer::kMinusZero, left, |
1445 Operand(zero_reg)); | 1446 Operand(zero_reg)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 | 1652 |
1652 if (!can_overflow) { | 1653 if (!can_overflow) { |
1653 if (right->IsStackSlot()) { | 1654 if (right->IsStackSlot()) { |
1654 Register right_reg = EmitLoadRegister(right, at); | 1655 Register right_reg = EmitLoadRegister(right, at); |
1655 __ Subu(ToRegister(result), ToRegister(left), Operand(right_reg)); | 1656 __ Subu(ToRegister(result), ToRegister(left), Operand(right_reg)); |
1656 } else { | 1657 } else { |
1657 DCHECK(right->IsRegister() || right->IsConstantOperand()); | 1658 DCHECK(right->IsRegister() || right->IsConstantOperand()); |
1658 __ Subu(ToRegister(result), ToRegister(left), ToOperand(right)); | 1659 __ Subu(ToRegister(result), ToRegister(left), ToOperand(right)); |
1659 } | 1660 } |
1660 } else { // can_overflow. | 1661 } else { // can_overflow. |
1661 Register overflow = scratch0(); | 1662 Register scratch = scratch0(); |
1662 Register scratch = scratch1(); | 1663 Label no_overflow_label; |
1663 if (right->IsStackSlot()) { | 1664 if (right->IsStackSlot()) { |
1664 Register right_reg = EmitLoadRegister(right, scratch); | 1665 Register right_reg = EmitLoadRegister(right, scratch); |
1665 __ SubuAndCheckForOverflow(ToRegister(result), | 1666 __ SubBranchNoOvf(ToRegister(result), ToRegister(left), |
1666 ToRegister(left), | 1667 Operand(right_reg), &no_overflow_label); |
1667 right_reg, | |
1668 overflow); // Reg at also used as scratch. | |
1669 } else { | 1668 } else { |
1670 DCHECK(right->IsRegister() || right->IsConstantOperand()); | 1669 DCHECK(right->IsRegister() || right->IsConstantOperand()); |
1671 __ SubuAndCheckForOverflow(ToRegister(result), ToRegister(left), | 1670 __ SubBranchNoOvf(ToRegister(result), ToRegister(left), ToOperand(right), |
1672 ToOperand(right), overflow, scratch); | 1671 &no_overflow_label, scratch); |
1673 } | 1672 } |
1674 DeoptimizeIf(lt, instr, Deoptimizer::kOverflow, overflow, | 1673 DeoptimizeIf(al, instr); |
1675 Operand(zero_reg)); | 1674 __ bind(&no_overflow_label); |
1676 } | 1675 } |
1677 } | 1676 } |
1678 | 1677 |
1679 | 1678 |
1680 void LCodeGen::DoConstantI(LConstantI* instr) { | 1679 void LCodeGen::DoConstantI(LConstantI* instr) { |
1681 __ li(ToRegister(instr->result()), Operand(instr->value())); | 1680 __ li(ToRegister(instr->result()), Operand(instr->value())); |
1682 } | 1681 } |
1683 | 1682 |
1684 | 1683 |
1685 void LCodeGen::DoConstantS(LConstantS* instr) { | 1684 void LCodeGen::DoConstantS(LConstantS* instr) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 | 1846 |
1848 if (!can_overflow) { | 1847 if (!can_overflow) { |
1849 if (right->IsStackSlot()) { | 1848 if (right->IsStackSlot()) { |
1850 Register right_reg = EmitLoadRegister(right, at); | 1849 Register right_reg = EmitLoadRegister(right, at); |
1851 __ Addu(ToRegister(result), ToRegister(left), Operand(right_reg)); | 1850 __ Addu(ToRegister(result), ToRegister(left), Operand(right_reg)); |
1852 } else { | 1851 } else { |
1853 DCHECK(right->IsRegister() || right->IsConstantOperand()); | 1852 DCHECK(right->IsRegister() || right->IsConstantOperand()); |
1854 __ Addu(ToRegister(result), ToRegister(left), ToOperand(right)); | 1853 __ Addu(ToRegister(result), ToRegister(left), ToOperand(right)); |
1855 } | 1854 } |
1856 } else { // can_overflow. | 1855 } else { // can_overflow. |
1857 Register overflow = scratch0(); | |
1858 Register scratch = scratch1(); | 1856 Register scratch = scratch1(); |
| 1857 Label no_overflow_label; |
1859 if (right->IsStackSlot()) { | 1858 if (right->IsStackSlot()) { |
1860 Register right_reg = EmitLoadRegister(right, scratch); | 1859 Register right_reg = EmitLoadRegister(right, scratch); |
1861 __ AdduAndCheckForOverflow(ToRegister(result), | 1860 __ AddBranchNoOvf(ToRegister(result), ToRegister(left), |
1862 ToRegister(left), | 1861 Operand(right_reg), &no_overflow_label); |
1863 right_reg, | |
1864 overflow); // Reg at also used as scratch. | |
1865 } else { | 1862 } else { |
1866 DCHECK(right->IsRegister() || right->IsConstantOperand()); | 1863 DCHECK(right->IsRegister() || right->IsConstantOperand()); |
1867 __ AdduAndCheckForOverflow(ToRegister(result), ToRegister(left), | 1864 __ AddBranchNoOvf(ToRegister(result), ToRegister(left), ToOperand(right), |
1868 ToOperand(right), overflow, scratch); | 1865 &no_overflow_label, scratch); |
1869 } | 1866 } |
1870 DeoptimizeIf(lt, instr, Deoptimizer::kOverflow, overflow, | 1867 DeoptimizeIf(al, instr); |
1871 Operand(zero_reg)); | 1868 __ bind(&no_overflow_label); |
1872 } | 1869 } |
1873 } | 1870 } |
1874 | 1871 |
1875 | 1872 |
1876 void LCodeGen::DoMathMinMax(LMathMinMax* instr) { | 1873 void LCodeGen::DoMathMinMax(LMathMinMax* instr) { |
1877 LOperand* left = instr->left(); | 1874 LOperand* left = instr->left(); |
1878 LOperand* right = instr->right(); | 1875 LOperand* right = instr->right(); |
1879 HMathMinMax::Operation operation = instr->hydrogen()->operation(); | 1876 HMathMinMax::Operation operation = instr->hydrogen()->operation(); |
1880 Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge; | 1877 Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge; |
1881 if (instr->hydrogen()->representation().IsSmiOrInteger32()) { | 1878 if (instr->hydrogen()->representation().IsSmiOrInteger32()) { |
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5765 __ Push(at, ToRegister(instr->function())); | 5762 __ Push(at, ToRegister(instr->function())); |
5766 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5763 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5767 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5764 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5768 } | 5765 } |
5769 | 5766 |
5770 | 5767 |
5771 #undef __ | 5768 #undef __ |
5772 | 5769 |
5773 } // namespace internal | 5770 } // namespace internal |
5774 } // namespace v8 | 5771 } // namespace v8 |
OLD | NEW |