< prev index next >

src/share/vm/opto/phaseX.cpp

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "opto/block.hpp"
  28 #include "opto/callnode.hpp"

  29 #include "opto/cfgnode.hpp"
  30 #include "opto/idealGraphPrinter.hpp"
  31 #include "opto/loopnode.hpp"
  32 #include "opto/machnode.hpp"
  33 #include "opto/opcodes.hpp"
  34 #include "opto/phaseX.hpp"
  35 #include "opto/regalloc.hpp"
  36 #include "opto/rootnode.hpp"
  37 
  38 //=============================================================================
  39 #define NODE_HASH_MINIMUM_SIZE    255
  40 //------------------------------NodeHash---------------------------------------
  41 NodeHash::NodeHash(uint est_max_size) :
  42   _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
  43   _a(Thread::current()->resource_area()),
  44   _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ), // (Node**)_a->Amalloc(_max * sizeof(Node*)) ),
  45   _inserts(0), _insert_limit( insert_limit() )
  46 #ifndef PRODUCT
  47   ,_look_probes(0), _lookup_hits(0), _lookup_misses(0),
  48   _delete_probes(0), _delete_hits(0), _delete_misses(0),


1395     } else {
1396       // Finished disconnecting all input and output edges.
1397       _stack.pop();
1398       // Remove dead node from iterative worklist
1399       _worklist.remove(dead);
1400       C->remove_modified_node(dead);
1401       // Constant node that has no out-edges and has only one in-edge from
1402       // root is usually dead. However, sometimes reshaping walk makes
1403       // it reachable by adding use edges. So, we will NOT count Con nodes
1404       // as dead to be conservative about the dead node count at any
1405       // given time.
1406       if (!dead->is_Con()) {
1407         C->record_dead_node(dead->_idx);
1408       }
1409       if (dead->is_macro()) {
1410         C->remove_macro_node(dead);
1411       }
1412       if (dead->is_expensive()) {
1413         C->remove_expensive_node(dead);
1414       }






1415     }
1416   } // while (_stack.is_nonempty())
1417 }
1418 
1419 //------------------------------subsume_node-----------------------------------
1420 // Remove users from node 'old' and add them to node 'nn'.
1421 void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
1422   assert( old != hash_find(old), "should already been removed" );
1423   assert( old != C->top(), "cannot subsume top node");
1424   // Copy debug or profile information to the new version:
1425   C->copy_node_notes_to(nn, old);
1426   // Move users of node 'old' to node 'nn'
1427   for (DUIterator_Last imin, i = old->last_outs(imin); i >= imin; ) {
1428     Node* use = old->last_out(i);  // for each use...
1429     // use might need re-hashing (but it won't if it's a new node)
1430     rehash_node_delayed(use);
1431     // Update use-def info as well
1432     // We remove all occurrences of old within use->in,
1433     // so as to avoid rehashing any node more than once.
1434     // The hash table probe swamps any outer loop overhead.




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "opto/block.hpp"
  28 #include "opto/callnode.hpp"
  29 #include "opto/castnode.hpp"
  30 #include "opto/cfgnode.hpp"
  31 #include "opto/idealGraphPrinter.hpp"
  32 #include "opto/loopnode.hpp"
  33 #include "opto/machnode.hpp"
  34 #include "opto/opcodes.hpp"
  35 #include "opto/phaseX.hpp"
  36 #include "opto/regalloc.hpp"
  37 #include "opto/rootnode.hpp"
  38 
  39 //=============================================================================
  40 #define NODE_HASH_MINIMUM_SIZE    255
  41 //------------------------------NodeHash---------------------------------------
  42 NodeHash::NodeHash(uint est_max_size) :
  43   _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
  44   _a(Thread::current()->resource_area()),
  45   _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ), // (Node**)_a->Amalloc(_max * sizeof(Node*)) ),
  46   _inserts(0), _insert_limit( insert_limit() )
  47 #ifndef PRODUCT
  48   ,_look_probes(0), _lookup_hits(0), _lookup_misses(0),
  49   _delete_probes(0), _delete_hits(0), _delete_misses(0),


1396     } else {
1397       // Finished disconnecting all input and output edges.
1398       _stack.pop();
1399       // Remove dead node from iterative worklist
1400       _worklist.remove(dead);
1401       C->remove_modified_node(dead);
1402       // Constant node that has no out-edges and has only one in-edge from
1403       // root is usually dead. However, sometimes reshaping walk makes
1404       // it reachable by adding use edges. So, we will NOT count Con nodes
1405       // as dead to be conservative about the dead node count at any
1406       // given time.
1407       if (!dead->is_Con()) {
1408         C->record_dead_node(dead->_idx);
1409       }
1410       if (dead->is_macro()) {
1411         C->remove_macro_node(dead);
1412       }
1413       if (dead->is_expensive()) {
1414         C->remove_expensive_node(dead);
1415       }
1416 #ifdef _LP64
1417       CastIINode* cast = dead->isa_CastII();
1418       if (cast != NULL && cast->has_range_check()) {
1419         C->remove_range_check_cast(cast);
1420       }
1421 #endif
1422     }
1423   } // while (_stack.is_nonempty())
1424 }
1425 
1426 //------------------------------subsume_node-----------------------------------
1427 // Remove users from node 'old' and add them to node 'nn'.
1428 void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
1429   assert( old != hash_find(old), "should already been removed" );
1430   assert( old != C->top(), "cannot subsume top node");
1431   // Copy debug or profile information to the new version:
1432   C->copy_node_notes_to(nn, old);
1433   // Move users of node 'old' to node 'nn'
1434   for (DUIterator_Last imin, i = old->last_outs(imin); i >= imin; ) {
1435     Node* use = old->last_out(i);  // for each use...
1436     // use might need re-hashing (but it won't if it's a new node)
1437     rehash_node_delayed(use);
1438     // Update use-def info as well
1439     // We remove all occurrences of old within use->in,
1440     // so as to avoid rehashing any node more than once.
1441     // The hash table probe swamps any outer loop overhead.


< prev index next >