--- old/src/hotspot/share/gc/g1/g1InCSetState.hpp 2018-11-26 21:50:53.008473598 +0100 +++ new/src/hotspot/share/gc/g1/g1InCSetState.hpp 2018-11-26 21:50:52.580471475 +0100 @@ -56,7 +56,8 @@ // makes getting the next generation fast by a simple increment. They are also // used to index into arrays. // The negative values are used for objects requiring various special cases, - // for example eager reclamation of humongous objects. + // for example eager reclamation of humongous objects or optional regions. + Optional = -2, // The region is optional Humongous = -1, // The region is humongous NotInCSet = 0, // The region is not in the collection set. Young = 1, // The region is in the collection set and a young region. @@ -78,10 +79,11 @@ bool is_humongous() const { return _value == Humongous; } bool is_young() const { return _value == Young; } bool is_old() const { return _value == Old; } + bool is_optional() const { return _value == Optional; } #ifdef ASSERT bool is_default() const { return _value == NotInCSet; } - bool is_valid() const { return (_value >= Humongous) && (_value < Num); } + bool is_valid() const { return (_value >= Optional) && (_value < Num); } bool is_valid_gen() const { return (_value >= Young && _value <= Old); } #endif }; @@ -101,6 +103,12 @@ protected: InCSetState default_value() const { return InCSetState::NotInCSet; } public: + void set_optional(uintptr_t index) { + assert(get_by_index(index).is_default(), + "State at index " INTPTR_FORMAT " should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()); + set_by_index(index, InCSetState::Optional); + } + void set_humongous(uintptr_t index) { assert(get_by_index(index).is_default(), "State at index " INTPTR_FORMAT " should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value());