< prev index next >

src/hotspot/share/gc/g1/g1HeapRegionAttr.hpp

Print this page
rev 55028 : imported patch 8223693-per-region-type-memory-wastage


  37 #ifdef SPARC
  38   typedef int32_t region_type_t;
  39   typedef uint32_t needs_remset_update_t;
  40 #else
  41   typedef int8_t region_type_t;
  42   typedef uint8_t needs_remset_update_t;
  43 #endif
  44 
  45 private:
  46   needs_remset_update_t _needs_remset_update;
  47   region_type_t _type;
  48 
  49 public:
  50   // Selection of the values for the _type field were driven to micro-optimize the
  51   // encoding and frequency of the checks.
  52   // The most common check for a given reference is whether the region is in the
  53   // collection set or not, and which generation this region is in.
  54   // The selected encoding allows us to use a single check (> NotInCSet) for the
  55   // former.
  56   //
  57   // The other values are used for objects requiring various special cases,
  58   // for example eager reclamation of humongous objects or optional regions.
  59   static const region_type_t Optional     =  -2;    // The region is optional and NOT in the current collection set.
  60   static const region_type_t Humongous    =  -1;    // The region is a humongous candidate not in the current collection set.
  61   static const region_type_t NotInCSet    =   0;    // The region is not in the collection set.
  62   static const region_type_t Young        =   1;    // The region is in the collection set and a young region.
  63   static const region_type_t Old          =   2;    // The region is in the collection set and an old region.
  64   static const region_type_t Num          =   3;
  65 
  66   G1HeapRegionAttr(region_type_t type = NotInCSet, bool needs_remset_update = false) :
  67     _needs_remset_update(needs_remset_update), _type(type) {
  68 
  69     assert(is_valid(), "Invalid type %d", _type);
  70   }
  71 
  72   region_type_t type() const           { return _type; }
  73 
  74   const char* get_type_str() const {
  75     switch (type()) {
  76       case Optional: return "Optional";
  77       case Humongous: return "Humongous";
  78       case NotInCSet: return "NotInCSet";
  79       case Young: return "Young";
  80       case Old: return "Old";
  81       default: ShouldNotReachHere(); return "";
  82     }
  83   }
  84 
  85   bool needs_remset_update() const     { return _needs_remset_update != 0; }
  86 
  87   void set_old()                       { _type = Old; }
  88   void clear_humongous()               {
  89     assert(is_humongous() || !is_in_cset(), "must be");
  90     _type = NotInCSet;
  91   }
  92   void set_has_remset(bool value)      { _needs_remset_update = value ? 1 : 0; }
  93 
  94   bool is_in_cset_or_humongous() const { return is_in_cset() || is_humongous(); }
  95   bool is_in_cset() const              { return type() > NotInCSet; }
  96 
  97   bool is_humongous() const            { return type() == Humongous; }
  98   bool is_young() const                { return type() == Young; }
  99   bool is_old() const                  { return type() == Old; }
 100   bool is_optional() const             { return type() == Optional; }
 101 
 102 #ifdef ASSERT
 103   bool is_default() const              { return type() == NotInCSet; }
 104   bool is_valid() const                { return (type() >= Optional && type() < Num); }
 105   bool is_valid_gen() const            { return (type() >= Young && type() <= Old); }
 106 #endif
 107 };
 108 
 109 // Table for all regions in the heap for above.
 110 //
 111 // We use this to speed up reference processing during young collection and
 112 // quickly reclaim humongous objects. For the latter, at the start of GC, by adding
 113 // it as a humongous region we enable special handling for that region. During the
 114 // reference iteration closures, when we see a humongous region, we then simply mark
 115 // it as referenced, i.e. live, and remove it from this table to prevent further




  37 #ifdef SPARC
  38   typedef int32_t region_type_t;
  39   typedef uint32_t needs_remset_update_t;
  40 #else
  41   typedef int8_t region_type_t;
  42   typedef uint8_t needs_remset_update_t;
  43 #endif
  44 
  45 private:
  46   needs_remset_update_t _needs_remset_update;
  47   region_type_t _type;
  48 
  49 public:
  50   // Selection of the values for the _type field were driven to micro-optimize the
  51   // encoding and frequency of the checks.
  52   // The most common check for a given reference is whether the region is in the
  53   // collection set or not, and which generation this region is in.
  54   // The selected encoding allows us to use a single check (> NotInCSet) for the
  55   // former.
  56   //
  57   // The other values are used for objects in regions requiring various special handling,
  58   // eager reclamation of humongous objects or optional regions.
  59   static const region_type_t Optional     =  -3;    // The region is optional not in the current collection set.
  60   static const region_type_t Humongous    =  -2;    // The region is a humongous candidate not in the current collection set.
  61   static const region_type_t NotInCSet    =  -1;    // The region is not in the collection set.
  62   static const region_type_t Young        =   0;    // The region is in the collection set and a young region.
  63   static const region_type_t Old          =   1;    // The region is in the collection set and an old region.
  64   static const region_type_t Num          =   2;
  65 
  66   G1HeapRegionAttr(region_type_t type = NotInCSet, bool needs_remset_update = false) :
  67     _needs_remset_update(needs_remset_update), _type(type) {
  68 
  69     assert(is_valid(), "Invalid type %d", _type);
  70   }
  71 
  72   region_type_t type() const           { return _type; }
  73 
  74   const char* get_type_str() const {
  75     switch (type()) {
  76       case Optional: return "Optional";
  77       case Humongous: return "Humongous";
  78       case NotInCSet: return "NotInCSet";
  79       case Young: return "Young";
  80       case Old: return "Old";
  81       default: ShouldNotReachHere(); return "";
  82     }
  83   }
  84 
  85   bool needs_remset_update() const     { return _needs_remset_update != 0; }
  86 
  87   void set_old()                       { _type = Old; }
  88   void clear_humongous()               {
  89     assert(is_humongous() || !is_in_cset(), "must be");
  90     _type = NotInCSet;
  91   }
  92   void set_has_remset(bool value)      { _needs_remset_update = value ? 1 : 0; }
  93 
  94   bool is_in_cset_or_humongous() const { return is_in_cset() || is_humongous(); }
  95   bool is_in_cset() const              { return type() >= Young; }
  96 
  97   bool is_humongous() const            { return type() == Humongous; }
  98   bool is_young() const                { return type() == Young; }
  99   bool is_old() const                  { return type() == Old; }
 100   bool is_optional() const             { return type() == Optional; }
 101 
 102 #ifdef ASSERT
 103   bool is_default() const              { return type() == NotInCSet; }
 104   bool is_valid() const                { return (type() >= Optional && type() < Num); }
 105   bool is_valid_gen() const            { return (type() >= Young && type() <= Old); }
 106 #endif
 107 };
 108 
 109 // Table for all regions in the heap for above.
 110 //
 111 // We use this to speed up reference processing during young collection and
 112 // quickly reclaim humongous objects. For the latter, at the start of GC, by adding
 113 // it as a humongous region we enable special handling for that region. During the
 114 // reference iteration closures, when we see a humongous region, we then simply mark
 115 // it as referenced, i.e. live, and remove it from this table to prevent further


< prev index next >