< prev index next >

src/hotspot/share/opto/node.cpp

Print this page

2781 
2782 //------------------------------Registers--------------------------------------
2783 // Do we Match on this edge index or not?  Generally false for Control
2784 // and true for everything else.  Weird for calls & returns.
2785 uint Node::match_edge(uint idx) const {
2786   return idx;                   // True for other than index 0 (control)
2787 }
2788 
2789 // Register classes are defined for specific machines
2790 const RegMask &Node::out_RegMask() const {
2791   ShouldNotCallThis();
2792   return RegMask::Empty;
2793 }
2794 
2795 const RegMask &Node::in_RegMask(uint) const {
2796   ShouldNotCallThis();
2797   return RegMask::Empty;
2798 }
2799 
2800 void Node_Array::grow(uint i) {
2801   _nesting.check(_a); // Check if a potential reallocation in the arena is safe
2802   assert(i >= _max, "Should have been checked before, use maybe_grow?");
2803   assert(_max > 0, "invariant");
2804   uint old = _max;
2805   _max = next_power_of_2(i);
2806   _nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*));
2807   Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) );
2808 }
2809 
2810 void Node_Array::insert(uint i, Node* n) {
2811   if (_nodes[_max - 1]) {
2812     grow(_max);
2813   }
2814   Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i + 1], ((_max - i - 1) * sizeof(Node*)));
2815   _nodes[i] = n;
2816 }
2817 
2818 void Node_Array::remove(uint i) {
2819   Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i + 1], (HeapWord*)&_nodes[i], ((_max - i - 1) * sizeof(Node*)));
2820   _nodes[_max - 1] = nullptr;
2821 }

3021   }
3022 }
3023 
3024 //-----------------------remove_useless_nodes----------------------------------
3025 // Remove useless nodes from worklist
3026 void Unique_Node_List::remove_useless_nodes(VectorSet &useful) {
3027   for (uint i = 0; i < size(); ++i) {
3028     Node *n = at(i);
3029     assert( n != nullptr, "Did not expect null entries in worklist");
3030     if (!useful.test(n->_idx)) {
3031       _in_worklist.remove(n->_idx);
3032       map(i, Node_List::pop());
3033       --i;  // Visit popped node
3034       // If it was last entry, loop terminates since size() was also reduced
3035     }
3036   }
3037 }
3038 
3039 //=============================================================================
3040 void Node_Stack::grow() {
3041   _nesting.check(_a); // Check if a potential reallocation in the arena is safe
3042   if (_inode_top < _inode_max) {
3043     return; // No need to grow
3044   }
3045   size_t old_top = pointer_delta(_inode_top,_inodes,sizeof(INode)); // save _top
3046   size_t old_max = pointer_delta(_inode_max,_inodes,sizeof(INode));
3047   size_t max = old_max << 1;             // max * 2
3048   _inodes = REALLOC_ARENA_ARRAY(_a, INode, _inodes, old_max, max);
3049   _inode_max = _inodes + max;
3050   _inode_top = _inodes + old_top;        // restore _top
3051 }
3052 
3053 // Node_Stack is used to map nodes.
3054 Node* Node_Stack::find(uint idx) const {
3055   uint sz = size();
3056   for (uint i = 0; i < sz; i++) {
3057     if (idx == index_at(i)) {
3058       return node_at(i);
3059     }
3060   }
3061   return nullptr;
3062 }
3063 
3064 //=============================================================================

2781 
2782 //------------------------------Registers--------------------------------------
2783 // Do we Match on this edge index or not?  Generally false for Control
2784 // and true for everything else.  Weird for calls & returns.
2785 uint Node::match_edge(uint idx) const {
2786   return idx;                   // True for other than index 0 (control)
2787 }
2788 
2789 // Register classes are defined for specific machines
2790 const RegMask &Node::out_RegMask() const {
2791   ShouldNotCallThis();
2792   return RegMask::Empty;
2793 }
2794 
2795 const RegMask &Node::in_RegMask(uint) const {
2796   ShouldNotCallThis();
2797   return RegMask::Empty;
2798 }
2799 
2800 void Node_Array::grow(uint i) {

2801   assert(i >= _max, "Should have been checked before, use maybe_grow?");
2802   assert(_max > 0, "invariant");
2803   uint old = _max;
2804   _max = next_power_of_2(i);
2805   _nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*));
2806   Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) );
2807 }
2808 
2809 void Node_Array::insert(uint i, Node* n) {
2810   if (_nodes[_max - 1]) {
2811     grow(_max);
2812   }
2813   Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i + 1], ((_max - i - 1) * sizeof(Node*)));
2814   _nodes[i] = n;
2815 }
2816 
2817 void Node_Array::remove(uint i) {
2818   Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i + 1], (HeapWord*)&_nodes[i], ((_max - i - 1) * sizeof(Node*)));
2819   _nodes[_max - 1] = nullptr;
2820 }

3020   }
3021 }
3022 
3023 //-----------------------remove_useless_nodes----------------------------------
3024 // Remove useless nodes from worklist
3025 void Unique_Node_List::remove_useless_nodes(VectorSet &useful) {
3026   for (uint i = 0; i < size(); ++i) {
3027     Node *n = at(i);
3028     assert( n != nullptr, "Did not expect null entries in worklist");
3029     if (!useful.test(n->_idx)) {
3030       _in_worklist.remove(n->_idx);
3031       map(i, Node_List::pop());
3032       --i;  // Visit popped node
3033       // If it was last entry, loop terminates since size() was also reduced
3034     }
3035   }
3036 }
3037 
3038 //=============================================================================
3039 void Node_Stack::grow() {




3040   size_t old_top = pointer_delta(_inode_top,_inodes,sizeof(INode)); // save _top
3041   size_t old_max = pointer_delta(_inode_max,_inodes,sizeof(INode));
3042   size_t max = old_max << 1;             // max * 2
3043   _inodes = REALLOC_ARENA_ARRAY(_a, INode, _inodes, old_max, max);
3044   _inode_max = _inodes + max;
3045   _inode_top = _inodes + old_top;        // restore _top
3046 }
3047 
3048 // Node_Stack is used to map nodes.
3049 Node* Node_Stack::find(uint idx) const {
3050   uint sz = size();
3051   for (uint i = 0; i < sz; i++) {
3052     if (idx == index_at(i)) {
3053       return node_at(i);
3054     }
3055   }
3056   return nullptr;
3057 }
3058 
3059 //=============================================================================
< prev index next >