Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/mips64/instruction-selector-mips64.cc

Issue 1721103003: [turbofan] Introduce DeoptimizeIf And DeoptimizeUnless common operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 outputs[output_count++] = g.DefineAsRegister(node); 112 outputs[output_count++] = g.DefineAsRegister(node);
113 if (cont->IsSet()) { 113 if (cont->IsSet()) {
114 outputs[output_count++] = g.DefineAsRegister(cont->result()); 114 outputs[output_count++] = g.DefineAsRegister(cont->result());
115 } 115 }
116 116
117 DCHECK_NE(0u, input_count); 117 DCHECK_NE(0u, input_count);
118 DCHECK_NE(0u, output_count); 118 DCHECK_NE(0u, output_count);
119 DCHECK_GE(arraysize(inputs), input_count); 119 DCHECK_GE(arraysize(inputs), input_count);
120 DCHECK_GE(arraysize(outputs), output_count); 120 DCHECK_GE(arraysize(outputs), output_count);
121 121
122 selector->Emit(cont->Encode(opcode), output_count, outputs, input_count, 122 opcode = cont->Encode(opcode);
123 inputs); 123 if (cont->IsDeoptimize()) {
124 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
125 cont->frame_state());
126 } else {
127 selector->Emit(opcode, output_count, outputs, input_count, inputs);
128 }
124 } 129 }
125 130
126 131
127 static void VisitBinop(InstructionSelector* selector, Node* node, 132 static void VisitBinop(InstructionSelector* selector, Node* node,
128 InstructionCode opcode) { 133 InstructionCode opcode) {
129 FlagsContinuation cont; 134 FlagsContinuation cont;
130 VisitBinop(selector, node, opcode, &cont); 135 VisitBinop(selector, node, opcode, &cont);
131 } 136 }
132 137
133 138
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 1429
1425 // Shared routine for multiple compare operations. 1430 // Shared routine for multiple compare operations.
1426 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 1431 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
1427 InstructionOperand left, InstructionOperand right, 1432 InstructionOperand left, InstructionOperand right,
1428 FlagsContinuation* cont) { 1433 FlagsContinuation* cont) {
1429 Mips64OperandGenerator g(selector); 1434 Mips64OperandGenerator g(selector);
1430 opcode = cont->Encode(opcode); 1435 opcode = cont->Encode(opcode);
1431 if (cont->IsBranch()) { 1436 if (cont->IsBranch()) {
1432 selector->Emit(opcode, g.NoOutput(), left, right, 1437 selector->Emit(opcode, g.NoOutput(), left, right,
1433 g.Label(cont->true_block()), g.Label(cont->false_block())); 1438 g.Label(cont->true_block()), g.Label(cont->false_block()));
1439 } else if (cont->IsDeoptimize()) {
1440 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right,
1441 cont->frame_state());
1434 } else { 1442 } else {
1435 DCHECK(cont->IsSet()); 1443 DCHECK(cont->IsSet());
1436 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); 1444 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
1437 } 1445 }
1438 } 1446 }
1439 1447
1440 1448
1441 // Shared routine for multiple float32 compare operations. 1449 // Shared routine for multiple float32 compare operations.
1442 void VisitFloat32Compare(InstructionSelector* selector, Node* node, 1450 void VisitFloat32Compare(InstructionSelector* selector, Node* node,
1443 FlagsContinuation* cont) { 1451 FlagsContinuation* cont) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 FlagsContinuation* cont) { 1543 FlagsContinuation* cont) {
1536 VisitWordCompare(selector, node, kMips64Cmp, cont, false); 1544 VisitWordCompare(selector, node, kMips64Cmp, cont, false);
1537 } 1545 }
1538 1546
1539 1547
1540 void VisitWord64Compare(InstructionSelector* selector, Node* node, 1548 void VisitWord64Compare(InstructionSelector* selector, Node* node,
1541 FlagsContinuation* cont) { 1549 FlagsContinuation* cont) {
1542 VisitWordCompare(selector, node, kMips64Cmp, cont, false); 1550 VisitWordCompare(selector, node, kMips64Cmp, cont, false);
1543 } 1551 }
1544 1552
1545 } // namespace
1546 1553
1547 1554
1548 void EmitWordCompareZero(InstructionSelector* selector, Node* value, 1555 void EmitWordCompareZero(InstructionSelector* selector, Node* value,
1549 FlagsContinuation* cont) { 1556 FlagsContinuation* cont) {
1550 Mips64OperandGenerator g(selector); 1557 Mips64OperandGenerator g(selector);
1551 InstructionCode opcode = cont->Encode(kMips64Cmp); 1558 InstructionCode opcode = cont->Encode(kMips64Cmp);
1552 InstructionOperand const value_operand = g.UseRegister(value); 1559 InstructionOperand const value_operand = g.UseRegister(value);
1553 if (cont->IsBranch()) { 1560 if (cont->IsBranch()) {
1554 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0), 1561 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0),
1555 g.Label(cont->true_block()), g.Label(cont->false_block())); 1562 g.Label(cont->true_block()), g.Label(cont->false_block()));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 default: 1677 default:
1671 break; 1678 break;
1672 } 1679 }
1673 break; 1680 break;
1674 } 1681 }
1675 1682
1676 // Continuation could not be combined with a compare, emit compare against 0. 1683 // Continuation could not be combined with a compare, emit compare against 0.
1677 EmitWordCompareZero(selector, value, cont); 1684 EmitWordCompareZero(selector, value, cont);
1678 } 1685 }
1679 1686
1687 } // namespace
1680 1688
1681 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, 1689 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
1682 BasicBlock* fbranch) { 1690 BasicBlock* fbranch) {
1683 FlagsContinuation cont(kNotEqual, tbranch, fbranch); 1691 FlagsContinuation cont(kNotEqual, tbranch, fbranch);
1684 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); 1692 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont);
1685 } 1693 }
1686 1694
1695 void InstructionSelector::VisitDeoptimizeIf(Node* node) {
1696 FlagsContinuation cont =
1697 FlagsContinuation::ForDeoptimize(kNotEqual, node->InputAt(1));
1698 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
1699 }
1700
1701 void InstructionSelector::VisitDeoptimizeUnless(Node* node) {
1702 FlagsContinuation cont =
1703 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1));
1704 VisitWordCompareZero(this, node, node->InputAt(0), &cont);
1705 }
1687 1706
1688 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { 1707 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) {
1689 Mips64OperandGenerator g(this); 1708 Mips64OperandGenerator g(this);
1690 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); 1709 InstructionOperand value_operand = g.UseRegister(node->InputAt(0));
1691 1710
1692 // Emit either ArchTableSwitch or ArchLookupSwitch. 1711 // Emit either ArchTableSwitch or ArchLookupSwitch.
1693 size_t table_space_cost = 10 + 2 * sw.value_range; 1712 size_t table_space_cost = 10 + 2 * sw.value_range;
1694 size_t table_time_cost = 3; 1713 size_t table_time_cost = 3;
1695 size_t lookup_space_cost = 2 + 2 * sw.case_count; 1714 size_t lookup_space_cost = 2 + 2 * sw.case_count;
1696 size_t lookup_time_cost = sw.case_count; 1715 size_t lookup_time_cost = sw.case_count;
(...skipping 10 matching lines...) Expand all
1707 // Generate a table lookup. 1726 // Generate a table lookup.
1708 return EmitTableSwitch(sw, index_operand); 1727 return EmitTableSwitch(sw, index_operand);
1709 } 1728 }
1710 1729
1711 // Generate a sequence of conditional jumps. 1730 // Generate a sequence of conditional jumps.
1712 return EmitLookupSwitch(sw, value_operand); 1731 return EmitLookupSwitch(sw, value_operand);
1713 } 1732 }
1714 1733
1715 1734
1716 void InstructionSelector::VisitWord32Equal(Node* const node) { 1735 void InstructionSelector::VisitWord32Equal(Node* const node) {
1717 FlagsContinuation cont(kEqual, node); 1736 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1718 Int32BinopMatcher m(node); 1737 Int32BinopMatcher m(node);
1719 if (m.right().Is(0)) { 1738 if (m.right().Is(0)) {
1720 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont); 1739 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont);
1721 } 1740 }
1722 1741
1723 VisitWord32Compare(this, node, &cont); 1742 VisitWord32Compare(this, node, &cont);
1724 } 1743 }
1725 1744
1726 1745
1727 void InstructionSelector::VisitInt32LessThan(Node* node) { 1746 void InstructionSelector::VisitInt32LessThan(Node* node) {
1728 FlagsContinuation cont(kSignedLessThan, node); 1747 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node);
1729 VisitWord32Compare(this, node, &cont); 1748 VisitWord32Compare(this, node, &cont);
1730 } 1749 }
1731 1750
1732 1751
1733 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { 1752 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) {
1734 FlagsContinuation cont(kSignedLessThanOrEqual, node); 1753 FlagsContinuation cont =
1754 FlagsContinuation::ForSet(kSignedLessThanOrEqual, node);
1735 VisitWord32Compare(this, node, &cont); 1755 VisitWord32Compare(this, node, &cont);
1736 } 1756 }
1737 1757
1738 1758
1739 void InstructionSelector::VisitUint32LessThan(Node* node) { 1759 void InstructionSelector::VisitUint32LessThan(Node* node) {
1740 FlagsContinuation cont(kUnsignedLessThan, node); 1760 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1741 VisitWord32Compare(this, node, &cont); 1761 VisitWord32Compare(this, node, &cont);
1742 } 1762 }
1743 1763
1744 1764
1745 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { 1765 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) {
1746 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1766 FlagsContinuation cont =
1767 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1747 VisitWord32Compare(this, node, &cont); 1768 VisitWord32Compare(this, node, &cont);
1748 } 1769 }
1749 1770
1750 1771
1751 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { 1772 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
1752 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1773 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1753 FlagsContinuation cont(kOverflow, ovf); 1774 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1754 return VisitBinop(this, node, kMips64Dadd, &cont); 1775 return VisitBinop(this, node, kMips64Dadd, &cont);
1755 } 1776 }
1756 FlagsContinuation cont; 1777 FlagsContinuation cont;
1757 VisitBinop(this, node, kMips64Dadd, &cont); 1778 VisitBinop(this, node, kMips64Dadd, &cont);
1758 } 1779 }
1759 1780
1760 1781
1761 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { 1782 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) {
1762 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1783 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1763 FlagsContinuation cont(kOverflow, ovf); 1784 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1764 return VisitBinop(this, node, kMips64Dsub, &cont); 1785 return VisitBinop(this, node, kMips64Dsub, &cont);
1765 } 1786 }
1766 FlagsContinuation cont; 1787 FlagsContinuation cont;
1767 VisitBinop(this, node, kMips64Dsub, &cont); 1788 VisitBinop(this, node, kMips64Dsub, &cont);
1768 } 1789 }
1769 1790
1770 1791
1771 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { 1792 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) {
1772 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1793 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1773 FlagsContinuation cont(kOverflow, ovf); 1794 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1774 return VisitBinop(this, node, kMips64DaddOvf, &cont); 1795 return VisitBinop(this, node, kMips64DaddOvf, &cont);
1775 } 1796 }
1776 FlagsContinuation cont; 1797 FlagsContinuation cont;
1777 VisitBinop(this, node, kMips64DaddOvf, &cont); 1798 VisitBinop(this, node, kMips64DaddOvf, &cont);
1778 } 1799 }
1779 1800
1780 1801
1781 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { 1802 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) {
1782 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1803 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1783 FlagsContinuation cont(kOverflow, ovf); 1804 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1784 return VisitBinop(this, node, kMips64DsubOvf, &cont); 1805 return VisitBinop(this, node, kMips64DsubOvf, &cont);
1785 } 1806 }
1786 FlagsContinuation cont; 1807 FlagsContinuation cont;
1787 VisitBinop(this, node, kMips64DsubOvf, &cont); 1808 VisitBinop(this, node, kMips64DsubOvf, &cont);
1788 } 1809 }
1789 1810
1790 1811
1791 void InstructionSelector::VisitWord64Equal(Node* const node) { 1812 void InstructionSelector::VisitWord64Equal(Node* const node) {
1792 FlagsContinuation cont(kEqual, node); 1813 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1793 Int64BinopMatcher m(node); 1814 Int64BinopMatcher m(node);
1794 if (m.right().Is(0)) { 1815 if (m.right().Is(0)) {
1795 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont); 1816 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont);
1796 } 1817 }
1797 1818
1798 VisitWord64Compare(this, node, &cont); 1819 VisitWord64Compare(this, node, &cont);
1799 } 1820 }
1800 1821
1801 1822
1802 void InstructionSelector::VisitInt64LessThan(Node* node) { 1823 void InstructionSelector::VisitInt64LessThan(Node* node) {
1803 FlagsContinuation cont(kSignedLessThan, node); 1824 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node);
1804 VisitWord64Compare(this, node, &cont); 1825 VisitWord64Compare(this, node, &cont);
1805 } 1826 }
1806 1827
1807 1828
1808 void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) { 1829 void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) {
1809 FlagsContinuation cont(kSignedLessThanOrEqual, node); 1830 FlagsContinuation cont =
1831 FlagsContinuation::ForSet(kSignedLessThanOrEqual, node);
1810 VisitWord64Compare(this, node, &cont); 1832 VisitWord64Compare(this, node, &cont);
1811 } 1833 }
1812 1834
1813 1835
1814 void InstructionSelector::VisitUint64LessThan(Node* node) { 1836 void InstructionSelector::VisitUint64LessThan(Node* node) {
1815 FlagsContinuation cont(kUnsignedLessThan, node); 1837 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1816 VisitWord64Compare(this, node, &cont); 1838 VisitWord64Compare(this, node, &cont);
1817 } 1839 }
1818 1840
1819 1841
1820 void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { 1842 void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) {
1821 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1843 FlagsContinuation cont =
1844 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1822 VisitWord64Compare(this, node, &cont); 1845 VisitWord64Compare(this, node, &cont);
1823 } 1846 }
1824 1847
1825 1848
1826 void InstructionSelector::VisitFloat32Equal(Node* node) { 1849 void InstructionSelector::VisitFloat32Equal(Node* node) {
1827 FlagsContinuation cont(kEqual, node); 1850 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1828 VisitFloat32Compare(this, node, &cont); 1851 VisitFloat32Compare(this, node, &cont);
1829 } 1852 }
1830 1853
1831 1854
1832 void InstructionSelector::VisitFloat32LessThan(Node* node) { 1855 void InstructionSelector::VisitFloat32LessThan(Node* node) {
1833 FlagsContinuation cont(kUnsignedLessThan, node); 1856 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1834 VisitFloat32Compare(this, node, &cont); 1857 VisitFloat32Compare(this, node, &cont);
1835 } 1858 }
1836 1859
1837 1860
1838 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { 1861 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) {
1839 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1862 FlagsContinuation cont =
1863 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1840 VisitFloat32Compare(this, node, &cont); 1864 VisitFloat32Compare(this, node, &cont);
1841 } 1865 }
1842 1866
1843 1867
1844 void InstructionSelector::VisitFloat64Equal(Node* node) { 1868 void InstructionSelector::VisitFloat64Equal(Node* node) {
1845 FlagsContinuation cont(kEqual, node); 1869 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1846 VisitFloat64Compare(this, node, &cont); 1870 VisitFloat64Compare(this, node, &cont);
1847 } 1871 }
1848 1872
1849 1873
1850 void InstructionSelector::VisitFloat64LessThan(Node* node) { 1874 void InstructionSelector::VisitFloat64LessThan(Node* node) {
1851 FlagsContinuation cont(kUnsignedLessThan, node); 1875 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1852 VisitFloat64Compare(this, node, &cont); 1876 VisitFloat64Compare(this, node, &cont);
1853 } 1877 }
1854 1878
1855 1879
1856 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { 1880 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
1857 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1881 FlagsContinuation cont =
1882 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1858 VisitFloat64Compare(this, node, &cont); 1883 VisitFloat64Compare(this, node, &cont);
1859 } 1884 }
1860 1885
1861 1886
1862 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { 1887 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) {
1863 VisitRR(this, kMips64Float64ExtractLowWord32, node); 1888 VisitRR(this, kMips64Float64ExtractLowWord32, node);
1864 } 1889 }
1865 1890
1866 1891
1867 void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { 1892 void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 MachineOperatorBuilder::kFloat32RoundUp | 1932 MachineOperatorBuilder::kFloat32RoundUp |
1908 MachineOperatorBuilder::kFloat64RoundTruncate | 1933 MachineOperatorBuilder::kFloat64RoundTruncate |
1909 MachineOperatorBuilder::kFloat32RoundTruncate | 1934 MachineOperatorBuilder::kFloat32RoundTruncate |
1910 MachineOperatorBuilder::kFloat64RoundTiesEven | 1935 MachineOperatorBuilder::kFloat64RoundTiesEven |
1911 MachineOperatorBuilder::kFloat32RoundTiesEven; 1936 MachineOperatorBuilder::kFloat32RoundTiesEven;
1912 } 1937 }
1913 1938
1914 } // namespace compiler 1939 } // namespace compiler
1915 } // namespace internal 1940 } // namespace internal
1916 } // namespace v8 1941 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698