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 6447 : 8026796: Make replace_in_map() on parent maps generic
Summary: propagate node replacements along control flow edges to callers
Reviewed-by:
rev 6448 : [mq]: replaceinmap-8026796-reviews


 518   // MachNode clone
 519   uint nopnds;
 520   if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
 521     MachNode *mach  = n->as_Mach();
 522     MachNode *mthis = this->as_Mach();
 523     // Get address of _opnd_array.
 524     // It should be the same offset since it is the clone of this node.
 525     MachOper **from = mthis->_opnds;
 526     MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
 527                     pointer_delta((const void*)from,
 528                                   (const void*)(&mthis->_opnds), 1));
 529     mach->_opnds = to;
 530     for ( uint i = 0; i < nopnds; ++i ) {
 531       to[i] = from[i]->clone(C);
 532     }
 533   }
 534   // cloning CallNode may need to clone JVMState
 535   if (n->is_Call()) {
 536     n->as_Call()->clone_jvms(C);
 537   }



 538   return n;                     // Return the clone
 539 }
 540 
 541 //---------------------------setup_is_top--------------------------------------
 542 // Call this when changing the top node, to reassert the invariants
 543 // required by Node::is_top.  See Compile::set_cached_top_node.
 544 void Node::setup_is_top() {
 545   if (this == (Node*)Compile::current()->top()) {
 546     // This node has just become top.  Kill its out array.
 547     _outcnt = _outmax = 0;
 548     _out = NULL;                           // marker value for top
 549     assert(is_top(), "must be top");
 550   } else {
 551     if (_out == NULL)  _out = NO_OUT_ARRAY;
 552     assert(!is_top(), "must not be top");
 553   }
 554 }
 555 
 556 
 557 //------------------------------~Node------------------------------------------


 612     // Free just the input array
 613 #ifdef ASSERT
 614     if( edge_end == compile->node_arena()->hwm() )
 615       reclaim_in  += edge_size;
 616 #endif
 617     compile->node_arena()->Afree(_in,edge_size);
 618 
 619     // Free just the object
 620 #ifdef ASSERT
 621     if( ((char*)this) + node_size == compile->node_arena()->hwm() )
 622       reclaim_node+= node_size;
 623 #else
 624     compile->node_arena()->Afree(this,node_size);
 625 #endif
 626   }
 627   if (is_macro()) {
 628     compile->remove_macro_node(this);
 629   }
 630   if (is_expensive()) {
 631     compile->remove_expensive_node(this);



 632   }
 633 #ifdef ASSERT
 634   // We will not actually delete the storage, but we'll make the node unusable.
 635   *(address*)this = badAddress;  // smash the C++ vtbl, probably
 636   _in = _out = (Node**) badAddress;
 637   _max = _cnt = _outmax = _outcnt = 0;
 638 #endif
 639 }
 640 
 641 //------------------------------grow-------------------------------------------
 642 // Grow the input array, making space for more edges
 643 void Node::grow( uint len ) {
 644   Arena* arena = Compile::current()->node_arena();
 645   uint new_max = _max;
 646   if( new_max == 0 ) {
 647     _max = 4;
 648     _in = (Node**)arena->Amalloc(4*sizeof(Node*));
 649     Node** to = _in;
 650     to[0] = NULL;
 651     to[1] = NULL;




 518   // MachNode clone
 519   uint nopnds;
 520   if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
 521     MachNode *mach  = n->as_Mach();
 522     MachNode *mthis = this->as_Mach();
 523     // Get address of _opnd_array.
 524     // It should be the same offset since it is the clone of this node.
 525     MachOper **from = mthis->_opnds;
 526     MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
 527                     pointer_delta((const void*)from,
 528                                   (const void*)(&mthis->_opnds), 1));
 529     mach->_opnds = to;
 530     for ( uint i = 0; i < nopnds; ++i ) {
 531       to[i] = from[i]->clone(C);
 532     }
 533   }
 534   // cloning CallNode may need to clone JVMState
 535   if (n->is_Call()) {
 536     n->as_Call()->clone_jvms(C);
 537   }
 538   if (n->is_SafePoint()) {
 539     n->as_SafePoint()->clone_replaced_nodes();
 540   }
 541   return n;                     // Return the clone
 542 }
 543 
 544 //---------------------------setup_is_top--------------------------------------
 545 // Call this when changing the top node, to reassert the invariants
 546 // required by Node::is_top.  See Compile::set_cached_top_node.
 547 void Node::setup_is_top() {
 548   if (this == (Node*)Compile::current()->top()) {
 549     // This node has just become top.  Kill its out array.
 550     _outcnt = _outmax = 0;
 551     _out = NULL;                           // marker value for top
 552     assert(is_top(), "must be top");
 553   } else {
 554     if (_out == NULL)  _out = NO_OUT_ARRAY;
 555     assert(!is_top(), "must not be top");
 556   }
 557 }
 558 
 559 
 560 //------------------------------~Node------------------------------------------


 615     // Free just the input array
 616 #ifdef ASSERT
 617     if( edge_end == compile->node_arena()->hwm() )
 618       reclaim_in  += edge_size;
 619 #endif
 620     compile->node_arena()->Afree(_in,edge_size);
 621 
 622     // Free just the object
 623 #ifdef ASSERT
 624     if( ((char*)this) + node_size == compile->node_arena()->hwm() )
 625       reclaim_node+= node_size;
 626 #else
 627     compile->node_arena()->Afree(this,node_size);
 628 #endif
 629   }
 630   if (is_macro()) {
 631     compile->remove_macro_node(this);
 632   }
 633   if (is_expensive()) {
 634     compile->remove_expensive_node(this);
 635   }
 636   if (is_SafePoint()) {
 637     as_SafePoint()->delete_replaced_nodes();
 638   }
 639 #ifdef ASSERT
 640   // We will not actually delete the storage, but we'll make the node unusable.
 641   *(address*)this = badAddress;  // smash the C++ vtbl, probably
 642   _in = _out = (Node**) badAddress;
 643   _max = _cnt = _outmax = _outcnt = 0;
 644 #endif
 645 }
 646 
 647 //------------------------------grow-------------------------------------------
 648 // Grow the input array, making space for more edges
 649 void Node::grow( uint len ) {
 650   Arena* arena = Compile::current()->node_arena();
 651   uint new_max = _max;
 652   if( new_max == 0 ) {
 653     _max = 4;
 654     _in = (Node**)arena->Amalloc(4*sizeof(Node*));
 655     Node** to = _in;
 656     to[0] = NULL;
 657     to[1] = NULL;


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