766 if (in == n) {
767 no_dead_loop = false;
768 } else if (in != NULL && !in->is_dead_loop_safe()) {
769 uint icnt = in->req();
770 for (uint j = 1; j < icnt && no_dead_loop; j++) {
771 if (in->in(j) == n || in->in(j) == in)
772 no_dead_loop = false;
773 }
774 }
775 }
776 if (!no_dead_loop) n->dump(3);
777 assert(no_dead_loop, "dead loop detected");
778 }
779 }
780 #endif
781
782 //=============================================================================
783 //------------------------------PhaseIterGVN-----------------------------------
784 // Initialize hash table to fresh and clean for +VerifyOpto
785 PhaseIterGVN::PhaseIterGVN( PhaseIterGVN *igvn, const char *dummy ) : PhaseGVN(igvn,dummy), _worklist( ),
786 _stack(C->unique() >> 1),
787 _delay_transform(false) {
788 }
789
790 //------------------------------PhaseIterGVN-----------------------------------
791 // Initialize with previous PhaseIterGVN info; used by PhaseCCP
792 PhaseIterGVN::PhaseIterGVN( PhaseIterGVN *igvn ) : PhaseGVN(igvn),
793 _worklist( igvn->_worklist ),
794 _stack( igvn->_stack ),
795 _delay_transform(igvn->_delay_transform)
796 {
797 }
798
799 //------------------------------PhaseIterGVN-----------------------------------
800 // Initialize with previous PhaseGVN info from Parser
801 PhaseIterGVN::PhaseIterGVN( PhaseGVN *gvn ) : PhaseGVN(gvn),
802 _worklist(*C->for_igvn()),
803 _stack(C->unique() >> 1),
804 _delay_transform(false)
805 {
806 uint max;
807
808 // Dead nodes in the hash table inherited from GVN were not treated as
809 // roots during def-use info creation; hence they represent an invisible
810 // use. Clear them out.
811 max = _table.size();
812 for( uint i = 0; i < max; ++i ) {
813 Node *n = _table.at(i);
814 if(n != NULL && n != _table.sentinel() && n->outcnt() == 0) {
815 if( n->is_top() ) continue;
816 assert( false, "Parse::remove_useless_nodes missed this node");
817 hash_delete(n);
818 }
819 }
820
821 // Any Phis or Regions on the worklist probably had uses that could not
822 // make more progress because the uses were made while the Phis and Regions
823 // were in half-built states. Put all uses of Phis and Regions on worklist.
1569 //------------------------------do_transform-----------------------------------
1570 // Top level driver for the recursive transformer
1571 void PhaseCCP::do_transform() {
1572 // Correct leaves of new-space Nodes; they point to old-space.
1573 C->set_root( transform(C->root())->as_Root() );
1574 assert( C->top(), "missing TOP node" );
1575 assert( C->root(), "missing root" );
1576 }
1577
1578 //------------------------------transform--------------------------------------
1579 // Given a Node in old-space, clone him into new-space.
1580 // Convert any of his old-space children into new-space children.
1581 Node *PhaseCCP::transform( Node *n ) {
1582 Node *new_node = _nodes[n->_idx]; // Check for transformed node
1583 if( new_node != NULL )
1584 return new_node; // Been there, done that, return old answer
1585 new_node = transform_once(n); // Check for constant
1586 _nodes.map( n->_idx, new_node ); // Flag as having been cloned
1587
1588 // Allocate stack of size _nodes.Size()/2 to avoid frequent realloc
1589 GrowableArray <Node *> trstack(C->unique() >> 1);
1590
1591 trstack.push(new_node); // Process children of cloned node
1592 while ( trstack.is_nonempty() ) {
1593 Node *clone = trstack.pop();
1594 uint cnt = clone->req();
1595 for( uint i = 0; i < cnt; i++ ) { // For all inputs do
1596 Node *input = clone->in(i);
1597 if( input != NULL ) { // Ignore NULLs
1598 Node *new_input = _nodes[input->_idx]; // Check for cloned input node
1599 if( new_input == NULL ) {
1600 new_input = transform_once(input); // Check for constant
1601 _nodes.map( input->_idx, new_input );// Flag as having been cloned
1602 trstack.push(new_input);
1603 }
1604 assert( new_input == clone->in(i), "insanity check");
1605 }
1606 }
1607 }
1608 return new_node;
1609 }
|
766 if (in == n) {
767 no_dead_loop = false;
768 } else if (in != NULL && !in->is_dead_loop_safe()) {
769 uint icnt = in->req();
770 for (uint j = 1; j < icnt && no_dead_loop; j++) {
771 if (in->in(j) == n || in->in(j) == in)
772 no_dead_loop = false;
773 }
774 }
775 }
776 if (!no_dead_loop) n->dump(3);
777 assert(no_dead_loop, "dead loop detected");
778 }
779 }
780 #endif
781
782 //=============================================================================
783 //------------------------------PhaseIterGVN-----------------------------------
784 // Initialize hash table to fresh and clean for +VerifyOpto
785 PhaseIterGVN::PhaseIterGVN( PhaseIterGVN *igvn, const char *dummy ) : PhaseGVN(igvn,dummy), _worklist( ),
786 _stack(C->live_nodes() >> 1),
787 _delay_transform(false) {
788 }
789
790 //------------------------------PhaseIterGVN-----------------------------------
791 // Initialize with previous PhaseIterGVN info; used by PhaseCCP
792 PhaseIterGVN::PhaseIterGVN( PhaseIterGVN *igvn ) : PhaseGVN(igvn),
793 _worklist( igvn->_worklist ),
794 _stack( igvn->_stack ),
795 _delay_transform(igvn->_delay_transform)
796 {
797 }
798
799 //------------------------------PhaseIterGVN-----------------------------------
800 // Initialize with previous PhaseGVN info from Parser
801 PhaseIterGVN::PhaseIterGVN( PhaseGVN *gvn ) : PhaseGVN(gvn),
802 _worklist(*C->for_igvn()),
803 // TODO: Before incremental inlining it was allocated only once and it was fine. Now that
804 // the constructor is used in incremental inlining, this consumes too much memory:
805 // _stack(C->live_nodes() >> 1),
806 // So, as a band-aid, we replace this by:
807 _stack(C->comp_arena(), 32),
808 _delay_transform(false)
809 {
810 uint max;
811
812 // Dead nodes in the hash table inherited from GVN were not treated as
813 // roots during def-use info creation; hence they represent an invisible
814 // use. Clear them out.
815 max = _table.size();
816 for( uint i = 0; i < max; ++i ) {
817 Node *n = _table.at(i);
818 if(n != NULL && n != _table.sentinel() && n->outcnt() == 0) {
819 if( n->is_top() ) continue;
820 assert( false, "Parse::remove_useless_nodes missed this node");
821 hash_delete(n);
822 }
823 }
824
825 // Any Phis or Regions on the worklist probably had uses that could not
826 // make more progress because the uses were made while the Phis and Regions
827 // were in half-built states. Put all uses of Phis and Regions on worklist.
1573 //------------------------------do_transform-----------------------------------
1574 // Top level driver for the recursive transformer
1575 void PhaseCCP::do_transform() {
1576 // Correct leaves of new-space Nodes; they point to old-space.
1577 C->set_root( transform(C->root())->as_Root() );
1578 assert( C->top(), "missing TOP node" );
1579 assert( C->root(), "missing root" );
1580 }
1581
1582 //------------------------------transform--------------------------------------
1583 // Given a Node in old-space, clone him into new-space.
1584 // Convert any of his old-space children into new-space children.
1585 Node *PhaseCCP::transform( Node *n ) {
1586 Node *new_node = _nodes[n->_idx]; // Check for transformed node
1587 if( new_node != NULL )
1588 return new_node; // Been there, done that, return old answer
1589 new_node = transform_once(n); // Check for constant
1590 _nodes.map( n->_idx, new_node ); // Flag as having been cloned
1591
1592 // Allocate stack of size _nodes.Size()/2 to avoid frequent realloc
1593 GrowableArray <Node *> trstack(C->live_nodes() >> 1);
1594
1595 trstack.push(new_node); // Process children of cloned node
1596 while ( trstack.is_nonempty() ) {
1597 Node *clone = trstack.pop();
1598 uint cnt = clone->req();
1599 for( uint i = 0; i < cnt; i++ ) { // For all inputs do
1600 Node *input = clone->in(i);
1601 if( input != NULL ) { // Ignore NULLs
1602 Node *new_input = _nodes[input->_idx]; // Check for cloned input node
1603 if( new_input == NULL ) {
1604 new_input = transform_once(input); // Check for constant
1605 _nodes.map( input->_idx, new_input );// Flag as having been cloned
1606 trstack.push(new_input);
1607 }
1608 assert( new_input == clone->in(i), "insanity check");
1609 }
1610 }
1611 }
1612 return new_node;
1613 }
|