< prev index next >

src/share/vm/opto/node.cpp

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 "libadt/vectset.hpp"
  27 #include "memory/allocation.inline.hpp"

  28 #include "opto/cfgnode.hpp"
  29 #include "opto/connode.hpp"
  30 #include "opto/loopnode.hpp"
  31 #include "opto/machnode.hpp"
  32 #include "opto/matcher.hpp"
  33 #include "opto/node.hpp"
  34 #include "opto/opcodes.hpp"
  35 #include "opto/regmask.hpp"
  36 #include "opto/type.hpp"
  37 #include "utilities/copy.hpp"
  38 
  39 class RegMask;
  40 // #include "phase.hpp"
  41 class PhaseTransform;
  42 class PhaseGVN;
  43 
  44 // Arena we are currently building Nodes in
  45 const uint Node::NotAMachineReg = 0xffff0000;
  46 
  47 #ifndef PRODUCT


 499   // Set the new input pointer array
 500   n->_in = (Node**)(((char*)n)+s);
 501   // Cannot share the old output pointer array, so kill it
 502   n->_out = NO_OUT_ARRAY;
 503   // And reset the counters to 0
 504   n->_outcnt = 0;
 505   n->_outmax = 0;
 506   // Unlock this guy, since he is not in any hash table.
 507   debug_only(n->_hash_lock = 0);
 508   // Walk the old node's input list to duplicate its edges
 509   uint i;
 510   for( i = 0; i < len(); i++ ) {
 511     Node *x = in(i);
 512     n->_in[i] = x;
 513     if (x != NULL) x->add_out(n);
 514   }
 515   if (is_macro())
 516     C->add_macro_node(n);
 517   if (is_expensive())
 518     C->add_expensive_node(n);





 519 
 520   n->set_idx(C->next_unique()); // Get new unique index as well
 521   debug_only( n->verify_construction() );
 522   NOT_PRODUCT(nodes_created++);
 523   // Do not patch over the debug_idx of a clone, because it makes it
 524   // impossible to break on the clone's moment of creation.
 525   //debug_only( n->set_debug_idx( debug_idx() ) );
 526 
 527   C->copy_node_notes_to(n, (Node*) this);
 528 
 529   // MachNode clone
 530   uint nopnds;
 531   if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
 532     MachNode *mach  = n->as_Mach();
 533     MachNode *mthis = this->as_Mach();
 534     // Get address of _opnd_array.
 535     // It should be the same offset since it is the clone of this node.
 536     MachOper **from = mthis->_opnds;
 537     MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
 538                     pointer_delta((const void*)from,


 627 #ifdef ASSERT
 628     if( edge_end == compile->node_arena()->hwm() )
 629       reclaim_in  += edge_size;
 630 #endif
 631     compile->node_arena()->Afree(_in,edge_size);
 632 
 633     // Free just the object
 634 #ifdef ASSERT
 635     if( ((char*)this) + node_size == compile->node_arena()->hwm() )
 636       reclaim_node+= node_size;
 637 #else
 638     compile->node_arena()->Afree(this,node_size);
 639 #endif
 640   }
 641   if (is_macro()) {
 642     compile->remove_macro_node(this);
 643   }
 644   if (is_expensive()) {
 645     compile->remove_expensive_node(this);
 646   }





 647   if (is_SafePoint()) {
 648     as_SafePoint()->delete_replaced_nodes();
 649   }
 650 #ifdef ASSERT
 651   // We will not actually delete the storage, but we'll make the node unusable.
 652   *(address*)this = badAddress;  // smash the C++ vtbl, probably
 653   _in = _out = (Node**) badAddress;
 654   _max = _cnt = _outmax = _outcnt = 0;
 655   compile->remove_modified_node(this);
 656 #endif
 657 }
 658 
 659 //------------------------------grow-------------------------------------------
 660 // Grow the input array, making space for more edges
 661 void Node::grow( uint len ) {
 662   Arena* arena = Compile::current()->node_arena();
 663   uint new_max = _max;
 664   if( new_max == 0 ) {
 665     _max = 4;
 666     _in = (Node**)arena->Amalloc(4*sizeof(Node*));


1361             }
1362             nstack.push(use);
1363           } else {
1364             igvn->_worklist.push(use);
1365           }
1366         }
1367         // Refresh the iterator, since any number of kills might have happened.
1368         k = dead->last_outs(kmin);
1369       }
1370     } else { // (dead->outcnt() == 0)
1371       // Done with outputs.
1372       igvn->hash_delete(dead);
1373       igvn->_worklist.remove(dead);
1374       igvn->C->remove_modified_node(dead);
1375       igvn->set_type(dead, Type::TOP);
1376       if (dead->is_macro()) {
1377         igvn->C->remove_macro_node(dead);
1378       }
1379       if (dead->is_expensive()) {
1380         igvn->C->remove_expensive_node(dead);




1381       }
1382       igvn->C->record_dead_node(dead->_idx);
1383       // Kill all inputs to the dead guy
1384       for (uint i=0; i < dead->req(); i++) {
1385         Node *n = dead->in(i);      // Get input to dead guy
1386         if (n != NULL && !n->is_top()) { // Input is valid?
1387           dead->set_req(i, top);    // Smash input away
1388           if (n->outcnt() == 0) {   // Input also goes dead?
1389             if (!n->is_Con())
1390               nstack.push(n);       // Clear it out as well
1391           } else if (n->outcnt() == 1 &&
1392                      n->has_special_unique_user()) {
1393             igvn->add_users_to_worklist( n );
1394           } else if (n->outcnt() <= 2 && n->is_Store()) {
1395             // Push store's uses on worklist to enable folding optimization for
1396             // store/store and store/load to the same address.
1397             // The restriction (outcnt() <= 2) is the same as in set_req_X()
1398             // and remove_globally_dead_node().
1399             igvn->add_users_to_worklist( n );
1400           }




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 "libadt/vectset.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "opto/castnode.hpp"
  29 #include "opto/cfgnode.hpp"
  30 #include "opto/connode.hpp"
  31 #include "opto/loopnode.hpp"
  32 #include "opto/machnode.hpp"
  33 #include "opto/matcher.hpp"
  34 #include "opto/node.hpp"
  35 #include "opto/opcodes.hpp"
  36 #include "opto/regmask.hpp"
  37 #include "opto/type.hpp"
  38 #include "utilities/copy.hpp"
  39 
  40 class RegMask;
  41 // #include "phase.hpp"
  42 class PhaseTransform;
  43 class PhaseGVN;
  44 
  45 // Arena we are currently building Nodes in
  46 const uint Node::NotAMachineReg = 0xffff0000;
  47 
  48 #ifndef PRODUCT


 500   // Set the new input pointer array
 501   n->_in = (Node**)(((char*)n)+s);
 502   // Cannot share the old output pointer array, so kill it
 503   n->_out = NO_OUT_ARRAY;
 504   // And reset the counters to 0
 505   n->_outcnt = 0;
 506   n->_outmax = 0;
 507   // Unlock this guy, since he is not in any hash table.
 508   debug_only(n->_hash_lock = 0);
 509   // Walk the old node's input list to duplicate its edges
 510   uint i;
 511   for( i = 0; i < len(); i++ ) {
 512     Node *x = in(i);
 513     n->_in[i] = x;
 514     if (x != NULL) x->add_out(n);
 515   }
 516   if (is_macro())
 517     C->add_macro_node(n);
 518   if (is_expensive())
 519     C->add_expensive_node(n);
 520   // If the cloned node is a range check dependent CastII, add it to the list.
 521   CastIINode* cast = n->isa_CastII();
 522   if (cast != NULL && cast->has_range_check()) {
 523     C->add_range_check_cast(cast);
 524   }
 525 
 526   n->set_idx(C->next_unique()); // Get new unique index as well
 527   debug_only( n->verify_construction() );
 528   NOT_PRODUCT(nodes_created++);
 529   // Do not patch over the debug_idx of a clone, because it makes it
 530   // impossible to break on the clone's moment of creation.
 531   //debug_only( n->set_debug_idx( debug_idx() ) );
 532 
 533   C->copy_node_notes_to(n, (Node*) this);
 534 
 535   // MachNode clone
 536   uint nopnds;
 537   if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
 538     MachNode *mach  = n->as_Mach();
 539     MachNode *mthis = this->as_Mach();
 540     // Get address of _opnd_array.
 541     // It should be the same offset since it is the clone of this node.
 542     MachOper **from = mthis->_opnds;
 543     MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
 544                     pointer_delta((const void*)from,


 633 #ifdef ASSERT
 634     if( edge_end == compile->node_arena()->hwm() )
 635       reclaim_in  += edge_size;
 636 #endif
 637     compile->node_arena()->Afree(_in,edge_size);
 638 
 639     // Free just the object
 640 #ifdef ASSERT
 641     if( ((char*)this) + node_size == compile->node_arena()->hwm() )
 642       reclaim_node+= node_size;
 643 #else
 644     compile->node_arena()->Afree(this,node_size);
 645 #endif
 646   }
 647   if (is_macro()) {
 648     compile->remove_macro_node(this);
 649   }
 650   if (is_expensive()) {
 651     compile->remove_expensive_node(this);
 652   }
 653   CastIINode* cast = isa_CastII();
 654   if (cast != NULL && cast->has_range_check()) {
 655     compile->remove_range_check_cast(cast);
 656   }
 657 
 658   if (is_SafePoint()) {
 659     as_SafePoint()->delete_replaced_nodes();
 660   }
 661 #ifdef ASSERT
 662   // We will not actually delete the storage, but we'll make the node unusable.
 663   *(address*)this = badAddress;  // smash the C++ vtbl, probably
 664   _in = _out = (Node**) badAddress;
 665   _max = _cnt = _outmax = _outcnt = 0;
 666   compile->remove_modified_node(this);
 667 #endif
 668 }
 669 
 670 //------------------------------grow-------------------------------------------
 671 // Grow the input array, making space for more edges
 672 void Node::grow( uint len ) {
 673   Arena* arena = Compile::current()->node_arena();
 674   uint new_max = _max;
 675   if( new_max == 0 ) {
 676     _max = 4;
 677     _in = (Node**)arena->Amalloc(4*sizeof(Node*));


1372             }
1373             nstack.push(use);
1374           } else {
1375             igvn->_worklist.push(use);
1376           }
1377         }
1378         // Refresh the iterator, since any number of kills might have happened.
1379         k = dead->last_outs(kmin);
1380       }
1381     } else { // (dead->outcnt() == 0)
1382       // Done with outputs.
1383       igvn->hash_delete(dead);
1384       igvn->_worklist.remove(dead);
1385       igvn->C->remove_modified_node(dead);
1386       igvn->set_type(dead, Type::TOP);
1387       if (dead->is_macro()) {
1388         igvn->C->remove_macro_node(dead);
1389       }
1390       if (dead->is_expensive()) {
1391         igvn->C->remove_expensive_node(dead);
1392       }
1393       CastIINode* cast = dead->isa_CastII();
1394       if (cast != NULL && cast->has_range_check()) {
1395         igvn->C->remove_range_check_cast(cast);
1396       }
1397       igvn->C->record_dead_node(dead->_idx);
1398       // Kill all inputs to the dead guy
1399       for (uint i=0; i < dead->req(); i++) {
1400         Node *n = dead->in(i);      // Get input to dead guy
1401         if (n != NULL && !n->is_top()) { // Input is valid?
1402           dead->set_req(i, top);    // Smash input away
1403           if (n->outcnt() == 0) {   // Input also goes dead?
1404             if (!n->is_Con())
1405               nstack.push(n);       // Clear it out as well
1406           } else if (n->outcnt() == 1 &&
1407                      n->has_special_unique_user()) {
1408             igvn->add_users_to_worklist( n );
1409           } else if (n->outcnt() <= 2 && n->is_Store()) {
1410             // Push store's uses on worklist to enable folding optimization for
1411             // store/store and store/load to the same address.
1412             // The restriction (outcnt() <= 2) is the same as in set_req_X()
1413             // and remove_globally_dead_node().
1414             igvn->add_users_to_worklist( n );
1415           }


< prev index next >