1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
816 assert( !VerifyHashTableKeys || _hash_lock == 0, |
816 assert( !VerifyHashTableKeys || _hash_lock == 0, |
817 "remove node from hash table before modifying it"); |
817 "remove node from hash table before modifying it"); |
818 // First remove corresponding def-use edge |
818 // First remove corresponding def-use edge |
819 Node *n = in(idx); |
819 Node *n = in(idx); |
820 if (n != NULL) n->del_out((Node *)this); |
820 if (n != NULL) n->del_out((Node *)this); |
821 _in[idx] = in(--_cnt); // Compact the array |
821 _in[idx] = in(--_cnt); // Compact the array |
822 _in[_cnt] = NULL; // NULL out emptied slot |
822 // Avoid spec violation: Gap in prec edges. |
|
823 close_prec_gap_at(_cnt); |
823 } |
824 } |
824 |
825 |
825 //------------------------------del_req_ordered-------------------------------- |
826 //------------------------------del_req_ordered-------------------------------- |
826 // Delete the required edge and compact the edge array with preserved order |
827 // Delete the required edge and compact the edge array with preserved order |
827 void Node::del_req_ordered( uint idx ) { |
828 void Node::del_req_ordered( uint idx ) { |
829 assert( !VerifyHashTableKeys || _hash_lock == 0, |
830 assert( !VerifyHashTableKeys || _hash_lock == 0, |
830 "remove node from hash table before modifying it"); |
831 "remove node from hash table before modifying it"); |
831 // First remove corresponding def-use edge |
832 // First remove corresponding def-use edge |
832 Node *n = in(idx); |
833 Node *n = in(idx); |
833 if (n != NULL) n->del_out((Node *)this); |
834 if (n != NULL) n->del_out((Node *)this); |
834 if (idx < _cnt - 1) { // Not last edge ? |
835 if (idx < --_cnt) { // Not last edge ? |
835 Copy::conjoint_words_to_lower((HeapWord*)&_in[idx+1], (HeapWord*)&_in[idx], ((_cnt-idx-1)*sizeof(Node*))); |
836 Copy::conjoint_words_to_lower((HeapWord*)&_in[idx+1], (HeapWord*)&_in[idx], ((_cnt-idx)*sizeof(Node*))); |
836 } |
837 } |
837 _in[--_cnt] = NULL; // NULL out emptied slot |
838 // Avoid spec violation: Gap in prec edges. |
|
839 close_prec_gap_at(_cnt); |
838 } |
840 } |
839 |
841 |
840 //------------------------------ins_req---------------------------------------- |
842 //------------------------------ins_req---------------------------------------- |
841 // Insert a new required input at the end |
843 // Insert a new required input at the end |
842 void Node::ins_req( uint idx, Node *n ) { |
844 void Node::ins_req( uint idx, Node *n ) { |
863 int Node::replace_edge(Node* old, Node* neww) { |
865 int Node::replace_edge(Node* old, Node* neww) { |
864 if (old == neww) return 0; // nothing to do |
866 if (old == neww) return 0; // nothing to do |
865 uint nrep = 0; |
867 uint nrep = 0; |
866 for (uint i = 0; i < len(); i++) { |
868 for (uint i = 0; i < len(); i++) { |
867 if (in(i) == old) { |
869 if (in(i) == old) { |
868 if (i < req()) |
870 if (i < req()) { |
869 set_req(i, neww); |
871 set_req(i, neww); |
870 else |
872 } else { |
|
873 assert(find_prec_edge(neww) == -1, err_msg("spec violation: duplicated prec edge (node %d -> %d)", _idx, neww->_idx)); |
871 set_prec(i, neww); |
874 set_prec(i, neww); |
|
875 } |
872 nrep++; |
876 nrep++; |
873 } |
877 } |
874 } |
878 } |
875 return nrep; |
879 return nrep; |
876 } |
880 } |
972 if( _cnt >= _max || in(_max-1) ) |
976 if( _cnt >= _max || in(_max-1) ) |
973 grow( _max+1 ); |
977 grow( _max+1 ); |
974 |
978 |
975 // Find a precedence edge to move |
979 // Find a precedence edge to move |
976 uint i = _cnt; |
980 uint i = _cnt; |
977 while( in(i) != NULL ) i++; |
981 while( in(i) != NULL ) { |
|
982 if (in(i) == n) return; // Avoid spec violation: duplicated prec edge. |
|
983 i++; |
|
984 } |
978 _in[i] = n; // Stuff prec edge over NULL |
985 _in[i] = n; // Stuff prec edge over NULL |
979 if ( n != NULL) n->add_out((Node *)this); // Add mirror edge |
986 if ( n != NULL) n->add_out((Node *)this); // Add mirror edge |
|
987 |
|
988 #ifdef ASSERT |
|
989 while ((++i)<_max) { assert(_in[i] == NULL, err_msg("spec violation: Gap in prec edges (node %d)", _idx)); } |
|
990 #endif |
980 } |
991 } |
981 |
992 |
982 //------------------------------rm_prec---------------------------------------- |
993 //------------------------------rm_prec---------------------------------------- |
983 // Remove a precedence input. Precedence inputs are unordered, with |
994 // Remove a precedence input. Precedence inputs are unordered, with |
984 // duplicates removed and NULLs packed down at the end. |
995 // duplicates removed and NULLs packed down at the end. |
985 void Node::rm_prec( uint j ) { |
996 void Node::rm_prec( uint j ) { |
986 |
997 assert(j < _max, err_msg("oob: i=%d, _max=%d", j, _max)); |
987 // Find end of precedence list to pack NULLs |
998 assert(j >= _cnt, "not a precedence edge"); |
988 uint i; |
999 if (_in[j] == NULL) return; // Avoid spec violation: Gap in prec edges. |
989 for( i=j; i<_max; i++ ) |
1000 _in[j]->del_out((Node *)this); |
990 if( !_in[i] ) // Find the NULL at end of prec edge list |
1001 close_prec_gap_at(j); |
991 break; |
|
992 if (_in[j] != NULL) _in[j]->del_out((Node *)this); |
|
993 _in[j] = _in[--i]; // Move last element over removed guy |
|
994 _in[i] = NULL; // NULL out last element |
|
995 } |
1002 } |
996 |
1003 |
997 //------------------------------size_of---------------------------------------- |
1004 //------------------------------size_of---------------------------------------- |
998 uint Node::size_of() const { return sizeof(*this); } |
1005 uint Node::size_of() const { return sizeof(*this); } |
999 |
1006 |