Mercurial > hg > truffle
comparison src/share/vm/opto/matcher.cpp @ 586:6bea93606c11
6791572: assert("duplicating node that's already been matched")
Summary: Mark inputs for an address expression as shared if there are other uses besides address expressions.
Reviewed-by: never
author | kvn |
---|---|
date | Mon, 23 Feb 2009 16:03:19 -0800 |
parents | 3b5ac9e7e6ea |
children | 98cb887364d3 |
comparison
equal
deleted
inserted
replaced
585:22e09c0f4b47 | 586:6bea93606c11 |
---|---|
1705 //------------------------------find_shared------------------------------------ | 1705 //------------------------------find_shared------------------------------------ |
1706 // Set bits if Node is shared or otherwise a root | 1706 // Set bits if Node is shared or otherwise a root |
1707 void Matcher::find_shared( Node *n ) { | 1707 void Matcher::find_shared( Node *n ) { |
1708 // Allocate stack of size C->unique() * 2 to avoid frequent realloc | 1708 // Allocate stack of size C->unique() * 2 to avoid frequent realloc |
1709 MStack mstack(C->unique() * 2); | 1709 MStack mstack(C->unique() * 2); |
1710 // Mark nodes as address_visited if they are inputs to an address expression | |
1711 VectorSet address_visited(Thread::current()->resource_area()); | |
1710 mstack.push(n, Visit); // Don't need to pre-visit root node | 1712 mstack.push(n, Visit); // Don't need to pre-visit root node |
1711 while (mstack.is_nonempty()) { | 1713 while (mstack.is_nonempty()) { |
1712 n = mstack.node(); // Leave node on stack | 1714 n = mstack.node(); // Leave node on stack |
1713 Node_State nstate = mstack.state(); | 1715 Node_State nstate = mstack.state(); |
1716 uint nop = n->Opcode(); | |
1714 if (nstate == Pre_Visit) { | 1717 if (nstate == Pre_Visit) { |
1718 if (address_visited.test(n->_idx)) { // Visited in address already? | |
1719 // Flag as visited and shared now. | |
1720 set_visited(n); | |
1721 } | |
1715 if (is_visited(n)) { // Visited already? | 1722 if (is_visited(n)) { // Visited already? |
1716 // Node is shared and has no reason to clone. Flag it as shared. | 1723 // Node is shared and has no reason to clone. Flag it as shared. |
1717 // This causes it to match into a register for the sharing. | 1724 // This causes it to match into a register for the sharing. |
1718 set_shared(n); // Flag as shared and | 1725 set_shared(n); // Flag as shared and |
1719 mstack.pop(); // remove node from stack | 1726 mstack.pop(); // remove node from stack |
1724 if (nstate == Visit) { | 1731 if (nstate == Visit) { |
1725 mstack.set_state(Post_Visit); | 1732 mstack.set_state(Post_Visit); |
1726 set_visited(n); // Flag as visited now | 1733 set_visited(n); // Flag as visited now |
1727 bool mem_op = false; | 1734 bool mem_op = false; |
1728 | 1735 |
1729 switch( n->Opcode() ) { // Handle some opcodes special | 1736 switch( nop ) { // Handle some opcodes special |
1730 case Op_Phi: // Treat Phis as shared roots | 1737 case Op_Phi: // Treat Phis as shared roots |
1731 case Op_Parm: | 1738 case Op_Parm: |
1732 case Op_Proj: // All handled specially during matching | 1739 case Op_Proj: // All handled specially during matching |
1733 case Op_SafePointScalarObject: | 1740 case Op_SafePointScalarObject: |
1734 set_shared(n); | 1741 set_shared(n); |
1885 // Bases used in addresses must be shared but since | 1892 // Bases used in addresses must be shared but since |
1886 // they are shared through a DecodeN they may appear | 1893 // they are shared through a DecodeN they may appear |
1887 // to have a single use so force sharing here. | 1894 // to have a single use so force sharing here. |
1888 set_shared(m->in(AddPNode::Base)->in(1)); | 1895 set_shared(m->in(AddPNode::Base)->in(1)); |
1889 } | 1896 } |
1897 | |
1898 // Some inputs for address expression are not put on stack | |
1899 // to avoid marking them as shared and forcing them into register | |
1900 // if they are used only in address expressions. | |
1901 // But they should be marked as shared if there are other uses | |
1902 // besides address expressions. | |
1903 | |
1890 Node *off = m->in(AddPNode::Offset); | 1904 Node *off = m->in(AddPNode::Offset); |
1891 if( off->is_Con() ) { | 1905 if( off->is_Con() && |
1892 set_visited(m); // Flag as visited now | 1906 // When there are other uses besides address expressions |
1907 // put it on stack and mark as shared. | |
1908 !is_visited(m) ) { | |
1909 address_visited.test_set(m->_idx); // Flag as address_visited | |
1893 Node *adr = m->in(AddPNode::Address); | 1910 Node *adr = m->in(AddPNode::Address); |
1894 | 1911 |
1895 // Intel, ARM and friends can handle 2 adds in addressing mode | 1912 // Intel, ARM and friends can handle 2 adds in addressing mode |
1896 if( clone_shift_expressions && adr->is_AddP() && | 1913 if( clone_shift_expressions && adr->is_AddP() && |
1897 // AtomicAdd is not an addressing expression. | 1914 // AtomicAdd is not an addressing expression. |
1898 // Cheap to find it by looking for screwy base. | 1915 // Cheap to find it by looking for screwy base. |
1899 !adr->in(AddPNode::Base)->is_top() ) { | 1916 !adr->in(AddPNode::Base)->is_top() && |
1900 set_visited(adr); // Flag as visited now | 1917 // Are there other uses besides address expressions? |
1918 !is_visited(adr) ) { | |
1919 address_visited.set(adr->_idx); // Flag as address_visited | |
1901 Node *shift = adr->in(AddPNode::Offset); | 1920 Node *shift = adr->in(AddPNode::Offset); |
1902 // Check for shift by small constant as well | 1921 // Check for shift by small constant as well |
1903 if( shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() && | 1922 if( shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() && |
1904 shift->in(2)->get_int() <= 3 ) { | 1923 shift->in(2)->get_int() <= 3 && |
1905 set_visited(shift); // Flag as visited now | 1924 // Are there other uses besides address expressions? |
1925 !is_visited(shift) ) { | |
1926 address_visited.set(shift->_idx); // Flag as address_visited | |
1906 mstack.push(shift->in(2), Visit); | 1927 mstack.push(shift->in(2), Visit); |
1928 Node *conv = shift->in(1); | |
1907 #ifdef _LP64 | 1929 #ifdef _LP64 |
1908 // Allow Matcher to match the rule which bypass | 1930 // Allow Matcher to match the rule which bypass |
1909 // ConvI2L operation for an array index on LP64 | 1931 // ConvI2L operation for an array index on LP64 |
1910 // if the index value is positive. | 1932 // if the index value is positive. |
1911 if( shift->in(1)->Opcode() == Op_ConvI2L && | 1933 if( conv->Opcode() == Op_ConvI2L && |
1912 shift->in(1)->as_Type()->type()->is_long()->_lo >= 0 ) { | 1934 conv->as_Type()->type()->is_long()->_lo >= 0 && |
1913 set_visited(shift->in(1)); // Flag as visited now | 1935 // Are there other uses besides address expressions? |
1914 mstack.push(shift->in(1)->in(1), Pre_Visit); | 1936 !is_visited(conv) ) { |
1937 address_visited.set(conv->_idx); // Flag as address_visited | |
1938 mstack.push(conv->in(1), Pre_Visit); | |
1915 } else | 1939 } else |
1916 #endif | 1940 #endif |
1917 mstack.push(shift->in(1), Pre_Visit); | 1941 mstack.push(conv, Pre_Visit); |
1918 } else { | 1942 } else { |
1919 mstack.push(shift, Pre_Visit); | 1943 mstack.push(shift, Pre_Visit); |
1920 } | 1944 } |
1921 mstack.push(adr->in(AddPNode::Address), Pre_Visit); | 1945 mstack.push(adr->in(AddPNode::Address), Pre_Visit); |
1922 mstack.push(adr->in(AddPNode::Base), Pre_Visit); | 1946 mstack.push(adr->in(AddPNode::Base), Pre_Visit); |