src/hotspot/share/gc/g1/g1Allocator.hpp
changeset 54843 25c329958c70
parent 53846 fe95464806a7
child 59060 fce1fa1bdc91
equal deleted inserted replaced
54842:f9c8e16db3dd 54843:25c329958c70
    24 
    24 
    25 #ifndef SHARE_GC_G1_G1ALLOCATOR_HPP
    25 #ifndef SHARE_GC_G1_G1ALLOCATOR_HPP
    26 #define SHARE_GC_G1_G1ALLOCATOR_HPP
    26 #define SHARE_GC_G1_G1ALLOCATOR_HPP
    27 
    27 
    28 #include "gc/g1/g1AllocRegion.hpp"
    28 #include "gc/g1/g1AllocRegion.hpp"
    29 #include "gc/g1/g1InCSetState.hpp"
    29 #include "gc/g1/g1HeapRegionAttr.hpp"
    30 #include "gc/shared/collectedHeap.hpp"
    30 #include "gc/shared/collectedHeap.hpp"
    31 #include "gc/shared/plab.hpp"
    31 #include "gc/shared/plab.hpp"
    32 
    32 
    33 class G1EvacuationInfo;
    33 class G1EvacuationInfo;
    34 
    34 
   110 
   110 
   111   // Allocate blocks of memory during garbage collection. Will ensure an
   111   // Allocate blocks of memory during garbage collection. Will ensure an
   112   // allocation region, either by picking one or expanding the
   112   // allocation region, either by picking one or expanding the
   113   // heap, and then allocate a block of the given size. The block
   113   // heap, and then allocate a block of the given size. The block
   114   // may not be a humongous - it must fit into a single heap region.
   114   // may not be a humongous - it must fit into a single heap region.
   115   HeapWord* par_allocate_during_gc(InCSetState dest,
   115   HeapWord* par_allocate_during_gc(G1HeapRegionAttr dest,
   116                                    size_t word_size);
   116                                    size_t word_size);
   117 
   117 
   118   HeapWord* par_allocate_during_gc(InCSetState dest,
   118   HeapWord* par_allocate_during_gc(G1HeapRegionAttr dest,
   119                                    size_t min_word_size,
   119                                    size_t min_word_size,
   120                                    size_t desired_word_size,
   120                                    size_t desired_word_size,
   121                                    size_t* actual_word_size);
   121                                    size_t* actual_word_size);
   122 };
   122 };
   123 
   123 
   130   G1CollectedHeap* _g1h;
   130   G1CollectedHeap* _g1h;
   131   G1Allocator* _allocator;
   131   G1Allocator* _allocator;
   132 
   132 
   133   PLAB  _surviving_alloc_buffer;
   133   PLAB  _surviving_alloc_buffer;
   134   PLAB  _tenured_alloc_buffer;
   134   PLAB  _tenured_alloc_buffer;
   135   PLAB* _alloc_buffers[InCSetState::Num];
   135   PLAB* _alloc_buffers[G1HeapRegionAttr::Num];
   136 
   136 
   137   // The survivor alignment in effect in bytes.
   137   // The survivor alignment in effect in bytes.
   138   // == 0 : don't align survivors
   138   // == 0 : don't align survivors
   139   // != 0 : align survivors to that alignment
   139   // != 0 : align survivors to that alignment
   140   // These values were chosen to favor the non-alignment case since some
   140   // These values were chosen to favor the non-alignment case since some
   141   // architectures have a special compare against zero instructions.
   141   // architectures have a special compare against zero instructions.
   142   const uint _survivor_alignment_bytes;
   142   const uint _survivor_alignment_bytes;
   143 
   143 
   144   // Number of words allocated directly (not counting PLAB allocation).
   144   // Number of words allocated directly (not counting PLAB allocation).
   145   size_t _direct_allocated[InCSetState::Num];
   145   size_t _direct_allocated[G1HeapRegionAttr::Num];
   146 
   146 
   147   void flush_and_retire_stats();
   147   void flush_and_retire_stats();
   148   inline PLAB* alloc_buffer(InCSetState dest);
   148   inline PLAB* alloc_buffer(G1HeapRegionAttr dest);
   149 
   149 
   150   // Calculate the survivor space object alignment in bytes. Returns that or 0 if
   150   // Calculate the survivor space object alignment in bytes. Returns that or 0 if
   151   // there are no restrictions on survivor alignment.
   151   // there are no restrictions on survivor alignment.
   152   static uint calc_survivor_alignment_bytes();
   152   static uint calc_survivor_alignment_bytes();
   153 
   153 
   160 
   160 
   161   // Allocate word_sz words in dest, either directly into the regions or by
   161   // Allocate word_sz words in dest, either directly into the regions or by
   162   // allocating a new PLAB. Returns the address of the allocated memory, NULL if
   162   // allocating a new PLAB. Returns the address of the allocated memory, NULL if
   163   // not successful. Plab_refill_failed indicates whether an attempt to refill the
   163   // not successful. Plab_refill_failed indicates whether an attempt to refill the
   164   // PLAB failed or not.
   164   // PLAB failed or not.
   165   HeapWord* allocate_direct_or_new_plab(InCSetState dest,
   165   HeapWord* allocate_direct_or_new_plab(G1HeapRegionAttr dest,
   166                                         size_t word_sz,
   166                                         size_t word_sz,
   167                                         bool* plab_refill_failed);
   167                                         bool* plab_refill_failed);
   168 
   168 
   169   // Allocate word_sz words in the PLAB of dest.  Returns the address of the
   169   // Allocate word_sz words in the PLAB of dest.  Returns the address of the
   170   // allocated memory, NULL if not successful.
   170   // allocated memory, NULL if not successful.
   171   inline HeapWord* plab_allocate(InCSetState dest,
   171   inline HeapWord* plab_allocate(G1HeapRegionAttr dest,
   172                                  size_t word_sz);
   172                                  size_t word_sz);
   173 
   173 
   174   inline HeapWord* allocate(InCSetState dest,
   174   inline HeapWord* allocate(G1HeapRegionAttr dest,
   175                             size_t word_sz,
   175                             size_t word_sz,
   176                             bool* refill_failed);
   176                             bool* refill_failed);
   177 
   177 
   178   void undo_allocation(InCSetState dest, HeapWord* obj, size_t word_sz);
   178   void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz);
   179 };
   179 };
   180 
   180 
   181 // G1ArchiveRegionMap is a boolean array used to mark G1 regions as
   181 // G1ArchiveRegionMap is a boolean array used to mark G1 regions as
   182 // archive regions.  This allows a quick check for whether an object
   182 // archive regions.  This allows a quick check for whether an object
   183 // should not be marked because it is in an archive region.
   183 // should not be marked because it is in an archive region.