src/share/vm/opto/node.cpp

Print this page
rev 5823 : 8033215: clang: node.cpp:284 IDX_INIT macro use uninitialized field _out
Reviewed-by:


 268 
 269 #endif //ASSERT
 270 
 271 
 272 // This constant used to initialize _out may be any non-null value.
 273 // The value NULL is reserved for the top node only.
 274 #define NO_OUT_ARRAY ((Node**)-1)
 275 
 276 // This funny expression handshakes with Node::operator new
 277 // to pull Compile::current out of the new node's _out field,
 278 // and then calls a subroutine which manages most field
 279 // initializations.  The only one which is tricky is the
 280 // _idx field, which is const, and so must be initialized
 281 // by a return value, not an assignment.
 282 //
 283 // (Aren't you thankful that Java finals don't require so many tricks?)
 284 #define IDX_INIT(req) this->Init((req), (Compile*) this->_out)
 285 #ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355
 286 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
 287 #endif




 288 
 289 // Out-of-line code from node constructors.
 290 // Executed only when extra debug info. is being passed around.
 291 static void init_node_notes(Compile* C, int idx, Node_Notes* nn) {
 292   C->set_node_notes_at(idx, nn);
 293 }
 294 
 295 // Shared initialization code.
 296 inline int Node::Init(int req, Compile* C) {
 297   assert(Compile::current() == C, "must use operator new(Compile*)");
 298   int idx = C->next_unique();
 299 
 300   // Allocate memory for the necessary number of edges.
 301   if (req > 0) {
 302     // Allocate space for _in array to have double alignment.
 303     _in = (Node **) ((char *) (C->node_arena()->Amalloc_D(req * sizeof(void*))));
 304 #ifdef ASSERT
 305     _in[req-1] = this; // magic cookie for assertion check
 306 #endif
 307   }


 450 {
 451   debug_only( verify_construction() );
 452   NOT_PRODUCT(nodes_created++);
 453   // Assert we allocated space for input array already
 454   assert( _in[6] == this, "Must pass arg count to 'new'" );
 455   assert( is_not_dead(n0), "can not use dead node");
 456   assert( is_not_dead(n1), "can not use dead node");
 457   assert( is_not_dead(n2), "can not use dead node");
 458   assert( is_not_dead(n3), "can not use dead node");
 459   assert( is_not_dead(n4), "can not use dead node");
 460   assert( is_not_dead(n5), "can not use dead node");
 461   assert( is_not_dead(n6), "can not use dead node");
 462   _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
 463   _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
 464   _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
 465   _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
 466   _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
 467   _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this);
 468   _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this);
 469 }




 470 
 471 
 472 //------------------------------clone------------------------------------------
 473 // Clone a Node.
 474 Node *Node::clone() const {
 475   Compile* C = Compile::current();
 476   uint s = size_of();           // Size of inherited Node
 477   Node *n = (Node*)C->node_arena()->Amalloc_D(size_of() + _max*sizeof(Node*));
 478   Copy::conjoint_words_to_lower((HeapWord*)this, (HeapWord*)n, s);
 479   // Set the new input pointer array
 480   n->_in = (Node**)(((char*)n)+s);
 481   // Cannot share the old output pointer array, so kill it
 482   n->_out = NO_OUT_ARRAY;
 483   // And reset the counters to 0
 484   n->_outcnt = 0;
 485   n->_outmax = 0;
 486   // Unlock this guy, since he is not in any hash table.
 487   debug_only(n->_hash_lock = 0);
 488   // Walk the old node's input list to duplicate its edges
 489   uint i;




 268 
 269 #endif //ASSERT
 270 
 271 
 272 // This constant used to initialize _out may be any non-null value.
 273 // The value NULL is reserved for the top node only.
 274 #define NO_OUT_ARRAY ((Node**)-1)
 275 
 276 // This funny expression handshakes with Node::operator new
 277 // to pull Compile::current out of the new node's _out field,
 278 // and then calls a subroutine which manages most field
 279 // initializations.  The only one which is tricky is the
 280 // _idx field, which is const, and so must be initialized
 281 // by a return value, not an assignment.
 282 //
 283 // (Aren't you thankful that Java finals don't require so many tricks?)
 284 #define IDX_INIT(req) this->Init((req), (Compile*) this->_out)
 285 #ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355
 286 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
 287 #endif
 288 #ifdef __clang__
 289 #pragma clang diagnostic push
 290 #pragma GCC diagnostic ignored "-Wuninitialized"
 291 #endif
 292 
 293 // Out-of-line code from node constructors.
 294 // Executed only when extra debug info. is being passed around.
 295 static void init_node_notes(Compile* C, int idx, Node_Notes* nn) {
 296   C->set_node_notes_at(idx, nn);
 297 }
 298 
 299 // Shared initialization code.
 300 inline int Node::Init(int req, Compile* C) {
 301   assert(Compile::current() == C, "must use operator new(Compile*)");
 302   int idx = C->next_unique();
 303 
 304   // Allocate memory for the necessary number of edges.
 305   if (req > 0) {
 306     // Allocate space for _in array to have double alignment.
 307     _in = (Node **) ((char *) (C->node_arena()->Amalloc_D(req * sizeof(void*))));
 308 #ifdef ASSERT
 309     _in[req-1] = this; // magic cookie for assertion check
 310 #endif
 311   }


 454 {
 455   debug_only( verify_construction() );
 456   NOT_PRODUCT(nodes_created++);
 457   // Assert we allocated space for input array already
 458   assert( _in[6] == this, "Must pass arg count to 'new'" );
 459   assert( is_not_dead(n0), "can not use dead node");
 460   assert( is_not_dead(n1), "can not use dead node");
 461   assert( is_not_dead(n2), "can not use dead node");
 462   assert( is_not_dead(n3), "can not use dead node");
 463   assert( is_not_dead(n4), "can not use dead node");
 464   assert( is_not_dead(n5), "can not use dead node");
 465   assert( is_not_dead(n6), "can not use dead node");
 466   _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
 467   _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
 468   _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
 469   _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
 470   _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
 471   _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this);
 472   _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this);
 473 }
 474 
 475 #ifdef __clang__
 476 #pragma clang diagnostic pop
 477 #endif
 478 
 479 
 480 //------------------------------clone------------------------------------------
 481 // Clone a Node.
 482 Node *Node::clone() const {
 483   Compile* C = Compile::current();
 484   uint s = size_of();           // Size of inherited Node
 485   Node *n = (Node*)C->node_arena()->Amalloc_D(size_of() + _max*sizeof(Node*));
 486   Copy::conjoint_words_to_lower((HeapWord*)this, (HeapWord*)n, s);
 487   // Set the new input pointer array
 488   n->_in = (Node**)(((char*)n)+s);
 489   // Cannot share the old output pointer array, so kill it
 490   n->_out = NO_OUT_ARRAY;
 491   // And reset the counters to 0
 492   n->_outcnt = 0;
 493   n->_outmax = 0;
 494   // Unlock this guy, since he is not in any hash table.
 495   debug_only(n->_hash_lock = 0);
 496   // Walk the old node's input list to duplicate its edges
 497   uint i;