< prev index next >

src/hotspot/share/opto/block.hpp

Print this page

 36 class CFGLoop;
 37 class MachCallNode;
 38 class Matcher;
 39 class RootNode;
 40 class VectorSet;
 41 class PhaseChaitin;
 42 struct Tarjan;
 43 
 44 //------------------------------Block_Array------------------------------------
 45 // Map dense integer indices to Blocks.  Uses classic doubling-array trick.
 46 // Abstractly provides an infinite array of Block*'s, initialized to null.
 47 // Note that the constructor just zeros things, and since I use Arena
 48 // allocation I do not need a destructor to reclaim storage.
 49 class Block_Array : public ArenaObj {
 50   uint _size;                   // allocated size, as opposed to formal limit
 51   DEBUG_ONLY(uint _limit;)      // limit to formal domain
 52   Arena *_arena;                // Arena to allocate in
 53   ReallocMark _nesting;         // Safety checks for arena reallocation
 54 protected:
 55   Block **_blocks;
 56   void grow( uint i );          // Grow array node to fit






 57 
 58 public:
 59   Block_Array(Arena *a) : _size(OptoBlockListSize), _arena(a) {
 60     DEBUG_ONLY(_limit=0);
 61     _blocks = NEW_ARENA_ARRAY( a, Block *, OptoBlockListSize );
 62     for( int i = 0; i < OptoBlockListSize; i++ ) {
 63       _blocks[i] = nullptr;
 64     }
 65   }
 66   Block *lookup( uint i ) const // Lookup, or null for not mapped
 67   { return (i<Max()) ? _blocks[i] : (Block*)nullptr; }
 68   Block *operator[] ( uint i ) const // Lookup, or assert for not mapped
 69   { assert( i < Max(), "oob" ); return _blocks[i]; }
 70   // Extend the mapping: index i maps to Block *n.
 71   void map( uint i, Block *n ) { grow(i); _blocks[i] = n; }
 72   uint Max() const { DEBUG_ONLY(return _limit); return _size; }
 73 };
 74 
 75 
 76 class Block_List : public Block_Array {
 77 public:
 78   uint _cnt;
 79   Block_List() : Block_List(Thread::current()->resource_area()) { }
 80   Block_List(Arena* a) : Block_Array(a), _cnt(0) { }
 81 
 82   void push( Block *b ) {  map(_cnt++,b); }
 83   Block *pop() { return _blocks[--_cnt]; }
 84   Block *rpop() { Block *b = _blocks[0]; _blocks[0]=_blocks[--_cnt]; return b;}
 85   void remove( uint i );
 86   void insert( uint i, Block *n );
 87   uint size() const { return _cnt; }
 88   void reset() { _cnt = 0; }
 89   void print();
 90 };
 91 

 36 class CFGLoop;
 37 class MachCallNode;
 38 class Matcher;
 39 class RootNode;
 40 class VectorSet;
 41 class PhaseChaitin;
 42 struct Tarjan;
 43 
 44 //------------------------------Block_Array------------------------------------
 45 // Map dense integer indices to Blocks.  Uses classic doubling-array trick.
 46 // Abstractly provides an infinite array of Block*'s, initialized to null.
 47 // Note that the constructor just zeros things, and since I use Arena
 48 // allocation I do not need a destructor to reclaim storage.
 49 class Block_Array : public ArenaObj {
 50   uint _size;                   // allocated size, as opposed to formal limit
 51   DEBUG_ONLY(uint _limit;)      // limit to formal domain
 52   Arena *_arena;                // Arena to allocate in
 53   ReallocMark _nesting;         // Safety checks for arena reallocation
 54 protected:
 55   Block **_blocks;
 56   void maybe_grow(uint i) {
 57     _nesting.check(_arena);     // Check if a potential reallocation in the arena is safe
 58     if (i >= Max()) {
 59       grow(i);
 60     }
 61   }
 62   void grow(uint i);            // Grow array node to fit
 63 
 64 public:
 65   Block_Array(Arena *a) : _size(OptoBlockListSize), _arena(a) {
 66     DEBUG_ONLY(_limit=0);
 67     _blocks = NEW_ARENA_ARRAY( a, Block *, OptoBlockListSize );
 68     for( int i = 0; i < OptoBlockListSize; i++ ) {
 69       _blocks[i] = nullptr;
 70     }
 71   }
 72   Block *lookup( uint i ) const // Lookup, or null for not mapped
 73   { return (i<Max()) ? _blocks[i] : (Block*)nullptr; }
 74   Block *operator[] ( uint i ) const // Lookup, or assert for not mapped
 75   { assert( i < Max(), "oob" ); return _blocks[i]; }
 76   // Extend the mapping: index i maps to Block *n.
 77   void map( uint i, Block *n ) { maybe_grow(i); _blocks[i] = n; }
 78   uint Max() const { DEBUG_ONLY(return _limit); return _size; }
 79 };
 80 
 81 
 82 class Block_List : public Block_Array {
 83 public:
 84   uint _cnt;
 85   Block_List() : Block_List(Thread::current()->resource_area()) { }
 86   Block_List(Arena* a) : Block_Array(a), _cnt(0) { }
 87 
 88   void push( Block *b ) {  map(_cnt++,b); }
 89   Block *pop() { return _blocks[--_cnt]; }
 90   Block *rpop() { Block *b = _blocks[0]; _blocks[0]=_blocks[--_cnt]; return b;}
 91   void remove( uint i );
 92   void insert( uint i, Block *n );
 93   uint size() const { return _cnt; }
 94   void reset() { _cnt = 0; }
 95   void print();
 96 };
 97 
< prev index next >