OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 compiler::Node* context) { | 1644 compiler::Node* context) { |
1645 using compiler::Node; | 1645 using compiler::Node; |
1646 | 1646 |
1647 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); | 1647 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
1648 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); | 1648 Node* rhs_value = assembler->TruncateTaggedToWord32(context, right); |
1649 Node* value = assembler->Word32Xor(lhs_value, rhs_value); | 1649 Node* value = assembler->Word32Xor(lhs_value, rhs_value); |
1650 Node* result = assembler->ChangeInt32ToTagged(value); | 1650 Node* result = assembler->ChangeInt32ToTagged(value); |
1651 return result; | 1651 return result; |
1652 } | 1652 } |
1653 | 1653 |
1654 void IncStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1654 // static |
| 1655 compiler::Node* IncStub::Generate(CodeStubAssembler* assembler, |
| 1656 compiler::Node* value, |
| 1657 compiler::Node* context) { |
1655 typedef CodeStubAssembler::Label Label; | 1658 typedef CodeStubAssembler::Label Label; |
1656 typedef compiler::Node Node; | 1659 typedef compiler::Node Node; |
1657 typedef CodeStubAssembler::Variable Variable; | 1660 typedef CodeStubAssembler::Variable Variable; |
1658 | 1661 |
1659 Node* context = assembler->Parameter(1); | |
1660 | |
1661 // Shared entry for floating point increment. | 1662 // Shared entry for floating point increment. |
1662 Label do_finc(assembler); | 1663 Label do_finc(assembler), end(assembler); |
1663 Variable var_finc_value(assembler, MachineRepresentation::kFloat64); | 1664 Variable var_finc_value(assembler, MachineRepresentation::kFloat64); |
1664 | 1665 |
1665 // We might need to try again due to ToNumber conversion. | 1666 // We might need to try again due to ToNumber conversion. |
1666 Variable value_var(assembler, MachineRepresentation::kTagged); | 1667 Variable value_var(assembler, MachineRepresentation::kTagged); |
| 1668 Variable result_var(assembler, MachineRepresentation::kTagged); |
1667 Label start(assembler, &value_var); | 1669 Label start(assembler, &value_var); |
1668 value_var.Bind(assembler->Parameter(0)); | 1670 value_var.Bind(value); |
1669 assembler->Goto(&start); | 1671 assembler->Goto(&start); |
1670 assembler->Bind(&start); | 1672 assembler->Bind(&start); |
1671 { | 1673 { |
1672 Node* value = value_var.value(); | 1674 value = value_var.value(); |
1673 | 1675 |
1674 Label if_issmi(assembler), if_isnotsmi(assembler); | 1676 Label if_issmi(assembler), if_isnotsmi(assembler); |
1675 assembler->Branch(assembler->WordIsSmi(value), &if_issmi, &if_isnotsmi); | 1677 assembler->Branch(assembler->WordIsSmi(value), &if_issmi, &if_isnotsmi); |
1676 | 1678 |
1677 assembler->Bind(&if_issmi); | 1679 assembler->Bind(&if_issmi); |
1678 { | 1680 { |
1679 // Try fast Smi addition first. | 1681 // Try fast Smi addition first. |
1680 Node* one = assembler->SmiConstant(Smi::FromInt(1)); | 1682 Node* one = assembler->SmiConstant(Smi::FromInt(1)); |
1681 Node* pair = assembler->SmiAddWithOverflow(value, one); | 1683 Node* pair = assembler->SmiAddWithOverflow(value, one); |
1682 Node* overflow = assembler->Projection(1, pair); | 1684 Node* overflow = assembler->Projection(1, pair); |
1683 | 1685 |
1684 // Check if the Smi additon overflowed. | 1686 // Check if the Smi additon overflowed. |
1685 Label if_overflow(assembler), if_notoverflow(assembler); | 1687 Label if_overflow(assembler), if_notoverflow(assembler); |
1686 assembler->Branch(overflow, &if_overflow, &if_notoverflow); | 1688 assembler->Branch(overflow, &if_overflow, &if_notoverflow); |
1687 | 1689 |
1688 assembler->Bind(&if_notoverflow); | 1690 assembler->Bind(&if_notoverflow); |
1689 assembler->Return(assembler->Projection(0, pair)); | 1691 result_var.Bind(assembler->Projection(0, pair)); |
| 1692 assembler->Goto(&end); |
1690 | 1693 |
1691 assembler->Bind(&if_overflow); | 1694 assembler->Bind(&if_overflow); |
1692 { | 1695 { |
1693 var_finc_value.Bind(assembler->SmiToFloat64(value)); | 1696 var_finc_value.Bind(assembler->SmiToFloat64(value)); |
1694 assembler->Goto(&do_finc); | 1697 assembler->Goto(&do_finc); |
1695 } | 1698 } |
1696 } | 1699 } |
1697 | 1700 |
1698 assembler->Bind(&if_isnotsmi); | 1701 assembler->Bind(&if_isnotsmi); |
1699 { | 1702 { |
1700 // Check if the value is a HeapNumber. | 1703 // Check if the value is a HeapNumber. |
1701 Label if_valueisnumber(assembler), | 1704 Label if_valueisnumber(assembler), |
1702 if_valuenotnumber(assembler, Label::kDeferred); | 1705 if_valuenotnumber(assembler, Label::kDeferred); |
1703 Node* value_map = assembler->LoadMap(value); | 1706 Node* value_map = assembler->LoadMap(value); |
1704 Node* number_map = assembler->HeapNumberMapConstant(); | 1707 Node* number_map = assembler->HeapNumberMapConstant(); |
1705 assembler->Branch(assembler->WordEqual(value_map, number_map), | 1708 assembler->Branch(assembler->WordEqual(value_map, number_map), |
1706 &if_valueisnumber, &if_valuenotnumber); | 1709 &if_valueisnumber, &if_valuenotnumber); |
1707 | 1710 |
1708 assembler->Bind(&if_valueisnumber); | 1711 assembler->Bind(&if_valueisnumber); |
1709 { | 1712 { |
1710 // Load the HeapNumber value. | 1713 // Load the HeapNumber value. |
1711 var_finc_value.Bind(assembler->LoadHeapNumberValue(value)); | 1714 var_finc_value.Bind(assembler->LoadHeapNumberValue(value)); |
1712 assembler->Goto(&do_finc); | 1715 assembler->Goto(&do_finc); |
1713 } | 1716 } |
1714 | 1717 |
1715 assembler->Bind(&if_valuenotnumber); | 1718 assembler->Bind(&if_valuenotnumber); |
1716 { | 1719 { |
1717 // Convert to a Number first and try again. | 1720 // Convert to a Number first and try again. |
1718 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1721 Callable callable = |
| 1722 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1719 value_var.Bind(assembler->CallStub(callable, context, value)); | 1723 value_var.Bind(assembler->CallStub(callable, context, value)); |
1720 assembler->Goto(&start); | 1724 assembler->Goto(&start); |
1721 } | 1725 } |
1722 } | 1726 } |
1723 } | 1727 } |
1724 | 1728 |
1725 assembler->Bind(&do_finc); | 1729 assembler->Bind(&do_finc); |
1726 { | 1730 { |
1727 Node* finc_value = var_finc_value.value(); | 1731 Node* finc_value = var_finc_value.value(); |
1728 Node* one = assembler->Float64Constant(1.0); | 1732 Node* one = assembler->Float64Constant(1.0); |
1729 Node* finc_result = assembler->Float64Add(finc_value, one); | 1733 Node* finc_result = assembler->Float64Add(finc_value, one); |
1730 Node* result = assembler->ChangeFloat64ToTagged(finc_result); | 1734 result_var.Bind(assembler->ChangeFloat64ToTagged(finc_result)); |
1731 assembler->Return(result); | 1735 assembler->Goto(&end); |
1732 } | 1736 } |
| 1737 |
| 1738 assembler->Bind(&end); |
| 1739 return result_var.value(); |
1733 } | 1740 } |
1734 | 1741 |
1735 void DecStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1742 // static |
| 1743 compiler::Node* DecStub::Generate(CodeStubAssembler* assembler, |
| 1744 compiler::Node* value, |
| 1745 compiler::Node* context) { |
1736 typedef CodeStubAssembler::Label Label; | 1746 typedef CodeStubAssembler::Label Label; |
1737 typedef compiler::Node Node; | 1747 typedef compiler::Node Node; |
1738 typedef CodeStubAssembler::Variable Variable; | 1748 typedef CodeStubAssembler::Variable Variable; |
1739 | 1749 |
1740 Node* context = assembler->Parameter(1); | |
1741 | |
1742 // Shared entry for floating point decrement. | 1750 // Shared entry for floating point decrement. |
1743 Label do_fdec(assembler); | 1751 Label do_fdec(assembler), end(assembler); |
1744 Variable var_fdec_value(assembler, MachineRepresentation::kFloat64); | 1752 Variable var_fdec_value(assembler, MachineRepresentation::kFloat64); |
1745 | 1753 |
1746 // We might need to try again due to ToNumber conversion. | 1754 // We might need to try again due to ToNumber conversion. |
1747 Variable value_var(assembler, MachineRepresentation::kTagged); | 1755 Variable value_var(assembler, MachineRepresentation::kTagged); |
| 1756 Variable result_var(assembler, MachineRepresentation::kTagged); |
1748 Label start(assembler, &value_var); | 1757 Label start(assembler, &value_var); |
1749 value_var.Bind(assembler->Parameter(0)); | 1758 value_var.Bind(value); |
1750 assembler->Goto(&start); | 1759 assembler->Goto(&start); |
1751 assembler->Bind(&start); | 1760 assembler->Bind(&start); |
1752 { | 1761 { |
1753 Node* value = value_var.value(); | 1762 value = value_var.value(); |
1754 | 1763 |
1755 Label if_issmi(assembler), if_isnotsmi(assembler); | 1764 Label if_issmi(assembler), if_isnotsmi(assembler); |
1756 assembler->Branch(assembler->WordIsSmi(value), &if_issmi, &if_isnotsmi); | 1765 assembler->Branch(assembler->WordIsSmi(value), &if_issmi, &if_isnotsmi); |
1757 | 1766 |
1758 assembler->Bind(&if_issmi); | 1767 assembler->Bind(&if_issmi); |
1759 { | 1768 { |
1760 // Try fast Smi subtraction first. | 1769 // Try fast Smi subtraction first. |
1761 Node* one = assembler->SmiConstant(Smi::FromInt(1)); | 1770 Node* one = assembler->SmiConstant(Smi::FromInt(1)); |
1762 Node* pair = assembler->SmiSubWithOverflow(value, one); | 1771 Node* pair = assembler->SmiSubWithOverflow(value, one); |
1763 Node* overflow = assembler->Projection(1, pair); | 1772 Node* overflow = assembler->Projection(1, pair); |
1764 | 1773 |
1765 // Check if the Smi subtraction overflowed. | 1774 // Check if the Smi subtraction overflowed. |
1766 Label if_overflow(assembler), if_notoverflow(assembler); | 1775 Label if_overflow(assembler), if_notoverflow(assembler); |
1767 assembler->Branch(overflow, &if_overflow, &if_notoverflow); | 1776 assembler->Branch(overflow, &if_overflow, &if_notoverflow); |
1768 | 1777 |
1769 assembler->Bind(&if_notoverflow); | 1778 assembler->Bind(&if_notoverflow); |
1770 assembler->Return(assembler->Projection(0, pair)); | 1779 result_var.Bind(assembler->Projection(0, pair)); |
| 1780 assembler->Goto(&end); |
1771 | 1781 |
1772 assembler->Bind(&if_overflow); | 1782 assembler->Bind(&if_overflow); |
1773 { | 1783 { |
1774 var_fdec_value.Bind(assembler->SmiToFloat64(value)); | 1784 var_fdec_value.Bind(assembler->SmiToFloat64(value)); |
1775 assembler->Goto(&do_fdec); | 1785 assembler->Goto(&do_fdec); |
1776 } | 1786 } |
1777 } | 1787 } |
1778 | 1788 |
1779 assembler->Bind(&if_isnotsmi); | 1789 assembler->Bind(&if_isnotsmi); |
1780 { | 1790 { |
1781 // Check if the value is a HeapNumber. | 1791 // Check if the value is a HeapNumber. |
1782 Label if_valueisnumber(assembler), | 1792 Label if_valueisnumber(assembler), |
1783 if_valuenotnumber(assembler, Label::kDeferred); | 1793 if_valuenotnumber(assembler, Label::kDeferred); |
1784 Node* value_map = assembler->LoadMap(value); | 1794 Node* value_map = assembler->LoadMap(value); |
1785 Node* number_map = assembler->HeapNumberMapConstant(); | 1795 Node* number_map = assembler->HeapNumberMapConstant(); |
1786 assembler->Branch(assembler->WordEqual(value_map, number_map), | 1796 assembler->Branch(assembler->WordEqual(value_map, number_map), |
1787 &if_valueisnumber, &if_valuenotnumber); | 1797 &if_valueisnumber, &if_valuenotnumber); |
1788 | 1798 |
1789 assembler->Bind(&if_valueisnumber); | 1799 assembler->Bind(&if_valueisnumber); |
1790 { | 1800 { |
1791 // Load the HeapNumber value. | 1801 // Load the HeapNumber value. |
1792 var_fdec_value.Bind(assembler->LoadHeapNumberValue(value)); | 1802 var_fdec_value.Bind(assembler->LoadHeapNumberValue(value)); |
1793 assembler->Goto(&do_fdec); | 1803 assembler->Goto(&do_fdec); |
1794 } | 1804 } |
1795 | 1805 |
1796 assembler->Bind(&if_valuenotnumber); | 1806 assembler->Bind(&if_valuenotnumber); |
1797 { | 1807 { |
1798 // Convert to a Number first and try again. | 1808 // Convert to a Number first and try again. |
1799 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 1809 Callable callable = |
| 1810 CodeFactory::NonNumberToNumber(assembler->isolate()); |
1800 value_var.Bind(assembler->CallStub(callable, context, value)); | 1811 value_var.Bind(assembler->CallStub(callable, context, value)); |
1801 assembler->Goto(&start); | 1812 assembler->Goto(&start); |
1802 } | 1813 } |
1803 } | 1814 } |
1804 } | 1815 } |
1805 | 1816 |
1806 assembler->Bind(&do_fdec); | 1817 assembler->Bind(&do_fdec); |
1807 { | 1818 { |
1808 Node* fdec_value = var_fdec_value.value(); | 1819 Node* fdec_value = var_fdec_value.value(); |
1809 Node* one = assembler->Float64Constant(1.0); | 1820 Node* one = assembler->Float64Constant(1.0); |
1810 Node* fdec_result = assembler->Float64Sub(fdec_value, one); | 1821 Node* fdec_result = assembler->Float64Sub(fdec_value, one); |
1811 Node* result = assembler->ChangeFloat64ToTagged(fdec_result); | 1822 result_var.Bind(assembler->ChangeFloat64ToTagged(fdec_result)); |
1812 assembler->Return(result); | 1823 assembler->Goto(&end); |
1813 } | 1824 } |
| 1825 |
| 1826 assembler->Bind(&end); |
| 1827 return result_var.value(); |
1814 } | 1828 } |
1815 | 1829 |
1816 void InstanceOfStub::GenerateAssembly(CodeStubAssembler* assembler) const { | 1830 void InstanceOfStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
1817 typedef CodeStubAssembler::Label Label; | 1831 typedef CodeStubAssembler::Label Label; |
1818 typedef compiler::Node Node; | 1832 typedef compiler::Node Node; |
1819 | 1833 |
1820 Node* object = assembler->Parameter(0); | 1834 Node* object = assembler->Parameter(0); |
1821 Node* callable = assembler->Parameter(1); | 1835 Node* callable = assembler->Parameter(1); |
1822 Node* context = assembler->Parameter(2); | 1836 Node* context = assembler->Parameter(2); |
1823 | 1837 |
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4519 if (type->Is(Type::UntaggedPointer())) { | 4533 if (type->Is(Type::UntaggedPointer())) { |
4520 return Representation::External(); | 4534 return Representation::External(); |
4521 } | 4535 } |
4522 | 4536 |
4523 DCHECK(!type->Is(Type::Untagged())); | 4537 DCHECK(!type->Is(Type::Untagged())); |
4524 return Representation::Tagged(); | 4538 return Representation::Tagged(); |
4525 } | 4539 } |
4526 | 4540 |
4527 } // namespace internal | 4541 } // namespace internal |
4528 } // namespace v8 | 4542 } // namespace v8 |
OLD | NEW |