hotspot/src/share/vm/gc/g1/g1InCSetState.hpp
changeset 35051 002d874a4284
parent 33228 9a491d1be90f
equal deleted inserted replaced
35048:af47b7963810 35051:002d874a4284
    51   enum {
    51   enum {
    52     // Selection of the values were driven to micro-optimize the encoding and
    52     // Selection of the values were driven to micro-optimize the encoding and
    53     // frequency of the checks.
    53     // frequency of the checks.
    54     // The most common check is whether the region is in the collection set or not,
    54     // The most common check is whether the region is in the collection set or not,
    55     // this encoding allows us to use an > 0 check.
    55     // this encoding allows us to use an > 0 check.
    56     // The other values are simply encoded in increasing generation order, which
    56     // The positive values are encoded in increasing generation order, which
    57     // makes getting the next generation fast by a simple increment.
    57     // makes getting the next generation fast by a simple increment. They are also
       
    58     // used to index into arrays.
       
    59     // The negative values are used for objects requiring various special cases,
       
    60     // for example eager reclamation of humongous objects.
       
    61     Ext          = -2,    // Extension point
    58     Humongous    = -1,    // The region is humongous
    62     Humongous    = -1,    // The region is humongous
    59     NotInCSet    =  0,    // The region is not in the collection set.
    63     NotInCSet    =  0,    // The region is not in the collection set.
    60     Young        =  1,    // The region is in the collection set and a young region.
    64     Young        =  1,    // The region is in the collection set and a young region.
    61     Old          =  2,    // The region is in the collection set and an old region.
    65     Old          =  2,    // The region is in the collection set and an old region.
    62     Num
    66     Num
    74   bool is_in_cset() const              { return _value > NotInCSet; }
    78   bool is_in_cset() const              { return _value > NotInCSet; }
    75 
    79 
    76   bool is_humongous() const            { return _value == Humongous; }
    80   bool is_humongous() const            { return _value == Humongous; }
    77   bool is_young() const                { return _value == Young; }
    81   bool is_young() const                { return _value == Young; }
    78   bool is_old() const                  { return _value == Old; }
    82   bool is_old() const                  { return _value == Old; }
       
    83   bool is_ext() const                  { return _value == Ext; }
    79 
    84 
    80 #ifdef ASSERT
    85 #ifdef ASSERT
    81   bool is_default() const              { return !is_in_cset_or_humongous(); }
    86   bool is_default() const              { return _value == NotInCSet; }
    82   bool is_valid() const                { return (_value >= Humongous) && (_value < Num); }
    87   bool is_valid() const                { return (_value >= Ext) && (_value < Num); }
    83   bool is_valid_gen() const            { return (_value >= Young && _value <= Old); }
    88   bool is_valid_gen() const            { return (_value >= Young && _value <= Old); }
    84 #endif
    89 #endif
    85 };
    90 };
    86 
    91 
    87 // Instances of this class are used for quick tests on whether a reference points
    92 // Instances of this class are used for quick tests on whether a reference points
   101  public:
   106  public:
   102   void set_humongous(uintptr_t index) {
   107   void set_humongous(uintptr_t index) {
   103     assert(get_by_index(index).is_default(),
   108     assert(get_by_index(index).is_default(),
   104            "State at index " INTPTR_FORMAT " should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value());
   109            "State at index " INTPTR_FORMAT " should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value());
   105     set_by_index(index, InCSetState::Humongous);
   110     set_by_index(index, InCSetState::Humongous);
       
   111   }
       
   112 
       
   113   void set_ext(uintptr_t index) {
       
   114     assert(get_by_index(index).is_default(),
       
   115            "State at index " INTPTR_FORMAT " should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value());
       
   116     set_by_index(index, InCSetState::Ext);
   106   }
   117   }
   107 
   118 
   108   void clear_humongous(uintptr_t index) {
   119   void clear_humongous(uintptr_t index) {
   109     set_by_index(index, InCSetState::NotInCSet);
   120     set_by_index(index, InCSetState::NotInCSet);
   110   }
   121   }