40 class PhaseTransform;
41 class PhaseGVN;
42
43 // Arena we are currently building Nodes in
44 const uint Node::NotAMachineReg = 0xffff0000;
45
46 #ifndef PRODUCT
47 extern int nodes_created;
48 #endif
49
50 #ifdef ASSERT
51
52 //-------------------------- construct_node------------------------------------
53 // Set a breakpoint here to identify where a particular node index is built.
54 void Node::verify_construction() {
55 _debug_orig = NULL;
56 int old_debug_idx = Compile::debug_idx();
57 int new_debug_idx = old_debug_idx+1;
58 if (new_debug_idx > 0) {
59 // Arrange that the lowest five decimal digits of _debug_idx
60 // will repeat thos of _idx. In case this is somehow pathological,
61 // we continue to assign negative numbers (!) consecutively.
62 const int mod = 100000;
63 int bump = (int)(_idx - new_debug_idx) % mod;
64 if (bump < 0) bump += mod;
65 assert(bump >= 0 && bump < mod, "");
66 new_debug_idx += bump;
67 }
68 Compile::set_debug_idx(new_debug_idx);
69 set_debug_idx( new_debug_idx );
70 assert(Compile::current()->unique() < (uint)MaxNodeLimit, "Node limit exceeded");
71 if (BreakAtNode != 0 && (_debug_idx == BreakAtNode || (int)_idx == BreakAtNode)) {
72 tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d", _idx, _debug_idx);
73 BREAKPOINT;
74 }
75 #if OPTO_DU_ITERATOR_ASSERT
76 _last_del = NULL;
77 _del_tick = 0;
78 #endif
79 _hash_lock = 0;
80 }
81
82
83 // #ifdef ASSERT ...
84
85 #if OPTO_DU_ITERATOR_ASSERT
86 void DUIterator_Common::sample(const Node* node) {
87 _vdui = VerifyDUIterators;
88 _node = node;
89 _outcnt = node->_outcnt;
90 _del_tick = node->_del_tick;
785
786 //----------------------------replace_edge-------------------------------------
787 int Node::replace_edge(Node* old, Node* neww) {
788 if (old == neww) return 0; // nothing to do
789 uint nrep = 0;
790 for (uint i = 0; i < len(); i++) {
791 if (in(i) == old) {
792 if (i < req())
793 set_req(i, neww);
794 else
795 set_prec(i, neww);
796 nrep++;
797 }
798 }
799 return nrep;
800 }
801
802 //-------------------------disconnect_inputs-----------------------------------
803 // NULL out all inputs to eliminate incoming Def-Use edges.
804 // Return the number of edges between 'n' and 'this'
805 int Node::disconnect_inputs(Node *n) {
806 int edges_to_n = 0;
807
808 uint cnt = req();
809 for( uint i = 0; i < cnt; ++i ) {
810 if( in(i) == 0 ) continue;
811 if( in(i) == n ) ++edges_to_n;
812 set_req(i, NULL);
813 }
814 // Remove precedence edges if any exist
815 // Note: Safepoints may have precedence edges, even during parsing
816 if( (req() != len()) && (in(req()) != NULL) ) {
817 uint max = len();
818 for( uint i = 0; i < max; ++i ) {
819 if( in(i) == 0 ) continue;
820 if( in(i) == n ) ++edges_to_n;
821 set_prec(i, NULL);
822 }
823 }
824
825 // Node::destruct requires all out edges be deleted first
826 // debug_only(destruct();) // no reuse benefit expected
827 return edges_to_n;
828 }
829
830 //-----------------------------uncast---------------------------------------
831 // %%% Temporary, until we sort out CheckCastPP vs. CastPP.
832 // Strip away casting. (It is depth-limited.)
833 Node* Node::uncast() const {
834 // Should be inline:
835 //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
836 if (is_ConstraintCast() || is_CheckCastPP())
837 return uncast_helper(this);
838 else
839 return (Node*) this;
840 }
841
842 //---------------------------uncast_helper-------------------------------------
843 Node* Node::uncast_helper(const Node* p) {
844 #ifdef ASSERT
845 uint depth_count = 0;
846 const Node* orig_p = p;
|
40 class PhaseTransform;
41 class PhaseGVN;
42
43 // Arena we are currently building Nodes in
44 const uint Node::NotAMachineReg = 0xffff0000;
45
46 #ifndef PRODUCT
47 extern int nodes_created;
48 #endif
49
50 #ifdef ASSERT
51
52 //-------------------------- construct_node------------------------------------
53 // Set a breakpoint here to identify where a particular node index is built.
54 void Node::verify_construction() {
55 _debug_orig = NULL;
56 int old_debug_idx = Compile::debug_idx();
57 int new_debug_idx = old_debug_idx+1;
58 if (new_debug_idx > 0) {
59 // Arrange that the lowest five decimal digits of _debug_idx
60 // will repeat those of _idx. In case this is somehow pathological,
61 // we continue to assign negative numbers (!) consecutively.
62 const int mod = 100000;
63 int bump = (int)(_idx - new_debug_idx) % mod;
64 if (bump < 0) bump += mod;
65 assert(bump >= 0 && bump < mod, "");
66 new_debug_idx += bump;
67 }
68 Compile::set_debug_idx(new_debug_idx);
69 set_debug_idx( new_debug_idx );
70 assert(Compile::current()->unique() < (UINT_MAX - 1), "Node limit exceeded UINT_MAX");
71 if (BreakAtNode != 0 && (_debug_idx == BreakAtNode || (int)_idx == BreakAtNode)) {
72 tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d", _idx, _debug_idx);
73 BREAKPOINT;
74 }
75 #if OPTO_DU_ITERATOR_ASSERT
76 _last_del = NULL;
77 _del_tick = 0;
78 #endif
79 _hash_lock = 0;
80 }
81
82
83 // #ifdef ASSERT ...
84
85 #if OPTO_DU_ITERATOR_ASSERT
86 void DUIterator_Common::sample(const Node* node) {
87 _vdui = VerifyDUIterators;
88 _node = node;
89 _outcnt = node->_outcnt;
90 _del_tick = node->_del_tick;
785
786 //----------------------------replace_edge-------------------------------------
787 int Node::replace_edge(Node* old, Node* neww) {
788 if (old == neww) return 0; // nothing to do
789 uint nrep = 0;
790 for (uint i = 0; i < len(); i++) {
791 if (in(i) == old) {
792 if (i < req())
793 set_req(i, neww);
794 else
795 set_prec(i, neww);
796 nrep++;
797 }
798 }
799 return nrep;
800 }
801
802 //-------------------------disconnect_inputs-----------------------------------
803 // NULL out all inputs to eliminate incoming Def-Use edges.
804 // Return the number of edges between 'n' and 'this'
805 int Node::disconnect_inputs(Node *n, Compile* C) {
806 int edges_to_n = 0;
807
808 uint cnt = req();
809 for( uint i = 0; i < cnt; ++i ) {
810 if( in(i) == 0 ) continue;
811 if( in(i) == n ) ++edges_to_n;
812 set_req(i, NULL);
813 }
814 // Remove precedence edges if any exist
815 // Note: Safepoints may have precedence edges, even during parsing
816 if( (req() != len()) && (in(req()) != NULL) ) {
817 uint max = len();
818 for( uint i = 0; i < max; ++i ) {
819 if( in(i) == 0 ) continue;
820 if( in(i) == n ) ++edges_to_n;
821 set_prec(i, NULL);
822 }
823 }
824
825 // Node::destruct requires all out edges be deleted first
826 // debug_only(destruct();) // no reuse benefit expected
827 if (edges_to_n == 0) {
828 C->record_dead_node(_idx);
829 }
830 return edges_to_n;
831 }
832
833 //-----------------------------uncast---------------------------------------
834 // %%% Temporary, until we sort out CheckCastPP vs. CastPP.
835 // Strip away casting. (It is depth-limited.)
836 Node* Node::uncast() const {
837 // Should be inline:
838 //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
839 if (is_ConstraintCast() || is_CheckCastPP())
840 return uncast_helper(this);
841 else
842 return (Node*) this;
843 }
844
845 //---------------------------uncast_helper-------------------------------------
846 Node* Node::uncast_helper(const Node* p) {
847 #ifdef ASSERT
848 uint depth_count = 0;
849 const Node* orig_p = p;
|