< prev index next >

src/share/vm/gc/g1/heapRegionType.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
  26 #define SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 
  30 #define hrt_assert_is_valid(tag) \
  31   assert(is_valid((tag)), err_msg("invalid HR type: %u", (uint) (tag)))
  32 
  33 class HeapRegionType VALUE_OBJ_CLASS_SPEC {
  34 private:
  35   // We encode the value of the heap region type so the generation can be
  36   // determined quickly. The tag is split into two parts:
  37   //
  38   //   major type (young, old, humongous, archive)           : top N-1 bits
  39   //   minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
  40   //
  41   // If there's need to increase the number of minor types in the
  42   // future, we'll have to increase the size of the latter and hence
  43   // decrease the size of the former.
  44   //
  45   // 0000 0 [ 0] Free
  46   //
  47   // 0001 0 [ 2] Young Mask
  48   // 0001 0 [ 2] Eden
  49   // 0001 1 [ 3] Survivor
  50   //
  51   // 0010 0 [ 4] Humongous Mask


  80 
  81   Tag get() const {
  82     hrt_assert_is_valid(_tag);
  83     return _tag;
  84   }
  85 
  86   // Sets the type to 'tag'.
  87   void set(Tag tag) {
  88     hrt_assert_is_valid(tag);
  89     hrt_assert_is_valid(_tag);
  90     _tag = tag;
  91   }
  92 
  93   // Sets the type to 'tag', expecting the type to be 'before'. This
  94   // is available for when we want to add sanity checking to the type
  95   // transition.
  96   void set_from(Tag tag, Tag before) {
  97     hrt_assert_is_valid(tag);
  98     hrt_assert_is_valid(before);
  99     hrt_assert_is_valid(_tag);
 100     assert(_tag == before,
 101            err_msg("HR tag: %u, expected: %u new tag; %u", _tag, before, tag));
 102     _tag = tag;
 103   }
 104 
 105 public:
 106   // Queries
 107 
 108   bool is_free() const { return get() == FreeTag; }
 109 
 110   bool is_young()    const { return (get() & YoungMask) != 0; }
 111   bool is_eden()     const { return get() == EdenTag;  }
 112   bool is_survivor() const { return get() == SurvTag;  }
 113 
 114   bool is_humongous()           const { return (get() & HumongousMask) != 0;   }
 115   bool is_starts_humongous()    const { return get() == StartsHumongousTag;    }
 116   bool is_continues_humongous() const { return get() == ContinuesHumongousTag; }
 117 
 118   bool is_archive() const { return get() == ArchiveTag; }
 119 
 120   // is_old regions may or may not also be pinned
 121   bool is_old() const { return (get() & OldMask) != 0; }




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
  26 #define SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 
  30 #define hrt_assert_is_valid(tag) \
  31   assert(is_valid((tag)), "invalid HR type: %u", (uint) (tag))
  32 
  33 class HeapRegionType VALUE_OBJ_CLASS_SPEC {
  34 private:
  35   // We encode the value of the heap region type so the generation can be
  36   // determined quickly. The tag is split into two parts:
  37   //
  38   //   major type (young, old, humongous, archive)           : top N-1 bits
  39   //   minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
  40   //
  41   // If there's need to increase the number of minor types in the
  42   // future, we'll have to increase the size of the latter and hence
  43   // decrease the size of the former.
  44   //
  45   // 0000 0 [ 0] Free
  46   //
  47   // 0001 0 [ 2] Young Mask
  48   // 0001 0 [ 2] Eden
  49   // 0001 1 [ 3] Survivor
  50   //
  51   // 0010 0 [ 4] Humongous Mask


  80 
  81   Tag get() const {
  82     hrt_assert_is_valid(_tag);
  83     return _tag;
  84   }
  85 
  86   // Sets the type to 'tag'.
  87   void set(Tag tag) {
  88     hrt_assert_is_valid(tag);
  89     hrt_assert_is_valid(_tag);
  90     _tag = tag;
  91   }
  92 
  93   // Sets the type to 'tag', expecting the type to be 'before'. This
  94   // is available for when we want to add sanity checking to the type
  95   // transition.
  96   void set_from(Tag tag, Tag before) {
  97     hrt_assert_is_valid(tag);
  98     hrt_assert_is_valid(before);
  99     hrt_assert_is_valid(_tag);
 100     assert(_tag == before, "HR tag: %u, expected: %u new tag; %u", _tag, before, tag);

 101     _tag = tag;
 102   }
 103 
 104 public:
 105   // Queries
 106 
 107   bool is_free() const { return get() == FreeTag; }
 108 
 109   bool is_young()    const { return (get() & YoungMask) != 0; }
 110   bool is_eden()     const { return get() == EdenTag;  }
 111   bool is_survivor() const { return get() == SurvTag;  }
 112 
 113   bool is_humongous()           const { return (get() & HumongousMask) != 0;   }
 114   bool is_starts_humongous()    const { return get() == StartsHumongousTag;    }
 115   bool is_continues_humongous() const { return get() == ContinuesHumongousTag; }
 116 
 117   bool is_archive() const { return get() == ArchiveTag; }
 118 
 119   // is_old regions may or may not also be pinned
 120   bool is_old() const { return (get() & OldMask) != 0; }


< prev index next >