< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.hpp

Print this page

 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
 27 
 28 #include "memory/allocation.hpp"
 29 #include "memory/virtualspace.hpp"
 30 #include "gc/shenandoah/shenandoahHeap.hpp"
 31 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
 32 #include "gc/shenandoah/shenandoahPadding.hpp"
 33 
 34 class ShenandoahCollectionSet : public CHeapObj<mtGC> {
 35   friend class ShenandoahHeap;
 36 private:
 37   size_t const          _map_size;
 38   size_t const          _region_size_bytes_shift;
 39   ReservedSpace         _map_space;
 40   char* const           _cset_map;
 41   // Bias cset map's base address for fast test if an oop is in cset
 42   char* const           _biased_cset_map;
 43 
 44   ShenandoahHeap* const _heap;
 45 

 46   size_t                _garbage;
 47   size_t                _used;
 48   size_t                _region_count;
















 49 
 50   shenandoah_padding(0);
 51   volatile size_t       _current_index;
 52   shenandoah_padding(1);
 53 
 54 public:
 55   ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedSpace space, char* heap_base);
 56 
 57   // Add region to collection set
 58   void add_region(ShenandoahHeapRegion* r);
 59 
 60   // MT version
 61   ShenandoahHeapRegion* claim_next();
 62 
 63   // Single-thread version
 64   ShenandoahHeapRegion* next();
 65 
 66   size_t count()  const { return _region_count; }
 67   bool is_empty() const { return _region_count == 0; }
 68 
 69   void clear_current_index() {
 70     _current_index = 0;
 71   }
 72 
 73   inline bool is_in(ShenandoahHeapRegion* r) const;
 74   inline bool is_in(size_t region_idx)       const;
 75   inline bool is_in(oop obj)                 const;
 76   inline bool is_in_loc(void* loc)           const;
 77 
 78   void print_on(outputStream* out) const;
 79 
 80   size_t used()      const { return _used; }
 81   size_t garbage()   const { return _garbage;   }





























 82   void clear();
 83 
 84 private:
 85   char* map_address() const {
 86     return _cset_map;
 87   }
 88   char* biased_map_address() const {
 89     return _biased_cset_map;
 90   }
 91 };
 92 
 93 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP

 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
 27 
 28 #include "memory/allocation.hpp"
 29 #include "memory/virtualspace.hpp"
 30 #include "gc/shenandoah/shenandoahHeap.hpp"
 31 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
 32 #include "gc/shenandoah/shenandoahPadding.hpp"
 33 
 34 class ShenandoahCollectionSet : public CHeapObj<mtGC> {
 35   friend class ShenandoahHeap;
 36 private:
 37   size_t const          _map_size;
 38   size_t const          _region_size_bytes_shift;
 39   ReservedSpace         _map_space;
 40   char* const           _cset_map;
 41   // Bias cset map's base address for fast test if an oop is in cset
 42   char* const           _biased_cset_map;
 43 
 44   ShenandoahHeap* const _heap;
 45 
 46   bool                  _has_old_regions;
 47   size_t                _garbage;
 48   size_t                _used;
 49   size_t                _region_count;
 50   size_t                _immediate_trash;
 51   size_t                _evacuation_reserve; // How many bytes reserved in generation for evacuation replicas.  This does
 52                                              // not include bytes reserved for old-generation replicas.  The value is
 53                                              // conservative in that memory may be reserved for objects that will be promoted.
 54   size_t                _young_bytes_to_evacuate;
 55   size_t                _young_bytes_to_promote;
 56   size_t                _old_bytes_to_evacuate;
 57 
 58   size_t                _young_region_count;
 59   size_t                _old_region_count;
 60 
 61   size_t                _old_garbage;        // How many bytes of old garbage are present in a mixed collection set?
 62 
 63   bool*                 _preselected_regions;   // Points to array identifying which tenure-age regions have been preselected
 64                                                 // for inclusion in collection set.  This field is only valid during brief
 65                                                 // spans of time while collection set is being constructed.
 66 
 67   shenandoah_padding(0);
 68   volatile size_t       _current_index;
 69   shenandoah_padding(1);
 70 
 71 public:
 72   ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedSpace space, char* heap_base);
 73 
 74   // Add region to collection set
 75   void add_region(ShenandoahHeapRegion* r);
 76 
 77   // MT version
 78   ShenandoahHeapRegion* claim_next();
 79 
 80   // Single-thread version
 81   ShenandoahHeapRegion* next();
 82 
 83   size_t count()  const { return _region_count; }
 84   bool is_empty() const { return _region_count == 0; }
 85 
 86   void clear_current_index() {
 87     _current_index = 0;
 88   }
 89 
 90   inline bool is_in(ShenandoahHeapRegion* r) const;
 91   inline bool is_in(size_t region_idx)       const;
 92   inline bool is_in(oop obj)                 const;
 93   inline bool is_in_loc(void* loc)           const;
 94 
 95   void print_on(outputStream* out) const;
 96 
 97   inline size_t get_immediate_trash();
 98   inline void set_immediate_trash(size_t immediate_trash);
 99 
100   // This represents total amount of work to be performed by evacuation, including evacuations to young, to old,
101   // and promotions from young to old.  This equals get_young_bytes_reserved_for_evacuation() plus
102   // get_old_bytes_reserved_for_evacuation().
103   inline size_t get_bytes_reserved_for_evacuation();
104 
105   // It is not known how many of these bytes will be promoted.
106   inline size_t get_young_bytes_reserved_for_evacuation();
107   inline void reserve_young_bytes_for_evacuation(size_t byte_count);
108 
109   inline size_t get_old_bytes_reserved_for_evacuation();
110   inline void reserve_old_bytes_for_evacuation(size_t byte_count);
111 
112   inline size_t get_young_bytes_to_be_promoted();
113 
114   inline size_t get_old_region_count();
115 
116   inline size_t get_young_region_count();
117 
118   inline size_t get_old_garbage();
119 
120   void establish_preselected(bool *preselected) { _preselected_regions = preselected; }
121   void abandon_preselected() { _preselected_regions = nullptr; }
122   bool is_preselected(size_t region_idx) { return (_preselected_regions != nullptr) && _preselected_regions[region_idx]; }
123 
124   bool has_old_regions() const { return _has_old_regions; }
125   size_t used()          const { return _used; }
126 
127   size_t garbage()       const { return _garbage; }
128   void clear();
129 
130 private:
131   char* map_address() const {
132     return _cset_map;
133   }
134   char* biased_map_address() const {
135     return _biased_cset_map;
136   }
137 };
138 
139 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP
< prev index next >