< prev index next >

src/hotspot/share/opto/node.hpp

Print this page
@@ -1631,10 +1631,11 @@
    Node** _nodes;
    ReallocMark _nesting;         // Safety checks for arena reallocation
  
    // Grow array to required capacity
    void maybe_grow(uint i) {
+     _nesting.check(_a); // Check if a potential reallocation in the arena is safe
      if (i >= _max) {
        grow(i);
      }
    }
    void grow(uint i);

@@ -1882,11 +1883,19 @@
    INode *_inode_top; // tos, stack grows up
    INode *_inode_max; // End of _inodes == _inodes + _max
    INode *_inodes;    // Array storage for the stack
    Arena *_a;         // Arena to allocate in
    ReallocMark _nesting; // Safety checks for arena reallocation
+ 
+   void maybe_grow() {
+     _nesting.check(_a); // Check if a potential reallocation in the arena is safe
+     if (_inode_top >= _inode_max) {
+       grow();
+     }
+   }
    void grow();
+ 
  public:
    Node_Stack(int size) {
      size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
      _a = Thread::current()->resource_area();
      _inodes = NEW_ARENA_ARRAY( _a, INode, max );

@@ -1905,11 +1914,11 @@
      assert(_inode_top >= _inodes, "node stack underflow");
      --_inode_top;
    }
    void push(Node *n, uint i) {
      ++_inode_top;
-     grow();
+     maybe_grow();
      INode *top = _inode_top; // optimization
      top->node = n;
      top->indx = i;
    }
    Node *node() const {
< prev index next >