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),
49 _total_insert_probes(0), _total_inserts(0),
50 _insert_probes(0), _grows(0)
51 #endif
52 {
53 // _sentinel must be in the current node space
54 _sentinel = new ProjNode(NULL, TypeFunc::Control);
55 memset(_table,0,sizeof(Node*)*_max);
56 }
548 dump_nodes_and_types_recur( root, depth, only_ctrl, visited );
549 }
550
551 //------------------------------dump_nodes_and_types_recur---------------------
552 void PhaseTransform::dump_nodes_and_types_recur( const Node *n, uint depth, bool only_ctrl, VectorSet &visited) {
553 if( !n ) return;
554 if( depth == 0 ) return;
555 if( visited.test_set(n->_idx) ) return;
556 for( uint i=0; i<n->len(); i++ ) {
557 if( only_ctrl && !(n->is_Region()) && i != TypeFunc::Control ) continue;
558 dump_nodes_and_types_recur( n->in(i), depth-1, only_ctrl, visited );
559 }
560 n->dump();
561 if (type_or_null(n) != NULL) {
562 tty->print(" "); type(n)->dump(); tty->cr();
563 }
564 }
565
566 #endif
567
568
569 //=============================================================================
570 //------------------------------PhaseValues------------------------------------
571 // Set minimum table size to "255"
572 PhaseValues::PhaseValues( Arena *arena, uint est_max_size ) : PhaseTransform(arena, GVN), _table(arena, est_max_size) {
573 NOT_PRODUCT( clear_new_values(); )
574 }
575
576 //------------------------------PhaseValues------------------------------------
577 // Set minimum table size to "255"
578 PhaseValues::PhaseValues( PhaseValues *ptv ) : PhaseTransform( ptv, GVN ),
579 _table(&ptv->_table) {
580 NOT_PRODUCT( clear_new_values(); )
581 }
582
583 //------------------------------PhaseValues------------------------------------
584 // Used by +VerifyOpto. Clear out hash table but copy _types array.
585 PhaseValues::PhaseValues( PhaseValues *ptv, const char *dummy ) : PhaseTransform( ptv, GVN ),
586 _table(ptv->arena(),ptv->_table.size()) {
587 NOT_PRODUCT( clear_new_values(); )
1173 // Since I just called 'Value' to compute the set of run-time values
1174 // for this Node, and 'Value' is non-local (and therefore expensive) I'll
1175 // cache Value. Later requests for the local phase->type of this Node can
1176 // use the cached Value instead of suffering with 'bottom_type'.
1177 if (type_or_null(k) != t) {
1178 #ifndef PRODUCT
1179 inc_new_values();
1180 set_progress();
1181 #endif
1182 set_type(k, t);
1183 // If k is a TypeNode, capture any more-precise type permanently into Node
1184 k->raise_bottom_type(t);
1185 // Move users of node to worklist
1186 add_users_to_worklist(k);
1187 }
1188 // If 'k' computes a constant, replace it with a constant
1189 if (t->singleton() && !k->is_Con()) {
1190 NOT_PRODUCT(set_progress();)
1191 Node* con = makecon(t); // Make a constant
1192 add_users_to_worklist(k);
1193 subsume_node(k, con); // Everybody using k now uses con
1194 return con;
1195 }
1196
1197 // Now check for Identities
1198 i = k->Identity(this); // Look for a nearby replacement
1199 if (i != k) { // Found? Return replacement!
1200 NOT_PRODUCT(set_progress();)
1201 add_users_to_worklist(k);
1202 subsume_node(k, i); // Everybody using k now uses i
1203 return i;
1204 }
1205
1206 // Global Value Numbering
1207 i = hash_find_insert(k); // Check for pre-existing node
1208 if (i && (i != k)) {
1209 // Return the pre-existing node if it isn't dead
1210 NOT_PRODUCT(set_progress();)
1211 add_users_to_worklist(k);
1212 subsume_node(k, i); // Everybody using k now uses i
|
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 #include "opto/shenandoahSupport.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),
50 _total_insert_probes(0), _total_inserts(0),
51 _insert_probes(0), _grows(0)
52 #endif
53 {
54 // _sentinel must be in the current node space
55 _sentinel = new ProjNode(NULL, TypeFunc::Control);
56 memset(_table,0,sizeof(Node*)*_max);
57 }
549 dump_nodes_and_types_recur( root, depth, only_ctrl, visited );
550 }
551
552 //------------------------------dump_nodes_and_types_recur---------------------
553 void PhaseTransform::dump_nodes_and_types_recur( const Node *n, uint depth, bool only_ctrl, VectorSet &visited) {
554 if( !n ) return;
555 if( depth == 0 ) return;
556 if( visited.test_set(n->_idx) ) return;
557 for( uint i=0; i<n->len(); i++ ) {
558 if( only_ctrl && !(n->is_Region()) && i != TypeFunc::Control ) continue;
559 dump_nodes_and_types_recur( n->in(i), depth-1, only_ctrl, visited );
560 }
561 n->dump();
562 if (type_or_null(n) != NULL) {
563 tty->print(" "); type(n)->dump(); tty->cr();
564 }
565 }
566
567 #endif
568
569 bool PhaseTransform::eqv(const Node* n1, const Node* n2) const {
570 if (UseShenandoahGC) {
571
572 if (n1 == n2) return true;
573
574 if (n1 == NULL || n2 == NULL) return false;
575
576 if (n1->is_AddP() && n2->is_AddP()) {
577 Node* addp1 = n1->as_AddP();
578 Node* base1 = addp1->in(AddPNode::Base);
579 Node* addr1 = addp1->in(AddPNode::Address);
580 Node* offs1 = addp1->in(AddPNode::Offset);
581
582 Node* addp2 = n2->as_AddP();
583 Node* base2 = addp2->in(AddPNode::Base);
584 Node* addr2 = addp2->in(AddPNode::Address);
585 Node* offs2 = addp2->in(AddPNode::Offset);
586
587 if (base1 == addr1 && base2 == addr2) {
588
589 addr1 = ShenandoahBarrierNode::skip_through_barrier(addr1);
590 addr2 = ShenandoahBarrierNode::skip_through_barrier(addr2);
591
592 if (addr1 == addr2 && offs1 == offs2) return true;
593 }
594
595 }
596 return false;
597 } else {
598 return n1 == n2;
599 }
600 }
601
602 //=============================================================================
603 //------------------------------PhaseValues------------------------------------
604 // Set minimum table size to "255"
605 PhaseValues::PhaseValues( Arena *arena, uint est_max_size ) : PhaseTransform(arena, GVN), _table(arena, est_max_size) {
606 NOT_PRODUCT( clear_new_values(); )
607 }
608
609 //------------------------------PhaseValues------------------------------------
610 // Set minimum table size to "255"
611 PhaseValues::PhaseValues( PhaseValues *ptv ) : PhaseTransform( ptv, GVN ),
612 _table(&ptv->_table) {
613 NOT_PRODUCT( clear_new_values(); )
614 }
615
616 //------------------------------PhaseValues------------------------------------
617 // Used by +VerifyOpto. Clear out hash table but copy _types array.
618 PhaseValues::PhaseValues( PhaseValues *ptv, const char *dummy ) : PhaseTransform( ptv, GVN ),
619 _table(ptv->arena(),ptv->_table.size()) {
620 NOT_PRODUCT( clear_new_values(); )
1206 // Since I just called 'Value' to compute the set of run-time values
1207 // for this Node, and 'Value' is non-local (and therefore expensive) I'll
1208 // cache Value. Later requests for the local phase->type of this Node can
1209 // use the cached Value instead of suffering with 'bottom_type'.
1210 if (type_or_null(k) != t) {
1211 #ifndef PRODUCT
1212 inc_new_values();
1213 set_progress();
1214 #endif
1215 set_type(k, t);
1216 // If k is a TypeNode, capture any more-precise type permanently into Node
1217 k->raise_bottom_type(t);
1218 // Move users of node to worklist
1219 add_users_to_worklist(k);
1220 }
1221 // If 'k' computes a constant, replace it with a constant
1222 if (t->singleton() && !k->is_Con()) {
1223 NOT_PRODUCT(set_progress();)
1224 Node* con = makecon(t); // Make a constant
1225 add_users_to_worklist(k);
1226 if (k->Opcode() == Op_ShenandoahWriteBarrier) {
1227 assert(con->is_top(), "can only replace barrier with top");
1228 }
1229 subsume_node(k, con); // Everybody using k now uses con
1230 return con;
1231 }
1232
1233 // Now check for Identities
1234 i = k->Identity(this); // Look for a nearby replacement
1235 if (i != k) { // Found? Return replacement!
1236 NOT_PRODUCT(set_progress();)
1237 add_users_to_worklist(k);
1238 subsume_node(k, i); // Everybody using k now uses i
1239 return i;
1240 }
1241
1242 // Global Value Numbering
1243 i = hash_find_insert(k); // Check for pre-existing node
1244 if (i && (i != k)) {
1245 // Return the pre-existing node if it isn't dead
1246 NOT_PRODUCT(set_progress();)
1247 add_users_to_worklist(k);
1248 subsume_node(k, i); // Everybody using k now uses i
|