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 _look_probes(0), _lookup_hits(0), _lookup_misses(0),
47 _total_insert_probes(0), _total_inserts(0),
48 _insert_probes(0), _grows(0) {
49 // _sentinel must be in the current node space
50 _sentinel = new (Compile::current()) ProjNode(NULL, TypeFunc::Control);
51 memset(_table,0,sizeof(Node*)*_max);
52 }
53
54 //------------------------------NodeHash---------------------------------------
55 NodeHash::NodeHash(Arena *arena, uint est_max_size) :
56 _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
57 _a(arena),
58 _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ),
59 _inserts(0), _insert_limit( insert_limit() ),
60 _look_probes(0), _lookup_hits(0), _lookup_misses(0),
61 _delete_probes(0), _delete_hits(0), _delete_misses(0),
62 _total_insert_probes(0), _total_inserts(0),
63 _insert_probes(0), _grows(0) {
64 // _sentinel must be in the current node space
65 _sentinel = new (Compile::current()) ProjNode(NULL, TypeFunc::Control);
66 memset(_table,0,sizeof(Node*)*_max);
67 }
68
69 //------------------------------NodeHash---------------------------------------
70 NodeHash::NodeHash(NodeHash *nh) {
71 debug_only(_table = (Node**)badAddress); // interact correctly w/ operator=
72 // just copy in all the fields
73 *this = *nh;
74 // nh->_sentinel must be in the current node space
75 }
76
77 void NodeHash::replace_with(NodeHash *nh) {
78 debug_only(_table = (Node**)badAddress); // interact correctly w/ operator=
79 // just copy in all the fields
80 *this = *nh;
81 // nh->_sentinel must be in the current node space
82 }
83
84 //------------------------------hash_find--------------------------------------
85 // Find in hash table
1292 // Update use-def info as well
1293 // We remove all occurrences of old within use->in,
1294 // so as to avoid rehashing any node more than once.
1295 // The hash table probe swamps any outer loop overhead.
1296 uint num_edges = 0;
1297 for (uint jmax = use->len(), j = 0; j < jmax; j++) {
1298 if (use->in(j) == old) {
1299 use->set_req(j, nn);
1300 ++num_edges;
1301 }
1302 }
1303 // Insert into GVN hash table if unique
1304 // If a duplicate, 'use' will be cleaned up when pulled off worklist
1305 if( is_in_table ) {
1306 hash_find_insert(use);
1307 }
1308 i -= num_edges; // we deleted 1 or more copies of this edge
1309 }
1310
1311 // Smash all inputs to 'old', isolating him completely
1312 Node *temp = new (C) Node(1);
1313 temp->init_req(0,nn); // Add a use to nn to prevent him from dying
1314 remove_dead_node( old );
1315 temp->del_req(0); // Yank bogus edge
1316 #ifndef PRODUCT
1317 if( VerifyIterativeGVN ) {
1318 for ( int i = 0; i < _verify_window_size; i++ ) {
1319 if ( _verify_window[i] == old )
1320 _verify_window[i] = nn;
1321 }
1322 }
1323 #endif
1324 _worklist.remove(temp); // this can be necessary
1325 temp->destruct(); // reuse the _idx of this little guy
1326 }
1327
1328 //------------------------------add_users_to_worklist--------------------------
1329 void PhaseIterGVN::add_users_to_worklist0( Node *n ) {
1330 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
1331 _worklist.push(n->fast_out(i)); // Push on worklist
1332 }
|
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 _look_probes(0), _lookup_hits(0), _lookup_misses(0),
47 _total_insert_probes(0), _total_inserts(0),
48 _insert_probes(0), _grows(0) {
49 // _sentinel must be in the current node space
50 _sentinel = new ProjNode(NULL, TypeFunc::Control);
51 memset(_table,0,sizeof(Node*)*_max);
52 }
53
54 //------------------------------NodeHash---------------------------------------
55 NodeHash::NodeHash(Arena *arena, uint est_max_size) :
56 _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
57 _a(arena),
58 _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ),
59 _inserts(0), _insert_limit( insert_limit() ),
60 _look_probes(0), _lookup_hits(0), _lookup_misses(0),
61 _delete_probes(0), _delete_hits(0), _delete_misses(0),
62 _total_insert_probes(0), _total_inserts(0),
63 _insert_probes(0), _grows(0) {
64 // _sentinel must be in the current node space
65 _sentinel = new ProjNode(NULL, TypeFunc::Control);
66 memset(_table,0,sizeof(Node*)*_max);
67 }
68
69 //------------------------------NodeHash---------------------------------------
70 NodeHash::NodeHash(NodeHash *nh) {
71 debug_only(_table = (Node**)badAddress); // interact correctly w/ operator=
72 // just copy in all the fields
73 *this = *nh;
74 // nh->_sentinel must be in the current node space
75 }
76
77 void NodeHash::replace_with(NodeHash *nh) {
78 debug_only(_table = (Node**)badAddress); // interact correctly w/ operator=
79 // just copy in all the fields
80 *this = *nh;
81 // nh->_sentinel must be in the current node space
82 }
83
84 //------------------------------hash_find--------------------------------------
85 // Find in hash table
1292 // Update use-def info as well
1293 // We remove all occurrences of old within use->in,
1294 // so as to avoid rehashing any node more than once.
1295 // The hash table probe swamps any outer loop overhead.
1296 uint num_edges = 0;
1297 for (uint jmax = use->len(), j = 0; j < jmax; j++) {
1298 if (use->in(j) == old) {
1299 use->set_req(j, nn);
1300 ++num_edges;
1301 }
1302 }
1303 // Insert into GVN hash table if unique
1304 // If a duplicate, 'use' will be cleaned up when pulled off worklist
1305 if( is_in_table ) {
1306 hash_find_insert(use);
1307 }
1308 i -= num_edges; // we deleted 1 or more copies of this edge
1309 }
1310
1311 // Smash all inputs to 'old', isolating him completely
1312 Node *temp = new Node(1);
1313 temp->init_req(0,nn); // Add a use to nn to prevent him from dying
1314 remove_dead_node( old );
1315 temp->del_req(0); // Yank bogus edge
1316 #ifndef PRODUCT
1317 if( VerifyIterativeGVN ) {
1318 for ( int i = 0; i < _verify_window_size; i++ ) {
1319 if ( _verify_window[i] == old )
1320 _verify_window[i] = nn;
1321 }
1322 }
1323 #endif
1324 _worklist.remove(temp); // this can be necessary
1325 temp->destruct(); // reuse the _idx of this little guy
1326 }
1327
1328 //------------------------------add_users_to_worklist--------------------------
1329 void PhaseIterGVN::add_users_to_worklist0( Node *n ) {
1330 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
1331 _worklist.push(n->fast_out(i)); // Push on worklist
1332 }
|