| 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 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 Register src, | 1577 Register src, |
| 1578 Smi* constant, | 1578 Smi* constant, |
| 1579 Label* on_not_smi_result, | 1579 Label* on_not_smi_result, |
| 1580 Label::Distance near_jump) { | 1580 Label::Distance near_jump) { |
| 1581 if (constant->value() == 0) { | 1581 if (constant->value() == 0) { |
| 1582 if (!dst.is(src)) { | 1582 if (!dst.is(src)) { |
| 1583 movq(dst, src); | 1583 movq(dst, src); |
| 1584 } | 1584 } |
| 1585 } else if (dst.is(src)) { | 1585 } else if (dst.is(src)) { |
| 1586 ASSERT(!dst.is(kScratchRegister)); | 1586 ASSERT(!dst.is(kScratchRegister)); |
| 1587 if (constant->value() == Smi::kMinValue) { | 1587 Label done; |
| 1588 // Subtracting min-value from any non-negative value will overflow. | 1588 LoadSmiConstant(kScratchRegister, constant); |
| 1589 // We test the non-negativeness before doing the subtraction. | 1589 subq(dst, kScratchRegister); |
| 1590 testq(src, src); | 1590 j(no_overflow, &done, Label::kNear); |
| 1591 j(not_sign, on_not_smi_result, near_jump); | 1591 // Restore src. |
| 1592 LoadSmiConstant(kScratchRegister, constant); | 1592 addq(dst, kScratchRegister); |
| 1593 subq(dst, kScratchRegister); | 1593 jmp(on_not_smi_result, near_jump); |
| 1594 } else { | 1594 bind(&done); |
| 1595 // Subtract by adding the negation. | |
| 1596 LoadSmiConstant(kScratchRegister, Smi::FromInt(-constant->value())); | |
| 1597 addq(kScratchRegister, dst); | |
| 1598 j(overflow, on_not_smi_result, near_jump); | |
| 1599 movq(dst, kScratchRegister); | |
| 1600 } | |
| 1601 } else { | 1595 } else { |
| 1602 if (constant->value() == Smi::kMinValue) { | 1596 if (constant->value() == Smi::kMinValue) { |
| 1603 // Subtracting min-value from any non-negative value will overflow. | 1597 // Subtracting min-value from any non-negative value will overflow. |
| 1604 // We test the non-negativeness before doing the subtraction. | 1598 // We test the non-negativeness before doing the subtraction. |
| 1605 testq(src, src); | 1599 testq(src, src); |
| 1606 j(not_sign, on_not_smi_result, near_jump); | 1600 j(not_sign, on_not_smi_result, near_jump); |
| 1607 LoadSmiConstant(dst, constant); | 1601 LoadSmiConstant(dst, constant); |
| 1608 // Adding and subtracting the min-value gives the same result, it only | 1602 // No overflow. |
| 1609 // differs on the overflow bit, which we don't check here. | |
| 1610 addq(dst, src); | 1603 addq(dst, src); |
| 1611 } else { | 1604 } else { |
| 1612 // Subtract by adding the negation. | 1605 // Subtract by adding the negation. |
| 1613 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); | 1606 LoadSmiConstant(dst, Smi::FromInt(-(constant->value()))); |
| 1614 addq(dst, src); | 1607 addq(dst, src); |
| 1615 j(overflow, on_not_smi_result, near_jump); | 1608 j(overflow, on_not_smi_result, near_jump); |
| 1616 } | 1609 } |
| 1617 } | 1610 } |
| 1618 } | 1611 } |
| 1619 | 1612 |
| (...skipping 3297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4917 j(greater, &no_memento_available); | 4910 j(greater, &no_memento_available); |
| 4918 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4911 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 4919 Heap::kAllocationMementoMapRootIndex); | 4912 Heap::kAllocationMementoMapRootIndex); |
| 4920 bind(&no_memento_available); | 4913 bind(&no_memento_available); |
| 4921 } | 4914 } |
| 4922 | 4915 |
| 4923 | 4916 |
| 4924 } } // namespace v8::internal | 4917 } } // namespace v8::internal |
| 4925 | 4918 |
| 4926 #endif // V8_TARGET_ARCH_X64 | 4919 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |