Chromium Code Reviews| 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 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1530 Smi* constant, | 1530 Smi* constant, |
| 1531 Label* on_not_smi_result, | 1531 Label* on_not_smi_result, |
| 1532 Label::Distance near_jump) { | 1532 Label::Distance near_jump) { |
| 1533 if (constant->value() == 0) { | 1533 if (constant->value() == 0) { |
| 1534 if (!dst.is(src)) { | 1534 if (!dst.is(src)) { |
| 1535 movq(dst, src); | 1535 movq(dst, src); |
| 1536 } | 1536 } |
| 1537 } else if (dst.is(src)) { | 1537 } else if (dst.is(src)) { |
| 1538 ASSERT(!dst.is(kScratchRegister)); | 1538 ASSERT(!dst.is(kScratchRegister)); |
| 1539 | 1539 |
| 1540 Label done; | |
| 1540 LoadSmiConstant(kScratchRegister, constant); | 1541 LoadSmiConstant(kScratchRegister, constant); |
| 1541 addq(kScratchRegister, src); | 1542 addq(dst, kScratchRegister); |
| 1542 j(overflow, on_not_smi_result, near_jump); | 1543 j(no_overflow, &done, Label::kNear); |
| 1543 movq(dst, kScratchRegister); | 1544 // Restore src. |
| 1545 subq(dst, kScratchRegister); | |
|
danno
2013/10/02 08:57:07
This is probably OK for now, but probably slightly
| |
| 1546 jmp(on_not_smi_result, near_jump); | |
| 1547 bind(&done); | |
| 1544 } else { | 1548 } else { |
| 1545 LoadSmiConstant(dst, constant); | 1549 LoadSmiConstant(dst, constant); |
| 1546 addq(dst, src); | 1550 addq(dst, src); |
| 1547 j(overflow, on_not_smi_result, near_jump); | 1551 j(overflow, on_not_smi_result, near_jump); |
| 1548 } | 1552 } |
| 1549 } | 1553 } |
| 1550 | 1554 |
| 1551 | 1555 |
| 1552 void MacroAssembler::SmiSubConstant(Register dst, Register src, Smi* constant) { | 1556 void MacroAssembler::SmiSubConstant(Register dst, Register src, Smi* constant) { |
| 1553 if (constant->value() == 0) { | 1557 if (constant->value() == 0) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1633 } else { | 1637 } else { |
| 1634 movq(dst, src); | 1638 movq(dst, src); |
| 1635 neg(dst); | 1639 neg(dst); |
| 1636 cmpq(dst, src); | 1640 cmpq(dst, src); |
| 1637 // If the result is zero or Smi::kMinValue, negation failed to create a smi. | 1641 // If the result is zero or Smi::kMinValue, negation failed to create a smi. |
| 1638 j(not_equal, on_smi_result, near_jump); | 1642 j(not_equal, on_smi_result, near_jump); |
| 1639 } | 1643 } |
| 1640 } | 1644 } |
| 1641 | 1645 |
| 1642 | 1646 |
| 1647 template<class T> | |
| 1648 static void SmiAddHelper(MacroAssembler* masm, | |
| 1649 Register dst, | |
| 1650 Register src1, | |
| 1651 T src2, | |
| 1652 Label* on_not_smi_result, | |
| 1653 Label::Distance near_jump) { | |
| 1654 if (dst.is(src1)) { | |
| 1655 Label done; | |
| 1656 masm->addq(dst, src2); | |
| 1657 masm->j(no_overflow, &done, Label::kNear); | |
| 1658 // Restore src1. | |
| 1659 masm->subq(dst, src2); | |
| 1660 masm->jmp(on_not_smi_result, near_jump); | |
| 1661 masm->bind(&done); | |
| 1662 } else { | |
| 1663 masm->movq(dst, src1); | |
| 1664 masm->addq(dst, src2); | |
| 1665 masm->j(overflow, on_not_smi_result, near_jump); | |
| 1666 } | |
| 1667 } | |
| 1668 | |
| 1669 | |
| 1643 void MacroAssembler::SmiAdd(Register dst, | 1670 void MacroAssembler::SmiAdd(Register dst, |
| 1644 Register src1, | 1671 Register src1, |
| 1645 Register src2, | 1672 Register src2, |
| 1646 Label* on_not_smi_result, | 1673 Label* on_not_smi_result, |
| 1647 Label::Distance near_jump) { | 1674 Label::Distance near_jump) { |
| 1648 ASSERT_NOT_NULL(on_not_smi_result); | 1675 ASSERT_NOT_NULL(on_not_smi_result); |
| 1649 ASSERT(!dst.is(src2)); | 1676 ASSERT(!dst.is(src2)); |
| 1650 if (dst.is(src1)) { | 1677 SmiAddHelper<Register>(this, dst, src1, src2, on_not_smi_result, near_jump); |
| 1651 movq(kScratchRegister, src1); | |
| 1652 addq(kScratchRegister, src2); | |
| 1653 j(overflow, on_not_smi_result, near_jump); | |
| 1654 movq(dst, kScratchRegister); | |
| 1655 } else { | |
| 1656 movq(dst, src1); | |
| 1657 addq(dst, src2); | |
| 1658 j(overflow, on_not_smi_result, near_jump); | |
| 1659 } | |
| 1660 } | 1678 } |
| 1661 | 1679 |
| 1662 | 1680 |
| 1663 void MacroAssembler::SmiAdd(Register dst, | 1681 void MacroAssembler::SmiAdd(Register dst, |
| 1664 Register src1, | 1682 Register src1, |
| 1665 const Operand& src2, | 1683 const Operand& src2, |
| 1666 Label* on_not_smi_result, | 1684 Label* on_not_smi_result, |
| 1667 Label::Distance near_jump) { | 1685 Label::Distance near_jump) { |
| 1668 ASSERT_NOT_NULL(on_not_smi_result); | 1686 ASSERT_NOT_NULL(on_not_smi_result); |
| 1669 if (dst.is(src1)) { | 1687 ASSERT(!src2.AddressUsesRegister(dst)); |
| 1670 movq(kScratchRegister, src1); | 1688 SmiAddHelper<Operand>(this, dst, src1, src2, on_not_smi_result, near_jump); |
| 1671 addq(kScratchRegister, src2); | |
| 1672 j(overflow, on_not_smi_result, near_jump); | |
| 1673 movq(dst, kScratchRegister); | |
| 1674 } else { | |
| 1675 ASSERT(!src2.AddressUsesRegister(dst)); | |
| 1676 movq(dst, src1); | |
| 1677 addq(dst, src2); | |
| 1678 j(overflow, on_not_smi_result, near_jump); | |
| 1679 } | |
| 1680 } | 1689 } |
| 1681 | 1690 |
| 1682 | 1691 |
| 1683 void MacroAssembler::SmiAdd(Register dst, | 1692 void MacroAssembler::SmiAdd(Register dst, |
| 1684 Register src1, | 1693 Register src1, |
| 1685 Register src2) { | 1694 Register src2) { |
| 1686 // No overflow checking. Use only when it's known that | 1695 // No overflow checking. Use only when it's known that |
| 1687 // overflowing is impossible. | 1696 // overflowing is impossible. |
| 1688 if (!dst.is(src1)) { | 1697 if (!dst.is(src1)) { |
| 1689 if (emit_debug_code()) { | 1698 if (emit_debug_code()) { |
| (...skipping 3227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4917 j(greater, &no_memento_available); | 4926 j(greater, &no_memento_available); |
| 4918 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4927 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 4919 Heap::kAllocationMementoMapRootIndex); | 4928 Heap::kAllocationMementoMapRootIndex); |
| 4920 bind(&no_memento_available); | 4929 bind(&no_memento_available); |
| 4921 } | 4930 } |
| 4922 | 4931 |
| 4923 | 4932 |
| 4924 } } // namespace v8::internal | 4933 } } // namespace v8::internal |
| 4925 | 4934 |
| 4926 #endif // V8_TARGET_ARCH_X64 | 4935 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |