< prev index next >

src/share/vm/gc/g1/g1Allocator.hpp

Print this page
rev 8362 : [mq]: hotspot


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP
  27 
  28 #include "gc_implementation/g1/g1AllocationContext.hpp"
  29 #include "gc_implementation/g1/g1AllocRegion.hpp"
  30 #include "gc_implementation/g1/g1InCSetState.hpp"
  31 #include "gc_implementation/shared/plab.hpp"
  32 #include "gc_interface/collectedHeap.hpp"
  33 
  34 class EvacuationInfo;
  35 
  36 // Base class for G1 allocators.
  37 class G1Allocator : public CHeapObj<mtGC> {
  38   friend class VMStructs;
  39 protected:
  40   G1CollectedHeap* _g1h;
  41 
  42   // Outside of GC pauses, the number of bytes used in all regions other
  43   // than the current allocation region.
  44   size_t _summary_bytes_used;
  45 
  46 public:
  47    G1Allocator(G1CollectedHeap* heap) :
  48      _g1h(heap), _summary_bytes_used(0) { }
  49 
  50    static G1Allocator* create_allocator(G1CollectedHeap* g1h);
  51 
  52    virtual void init_mutator_alloc_region() = 0;


 252   G1PLAB  _surviving_alloc_buffer;
 253   G1PLAB  _tenured_alloc_buffer;
 254   G1PLAB* _alloc_buffers[InCSetState::Num];
 255 
 256 public:
 257   G1DefaultParGCAllocator(G1CollectedHeap* g1h);
 258 
 259   virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
 260     assert(dest.is_valid(),
 261            err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()));
 262     assert(_alloc_buffers[dest.value()] != NULL,
 263            err_msg("Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()));
 264     return _alloc_buffers[dest.value()];
 265   }
 266 
 267   virtual void retire_alloc_buffers();
 268 
 269   virtual void waste(size_t& wasted, size_t& undo_wasted);
 270 };
 271 
 272 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1ALLOCATOR_HPP
  26 #define SHARE_VM_GC_G1_G1ALLOCATOR_HPP
  27 
  28 #include "gc/g1/g1AllocRegion.hpp"
  29 #include "gc/g1/g1AllocationContext.hpp"
  30 #include "gc/g1/g1InCSetState.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "gc/shared/plab.hpp"
  33 
  34 class EvacuationInfo;
  35 
  36 // Base class for G1 allocators.
  37 class G1Allocator : public CHeapObj<mtGC> {
  38   friend class VMStructs;
  39 protected:
  40   G1CollectedHeap* _g1h;
  41 
  42   // Outside of GC pauses, the number of bytes used in all regions other
  43   // than the current allocation region.
  44   size_t _summary_bytes_used;
  45 
  46 public:
  47    G1Allocator(G1CollectedHeap* heap) :
  48      _g1h(heap), _summary_bytes_used(0) { }
  49 
  50    static G1Allocator* create_allocator(G1CollectedHeap* g1h);
  51 
  52    virtual void init_mutator_alloc_region() = 0;


 252   G1PLAB  _surviving_alloc_buffer;
 253   G1PLAB  _tenured_alloc_buffer;
 254   G1PLAB* _alloc_buffers[InCSetState::Num];
 255 
 256 public:
 257   G1DefaultParGCAllocator(G1CollectedHeap* g1h);
 258 
 259   virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
 260     assert(dest.is_valid(),
 261            err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()));
 262     assert(_alloc_buffers[dest.value()] != NULL,
 263            err_msg("Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()));
 264     return _alloc_buffers[dest.value()];
 265   }
 266 
 267   virtual void retire_alloc_buffers();
 268 
 269   virtual void waste(size_t& wasted, size_t& undo_wasted);
 270 };
 271 
 272 #endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP
< prev index next >