Mercurial > hg > truffle
comparison src/share/vm/opto/matcher.cpp @ 628:7bb995fbd3c0
Merge
author | trims |
---|---|
date | Thu, 12 Mar 2009 18:16:36 -0700 |
parents | 0fbdb4381b99 98cb887364d3 |
children | bd441136a5ce |
comparison
equal
deleted
inserted
replaced
580:ce2272390558 | 628:7bb995fbd3c0 |
---|---|
895 ) { | 895 ) { |
896 m = m->clone(); | 896 m = m->clone(); |
897 #ifdef ASSERT | 897 #ifdef ASSERT |
898 _new2old_map.map(m->_idx, n); | 898 _new2old_map.map(m->_idx, n); |
899 #endif | 899 #endif |
900 mstack.push(m, Post_Visit, n, i); // Don't neet to visit | 900 mstack.push(m, Post_Visit, n, i); // Don't need to visit |
901 mstack.push(m->in(0), Visit, m, 0); | 901 mstack.push(m->in(0), Visit, m, 0); |
902 } else { | 902 } else { |
903 mstack.push(m, Visit, n, i); | 903 mstack.push(m, Visit, n, i); |
904 } | 904 } |
905 } | 905 } |
1265 // efficiently fold into them on X64 in some cases. | 1265 // efficiently fold into them on X64 in some cases. |
1266 return false; | 1266 return false; |
1267 } | 1267 } |
1268 } | 1268 } |
1269 | 1269 |
1270 // Not forceably cloning. If shared, put it into a register. | 1270 // Not forceable cloning. If shared, put it into a register. |
1271 return shared; | 1271 return shared; |
1272 } | 1272 } |
1273 | 1273 |
1274 | 1274 |
1275 //------------------------------Instruction Selection-------------------------- | 1275 //------------------------------Instruction Selection-------------------------- |
1540 int op = _leftOp[rule]; | 1540 int op = _leftOp[rule]; |
1541 // Operand type to catch childs result | 1541 // Operand type to catch childs result |
1542 // This is what my child will give me. | 1542 // This is what my child will give me. |
1543 int opnd_class_instance = s->_rule[op]; | 1543 int opnd_class_instance = s->_rule[op]; |
1544 // Choose between operand class or not. | 1544 // Choose between operand class or not. |
1545 // This is what I will recieve. | 1545 // This is what I will receive. |
1546 int catch_op = (FIRST_OPERAND_CLASS <= op && op < NUM_OPERANDS) ? opnd_class_instance : op; | 1546 int catch_op = (FIRST_OPERAND_CLASS <= op && op < NUM_OPERANDS) ? opnd_class_instance : op; |
1547 // New rule for child. Chase operand classes to get the actual rule. | 1547 // New rule for child. Chase operand classes to get the actual rule. |
1548 int newrule = s->_rule[catch_op]; | 1548 int newrule = s->_rule[catch_op]; |
1549 | 1549 |
1550 if( newrule < NUM_OPERANDS ) { | 1550 if( newrule < NUM_OPERANDS ) { |
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); |
1940 // This leaves both the Bool and the If pointing at the Cmp. To | 1964 // This leaves both the Bool and the If pointing at the Cmp. To |
1941 // prevent the Matcher from trying to Match the Cmp along both paths | 1965 // prevent the Matcher from trying to Match the Cmp along both paths |
1942 // BoolNode::match_edge always returns a zero. | 1966 // BoolNode::match_edge always returns a zero. |
1943 | 1967 |
1944 // We reorder the Op_If in a pre-order manner, so we can visit without | 1968 // We reorder the Op_If in a pre-order manner, so we can visit without |
1945 // accidently sharing the Cmp (the Bool and the If make 2 users). | 1969 // accidentally sharing the Cmp (the Bool and the If make 2 users). |
1946 n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool | 1970 n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool |
1947 } | 1971 } |
1948 else if (nstate == Post_Visit) { | 1972 else if (nstate == Post_Visit) { |
1949 mstack.pop(); // Remove node from stack | 1973 mstack.pop(); // Remove node from stack |
1950 | 1974 |