src/hotspot/share/gc/g1/g1Allocator.hpp
changeset 59060 fce1fa1bdc91
parent 54843 25c329958c70
child 59061 df6f2350edfa
equal deleted inserted replaced
59059:27a266d5fb13 59060:fce1fa1bdc91
    29 #include "gc/g1/g1HeapRegionAttr.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 class G1NUMA;
    34 
    35 
    35 // Interface to keep track of which regions G1 is currently allocating into. Provides
    36 // Interface to keep track of which regions G1 is currently allocating into. Provides
    36 // some accessors (e.g. allocating into them, or getting their occupancy).
    37 // some accessors (e.g. allocating into them, or getting their occupancy).
    37 // Also keeps track of retained regions across GCs.
    38 // Also keeps track of retained regions across GCs.
    38 class G1Allocator : public CHeapObj<mtGC> {
    39 class G1Allocator : public CHeapObj<mtGC> {
    39   friend class VMStructs;
    40   friend class VMStructs;
    40 
    41 
    41 private:
    42 private:
    42   G1CollectedHeap* _g1h;
    43   G1CollectedHeap* _g1h;
       
    44   G1NUMA* _numa;
    43 
    45 
    44   bool _survivor_is_full;
    46   bool _survivor_is_full;
    45   bool _old_is_full;
    47   bool _old_is_full;
    46 
    48 
       
    49   // The number of MutatorAllocRegions used, one per memory node.
       
    50   size_t _num_alloc_regions;
       
    51 
    47   // Alloc region used to satisfy mutator allocation requests.
    52   // Alloc region used to satisfy mutator allocation requests.
    48   MutatorAllocRegion _mutator_alloc_region;
    53   MutatorAllocRegion* _mutator_alloc_regions;
    49 
    54 
    50   // Alloc region used to satisfy allocation requests by the GC for
    55   // Alloc region used to satisfy allocation requests by the GC for
    51   // survivor objects.
    56   // survivor objects.
    52   SurvivorGCAllocRegion _survivor_gc_alloc_region;
    57   SurvivorGCAllocRegion _survivor_gc_alloc_region;
    53 
    58 
    66   void reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
    71   void reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
    67                                  OldGCAllocRegion* old,
    72                                  OldGCAllocRegion* old,
    68                                  HeapRegion** retained);
    73                                  HeapRegion** retained);
    69 
    74 
    70   // Accessors to the allocation regions.
    75   // Accessors to the allocation regions.
    71   inline MutatorAllocRegion* mutator_alloc_region();
    76   inline MutatorAllocRegion* mutator_alloc_region(uint node_index);
    72   inline SurvivorGCAllocRegion* survivor_gc_alloc_region();
    77   inline SurvivorGCAllocRegion* survivor_gc_alloc_region();
    73   inline OldGCAllocRegion* old_gc_alloc_region();
    78   inline OldGCAllocRegion* old_gc_alloc_region();
    74 
    79 
    75   // Allocation attempt during GC for a survivor object / PLAB.
    80   // Allocation attempt during GC for a survivor object / PLAB.
    76   HeapWord* survivor_attempt_allocation(size_t min_word_size,
    81   HeapWord* survivor_attempt_allocation(size_t min_word_size,
    77                                                size_t desired_word_size,
    82                                         size_t desired_word_size,
    78                                                size_t* actual_word_size);
    83                                         size_t* actual_word_size);
    79 
    84 
    80   // Allocation attempt during GC for an old object / PLAB.
    85   // Allocation attempt during GC for an old object / PLAB.
    81   HeapWord* old_attempt_allocation(size_t min_word_size,
    86   HeapWord* old_attempt_allocation(size_t min_word_size,
    82                                           size_t desired_word_size,
    87                                    size_t desired_word_size,
    83                                           size_t* actual_word_size);
    88                                    size_t* actual_word_size);
       
    89 
       
    90   // Node index of current thread.
       
    91   inline uint current_node_index() const;
       
    92 
    84 public:
    93 public:
    85   G1Allocator(G1CollectedHeap* heap);
    94   G1Allocator(G1CollectedHeap* heap);
       
    95   ~G1Allocator();
    86 
    96 
    87 #ifdef ASSERT
    97 #ifdef ASSERT
    88   // Do we currently have an active mutator region to allocate into?
    98   // Do we currently have an active mutator region to allocate into?
    89   bool has_mutator_alloc_region() { return mutator_alloc_region()->get() != NULL; }
    99   bool has_mutator_alloc_region();
    90 #endif
   100 #endif
    91 
   101 
    92   void init_mutator_alloc_region();
   102   void init_mutator_alloc_regions();
    93   void release_mutator_alloc_region();
   103   void release_mutator_alloc_regions();
    94 
   104 
    95   void init_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
   105   void init_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
    96   void release_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
   106   void release_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
    97   void abandon_gc_alloc_regions();
   107   void abandon_gc_alloc_regions();
    98   bool is_retained_old_region(HeapRegion* hr);
   108   bool is_retained_old_region(HeapRegion* hr);