hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp
changeset 24103 956dc4aa4615
parent 22904 ed968158d053
child 25905 04a3d83cc752
equal deleted inserted replaced
24102:5e9eb5aa4dc5 24103:956dc4aa4615
    58 
    58 
    59 public:
    59 public:
    60   // Initializes the buffer to be empty, but with the given "word_sz".
    60   // Initializes the buffer to be empty, but with the given "word_sz".
    61   // Must get initialized with "set_buf" for an allocation to succeed.
    61   // Must get initialized with "set_buf" for an allocation to succeed.
    62   ParGCAllocBuffer(size_t word_sz);
    62   ParGCAllocBuffer(size_t word_sz);
       
    63   virtual ~ParGCAllocBuffer() {}
    63 
    64 
    64   static const size_t min_size() {
    65   static const size_t min_size() {
    65     return ThreadLocalAllocBuffer::min_size();
    66     return ThreadLocalAllocBuffer::min_size();
    66   }
    67   }
    67 
    68 
   111   bool contains(void* addr) {
   112   bool contains(void* addr) {
   112     return (void*)_bottom <= addr && addr < (void*)_hard_end;
   113     return (void*)_bottom <= addr && addr < (void*)_hard_end;
   113   }
   114   }
   114 
   115 
   115   // Sets the space of the buffer to be [buf, space+word_sz()).
   116   // Sets the space of the buffer to be [buf, space+word_sz()).
   116   void set_buf(HeapWord* buf) {
   117   virtual void set_buf(HeapWord* buf) {
   117     _bottom   = buf;
   118     _bottom   = buf;
   118     _top      = _bottom;
   119     _top      = _bottom;
   119     _hard_end = _bottom + word_sz();
   120     _hard_end = _bottom + word_sz();
   120     _end      = _hard_end - AlignmentReserve;
   121     _end      = _hard_end - AlignmentReserve;
   121     assert(_end >= _top, "Negative buffer");
   122     assert(_end >= _top, "Negative buffer");
   156   }
   157   }
   157 
   158 
   158   // Fills in the unallocated portion of the buffer with a garbage object.
   159   // Fills in the unallocated portion of the buffer with a garbage object.
   159   // If "end_of_gc" is TRUE, is after the last use in the GC.  IF "retain"
   160   // If "end_of_gc" is TRUE, is after the last use in the GC.  IF "retain"
   160   // is true, attempt to re-use the unused portion in the next GC.
   161   // is true, attempt to re-use the unused portion in the next GC.
   161   void retire(bool end_of_gc, bool retain);
   162   virtual void retire(bool end_of_gc, bool retain);
   162 
   163 
   163   void print() PRODUCT_RETURN;
   164   void print() PRODUCT_RETURN;
   164 };
   165 };
   165 
   166 
   166 // PLAB stats book-keeping
   167 // PLAB stats book-keeping
   236     return res;
   237     return res;
   237   }
   238   }
   238 
   239 
   239   void undo_allocation(HeapWord* obj, size_t word_sz);
   240   void undo_allocation(HeapWord* obj, size_t word_sz);
   240 
   241 
   241   void set_buf(HeapWord* buf_start) {
   242   virtual void set_buf(HeapWord* buf_start) {
   242     ParGCAllocBuffer::set_buf(buf_start);
   243     ParGCAllocBuffer::set_buf(buf_start);
   243     _true_end = _hard_end;
   244     _true_end = _hard_end;
   244     _bt.set_region(MemRegion(buf_start, word_sz()));
   245     _bt.set_region(MemRegion(buf_start, word_sz()));
   245     _bt.initialize_threshold();
   246     _bt.initialize_threshold();
   246   }
   247   }
   247 
   248 
   248   void retire(bool end_of_gc, bool retain);
   249   virtual void retire(bool end_of_gc, bool retain);
   249 
   250 
   250   MemRegion range() {
   251   MemRegion range() {
   251     return MemRegion(_top, _true_end);
   252     return MemRegion(_top, _true_end);
   252   }
   253   }
   253 };
   254 };