src/share/vm/opto/node.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/node.cpp

Print this page
rev 6519 : 8026796: Make replace_in_map() on parent maps generic
Summary: propagate node replacements along control flow edges to callers
Reviewed-by:
rev 6520 : [mq]: replaceinmap-8026796-reviews


 497   // MachNode clone
 498   uint nopnds;
 499   if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
 500     MachNode *mach  = n->as_Mach();
 501     MachNode *mthis = this->as_Mach();
 502     // Get address of _opnd_array.
 503     // It should be the same offset since it is the clone of this node.
 504     MachOper **from = mthis->_opnds;
 505     MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
 506                     pointer_delta((const void*)from,
 507                                   (const void*)(&mthis->_opnds), 1));
 508     mach->_opnds = to;
 509     for ( uint i = 0; i < nopnds; ++i ) {
 510       to[i] = from[i]->clone(C);
 511     }
 512   }
 513   // cloning CallNode may need to clone JVMState
 514   if (n->is_Call()) {
 515     n->as_Call()->clone_jvms(C);
 516   }



 517   return n;                     // Return the clone
 518 }
 519 
 520 //---------------------------setup_is_top--------------------------------------
 521 // Call this when changing the top node, to reassert the invariants
 522 // required by Node::is_top.  See Compile::set_cached_top_node.
 523 void Node::setup_is_top() {
 524   if (this == (Node*)Compile::current()->top()) {
 525     // This node has just become top.  Kill its out array.
 526     _outcnt = _outmax = 0;
 527     _out = NULL;                           // marker value for top
 528     assert(is_top(), "must be top");
 529   } else {
 530     if (_out == NULL)  _out = NO_OUT_ARRAY;
 531     assert(!is_top(), "must not be top");
 532   }
 533 }
 534 
 535 
 536 //------------------------------~Node------------------------------------------


 591     // Free just the input array
 592 #ifdef ASSERT
 593     if( edge_end == compile->node_arena()->hwm() )
 594       reclaim_in  += edge_size;
 595 #endif
 596     compile->node_arena()->Afree(_in,edge_size);
 597 
 598     // Free just the object
 599 #ifdef ASSERT
 600     if( ((char*)this) + node_size == compile->node_arena()->hwm() )
 601       reclaim_node+= node_size;
 602 #else
 603     compile->node_arena()->Afree(this,node_size);
 604 #endif
 605   }
 606   if (is_macro()) {
 607     compile->remove_macro_node(this);
 608   }
 609   if (is_expensive()) {
 610     compile->remove_expensive_node(this);



 611   }
 612 #ifdef ASSERT
 613   // We will not actually delete the storage, but we'll make the node unusable.
 614   *(address*)this = badAddress;  // smash the C++ vtbl, probably
 615   _in = _out = (Node**) badAddress;
 616   _max = _cnt = _outmax = _outcnt = 0;
 617 #endif
 618 }
 619 
 620 //------------------------------grow-------------------------------------------
 621 // Grow the input array, making space for more edges
 622 void Node::grow( uint len ) {
 623   Arena* arena = Compile::current()->node_arena();
 624   uint new_max = _max;
 625   if( new_max == 0 ) {
 626     _max = 4;
 627     _in = (Node**)arena->Amalloc(4*sizeof(Node*));
 628     Node** to = _in;
 629     to[0] = NULL;
 630     to[1] = NULL;




 497   // MachNode clone
 498   uint nopnds;
 499   if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
 500     MachNode *mach  = n->as_Mach();
 501     MachNode *mthis = this->as_Mach();
 502     // Get address of _opnd_array.
 503     // It should be the same offset since it is the clone of this node.
 504     MachOper **from = mthis->_opnds;
 505     MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
 506                     pointer_delta((const void*)from,
 507                                   (const void*)(&mthis->_opnds), 1));
 508     mach->_opnds = to;
 509     for ( uint i = 0; i < nopnds; ++i ) {
 510       to[i] = from[i]->clone(C);
 511     }
 512   }
 513   // cloning CallNode may need to clone JVMState
 514   if (n->is_Call()) {
 515     n->as_Call()->clone_jvms(C);
 516   }
 517   if (n->is_SafePoint()) {
 518     n->as_SafePoint()->clone_replaced_nodes();
 519   }
 520   return n;                     // Return the clone
 521 }
 522 
 523 //---------------------------setup_is_top--------------------------------------
 524 // Call this when changing the top node, to reassert the invariants
 525 // required by Node::is_top.  See Compile::set_cached_top_node.
 526 void Node::setup_is_top() {
 527   if (this == (Node*)Compile::current()->top()) {
 528     // This node has just become top.  Kill its out array.
 529     _outcnt = _outmax = 0;
 530     _out = NULL;                           // marker value for top
 531     assert(is_top(), "must be top");
 532   } else {
 533     if (_out == NULL)  _out = NO_OUT_ARRAY;
 534     assert(!is_top(), "must not be top");
 535   }
 536 }
 537 
 538 
 539 //------------------------------~Node------------------------------------------


 594     // Free just the input array
 595 #ifdef ASSERT
 596     if( edge_end == compile->node_arena()->hwm() )
 597       reclaim_in  += edge_size;
 598 #endif
 599     compile->node_arena()->Afree(_in,edge_size);
 600 
 601     // Free just the object
 602 #ifdef ASSERT
 603     if( ((char*)this) + node_size == compile->node_arena()->hwm() )
 604       reclaim_node+= node_size;
 605 #else
 606     compile->node_arena()->Afree(this,node_size);
 607 #endif
 608   }
 609   if (is_macro()) {
 610     compile->remove_macro_node(this);
 611   }
 612   if (is_expensive()) {
 613     compile->remove_expensive_node(this);
 614   }
 615   if (is_SafePoint()) {
 616     as_SafePoint()->delete_replaced_nodes();
 617   }
 618 #ifdef ASSERT
 619   // We will not actually delete the storage, but we'll make the node unusable.
 620   *(address*)this = badAddress;  // smash the C++ vtbl, probably
 621   _in = _out = (Node**) badAddress;
 622   _max = _cnt = _outmax = _outcnt = 0;
 623 #endif
 624 }
 625 
 626 //------------------------------grow-------------------------------------------
 627 // Grow the input array, making space for more edges
 628 void Node::grow( uint len ) {
 629   Arena* arena = Compile::current()->node_arena();
 630   uint new_max = _max;
 631   if( new_max == 0 ) {
 632     _max = 4;
 633     _in = (Node**)arena->Amalloc(4*sizeof(Node*));
 634     Node** to = _in;
 635     to[0] = NULL;
 636     to[1] = NULL;


src/share/vm/opto/node.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File