1616 bool has_next() { return i < imax; }
1617 void next() { i++; }
1618 Node* get() { return node->fast_out(i); }
1619 };
1620
1621
1622 //-----------------------------------------------------------------------------
1623 // Map dense integer indices to Nodes. Uses classic doubling-array trick.
1624 // Abstractly provides an infinite array of Node*'s, initialized to null.
1625 // Note that the constructor just zeros things, and since I use Arena
1626 // allocation I do not need a destructor to reclaim storage.
1627 class Node_Array : public AnyObj {
1628 protected:
1629 Arena* _a; // Arena to allocate in
1630 uint _max;
1631 Node** _nodes;
1632 ReallocMark _nesting; // Safety checks for arena reallocation
1633
1634 // Grow array to required capacity
1635 void maybe_grow(uint i) {
1636 if (i >= _max) {
1637 grow(i);
1638 }
1639 }
1640 void grow(uint i);
1641
1642 public:
1643 Node_Array(Arena* a, uint max = OptoNodeListSize) : _a(a), _max(max) {
1644 _nodes = NEW_ARENA_ARRAY(a, Node*, max);
1645 clear();
1646 }
1647 Node_Array() : Node_Array(Thread::current()->resource_area()) {}
1648
1649 NONCOPYABLE(Node_Array);
1650 Node_Array& operator=(Node_Array&&) = delete;
1651 // Allow move constructor for && (eg. capture return of function)
1652 Node_Array(Node_Array&&) = default;
1653
1654 Node *operator[] ( uint i ) const // Lookup, or null for not mapped
1655 { return (i<_max) ? _nodes[i] : (Node*)nullptr; }
1867 _igvn_worklist->push(n);
1868 }
1869
1870 // Inline definition of Compile::remove_for_igvn must be deferred to this point.
1871 inline void Compile::remove_for_igvn(Node* n) {
1872 _igvn_worklist->remove(n);
1873 }
1874
1875 //------------------------------Node_Stack-------------------------------------
1876 class Node_Stack {
1877 protected:
1878 struct INode {
1879 Node *node; // Processed node
1880 uint indx; // Index of next node's child
1881 };
1882 INode *_inode_top; // tos, stack grows up
1883 INode *_inode_max; // End of _inodes == _inodes + _max
1884 INode *_inodes; // Array storage for the stack
1885 Arena *_a; // Arena to allocate in
1886 ReallocMark _nesting; // Safety checks for arena reallocation
1887 void grow();
1888 public:
1889 Node_Stack(int size) {
1890 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1891 _a = Thread::current()->resource_area();
1892 _inodes = NEW_ARENA_ARRAY( _a, INode, max );
1893 _inode_max = _inodes + max;
1894 _inode_top = _inodes - 1; // stack is empty
1895 }
1896
1897 Node_Stack(Arena *a, int size) : _a(a) {
1898 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1899 _inodes = NEW_ARENA_ARRAY( _a, INode, max );
1900 _inode_max = _inodes + max;
1901 _inode_top = _inodes - 1; // stack is empty
1902 }
1903
1904 void pop() {
1905 assert(_inode_top >= _inodes, "node stack underflow");
1906 --_inode_top;
1907 }
1908 void push(Node *n, uint i) {
1909 ++_inode_top;
1910 grow();
1911 INode *top = _inode_top; // optimization
1912 top->node = n;
1913 top->indx = i;
1914 }
1915 Node *node() const {
1916 return _inode_top->node;
1917 }
1918 Node* node_at(uint i) const {
1919 assert(_inodes + i <= _inode_top, "in range");
1920 return _inodes[i].node;
1921 }
1922 uint index() const {
1923 return _inode_top->indx;
1924 }
1925 uint index_at(uint i) const {
1926 assert(_inodes + i <= _inode_top, "in range");
1927 return _inodes[i].indx;
1928 }
1929 void set_node(Node *n) {
1930 _inode_top->node = n;
|
1616 bool has_next() { return i < imax; }
1617 void next() { i++; }
1618 Node* get() { return node->fast_out(i); }
1619 };
1620
1621
1622 //-----------------------------------------------------------------------------
1623 // Map dense integer indices to Nodes. Uses classic doubling-array trick.
1624 // Abstractly provides an infinite array of Node*'s, initialized to null.
1625 // Note that the constructor just zeros things, and since I use Arena
1626 // allocation I do not need a destructor to reclaim storage.
1627 class Node_Array : public AnyObj {
1628 protected:
1629 Arena* _a; // Arena to allocate in
1630 uint _max;
1631 Node** _nodes;
1632 ReallocMark _nesting; // Safety checks for arena reallocation
1633
1634 // Grow array to required capacity
1635 void maybe_grow(uint i) {
1636 _nesting.check(_a); // Check if a potential reallocation in the arena is safe
1637 if (i >= _max) {
1638 grow(i);
1639 }
1640 }
1641 void grow(uint i);
1642
1643 public:
1644 Node_Array(Arena* a, uint max = OptoNodeListSize) : _a(a), _max(max) {
1645 _nodes = NEW_ARENA_ARRAY(a, Node*, max);
1646 clear();
1647 }
1648 Node_Array() : Node_Array(Thread::current()->resource_area()) {}
1649
1650 NONCOPYABLE(Node_Array);
1651 Node_Array& operator=(Node_Array&&) = delete;
1652 // Allow move constructor for && (eg. capture return of function)
1653 Node_Array(Node_Array&&) = default;
1654
1655 Node *operator[] ( uint i ) const // Lookup, or null for not mapped
1656 { return (i<_max) ? _nodes[i] : (Node*)nullptr; }
1868 _igvn_worklist->push(n);
1869 }
1870
1871 // Inline definition of Compile::remove_for_igvn must be deferred to this point.
1872 inline void Compile::remove_for_igvn(Node* n) {
1873 _igvn_worklist->remove(n);
1874 }
1875
1876 //------------------------------Node_Stack-------------------------------------
1877 class Node_Stack {
1878 protected:
1879 struct INode {
1880 Node *node; // Processed node
1881 uint indx; // Index of next node's child
1882 };
1883 INode *_inode_top; // tos, stack grows up
1884 INode *_inode_max; // End of _inodes == _inodes + _max
1885 INode *_inodes; // Array storage for the stack
1886 Arena *_a; // Arena to allocate in
1887 ReallocMark _nesting; // Safety checks for arena reallocation
1888
1889 void maybe_grow() {
1890 _nesting.check(_a); // Check if a potential reallocation in the arena is safe
1891 if (_inode_top >= _inode_max) {
1892 grow();
1893 }
1894 }
1895 void grow();
1896
1897 public:
1898 Node_Stack(int size) {
1899 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1900 _a = Thread::current()->resource_area();
1901 _inodes = NEW_ARENA_ARRAY( _a, INode, max );
1902 _inode_max = _inodes + max;
1903 _inode_top = _inodes - 1; // stack is empty
1904 }
1905
1906 Node_Stack(Arena *a, int size) : _a(a) {
1907 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1908 _inodes = NEW_ARENA_ARRAY( _a, INode, max );
1909 _inode_max = _inodes + max;
1910 _inode_top = _inodes - 1; // stack is empty
1911 }
1912
1913 void pop() {
1914 assert(_inode_top >= _inodes, "node stack underflow");
1915 --_inode_top;
1916 }
1917 void push(Node *n, uint i) {
1918 ++_inode_top;
1919 maybe_grow();
1920 INode *top = _inode_top; // optimization
1921 top->node = n;
1922 top->indx = i;
1923 }
1924 Node *node() const {
1925 return _inode_top->node;
1926 }
1927 Node* node_at(uint i) const {
1928 assert(_inodes + i <= _inode_top, "in range");
1929 return _inodes[i].node;
1930 }
1931 uint index() const {
1932 return _inode_top->indx;
1933 }
1934 uint index_at(uint i) const {
1935 assert(_inodes + i <= _inode_top, "in range");
1936 return _inodes[i].indx;
1937 }
1938 void set_node(Node *n) {
1939 _inode_top->node = n;
|