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

Thu, 23 Oct 2014 12:02:08 -0700

author
asaha
date
Thu, 23 Oct 2014 12:02:08 -0700
changeset 7476
c2844108a708
parent 7195
c02ec279b062
child 9861
a248d0be1309
permissions
-rw-r--r--

Merge

brutisso@7195 1 /*
brutisso@7195 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
brutisso@7195 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
brutisso@7195 4 *
brutisso@7195 5 * This code is free software; you can redistribute it and/or modify it
brutisso@7195 6 * under the terms of the GNU General Public License version 2 only, as
brutisso@7195 7 * published by the Free Software Foundation.
brutisso@7195 8 *
brutisso@7195 9 * This code is distributed in the hope that it will be useful, but WITHOUT
brutisso@7195 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
brutisso@7195 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
brutisso@7195 12 * version 2 for more details (a copy is included in the LICENSE file that
brutisso@7195 13 * accompanied this code).
brutisso@7195 14 *
brutisso@7195 15 * You should have received a copy of the GNU General Public License version
brutisso@7195 16 * 2 along with this work; if not, write to the Free Software Foundation,
brutisso@7195 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
brutisso@7195 18 *
brutisso@7195 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
brutisso@7195 20 * or visit www.oracle.com if you need additional information or have any
brutisso@7195 21 * questions.
brutisso@7195 22 *
brutisso@7195 23 */
brutisso@7195 24
brutisso@7195 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP
brutisso@7195 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP
brutisso@7195 27
brutisso@7195 28 #include "memory/allocation.hpp"
brutisso@7195 29
brutisso@7195 30 #define hrt_assert_is_valid(tag) \
brutisso@7195 31 assert(is_valid((tag)), err_msg("invalid HR type: %u", (uint) (tag)))
brutisso@7195 32
brutisso@7195 33 class HeapRegionType VALUE_OBJ_CLASS_SPEC {
brutisso@7195 34 private:
brutisso@7195 35 // We encode the value of the heap region type so the generation can be
brutisso@7195 36 // determined quickly. The tag is split into two parts:
brutisso@7195 37 //
brutisso@7195 38 // major type (young, humongous) : top N-1 bits
brutisso@7195 39 // minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
brutisso@7195 40 //
brutisso@7195 41 // If there's need to increase the number of minor types in the
brutisso@7195 42 // future, we'll have to increase the size of the latter and hence
brutisso@7195 43 // decrease the size of the former.
brutisso@7195 44 //
brutisso@7195 45 // 0000 0 [ 0] Free
brutisso@7195 46 //
brutisso@7195 47 // 0001 0 Young Mask
brutisso@7195 48 // 0001 0 [ 2] Eden
brutisso@7195 49 // 0001 1 [ 3] Survivor
brutisso@7195 50 //
brutisso@7195 51 // 0010 0 Humongous Mask
brutisso@7195 52 // 0010 0 [ 4] Humongous Starts
brutisso@7195 53 // 0010 1 [ 5] Humongous Continues
brutisso@7195 54 //
brutisso@7195 55 // 01000 [ 8] Old
brutisso@7195 56 typedef enum {
brutisso@7195 57 FreeTag = 0,
brutisso@7195 58
brutisso@7195 59 YoungMask = 2,
brutisso@7195 60 EdenTag = YoungMask,
brutisso@7195 61 SurvTag = YoungMask + 1,
brutisso@7195 62
brutisso@7195 63 HumMask = 4,
brutisso@7195 64 HumStartsTag = HumMask,
brutisso@7195 65 HumContTag = HumMask + 1,
brutisso@7195 66
brutisso@7195 67 OldTag = 8
brutisso@7195 68 } Tag;
brutisso@7195 69
brutisso@7195 70 volatile Tag _tag;
brutisso@7195 71
brutisso@7195 72 static bool is_valid(Tag tag);
brutisso@7195 73
brutisso@7195 74 Tag get() const {
brutisso@7195 75 hrt_assert_is_valid(_tag);
brutisso@7195 76 return _tag;
brutisso@7195 77 }
brutisso@7195 78
brutisso@7195 79 // Sets the type to 'tag'.
brutisso@7195 80 void set(Tag tag) {
brutisso@7195 81 hrt_assert_is_valid(tag);
brutisso@7195 82 hrt_assert_is_valid(_tag);
brutisso@7195 83 _tag = tag;
brutisso@7195 84 }
brutisso@7195 85
brutisso@7195 86 // Sets the type to 'tag', expecting the type to be 'before'. This
brutisso@7195 87 // is available for when we want to add sanity checking to the type
brutisso@7195 88 // transition.
brutisso@7195 89 void set_from(Tag tag, Tag before) {
brutisso@7195 90 hrt_assert_is_valid(tag);
brutisso@7195 91 hrt_assert_is_valid(before);
brutisso@7195 92 hrt_assert_is_valid(_tag);
brutisso@7195 93 assert(_tag == before,
brutisso@7195 94 err_msg("HR tag: %u, expected: %u new tag; %u", _tag, before, tag));
brutisso@7195 95 _tag = tag;
brutisso@7195 96 }
brutisso@7195 97
brutisso@7195 98 public:
brutisso@7195 99 // Queries
brutisso@7195 100
brutisso@7195 101 bool is_free() const { return get() == FreeTag; }
brutisso@7195 102
brutisso@7195 103 bool is_young() const { return (get() & YoungMask) != 0; }
brutisso@7195 104 bool is_eden() const { return get() == EdenTag; }
brutisso@7195 105 bool is_survivor() const { return get() == SurvTag; }
brutisso@7195 106
brutisso@7195 107 bool is_humongous() const { return (get() & HumMask) != 0; }
brutisso@7195 108 bool is_starts_humongous() const { return get() == HumStartsTag; }
brutisso@7195 109 bool is_continues_humongous() const { return get() == HumContTag; }
brutisso@7195 110
brutisso@7195 111 bool is_old() const { return get() == OldTag; }
brutisso@7195 112
brutisso@7195 113 // Setters
brutisso@7195 114
brutisso@7195 115 void set_free() { set(FreeTag); }
brutisso@7195 116
brutisso@7195 117 void set_eden() { set_from(EdenTag, FreeTag); }
brutisso@7195 118 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
brutisso@7195 119 void set_survivor() { set_from(SurvTag, FreeTag); }
brutisso@7195 120
brutisso@7195 121 void set_starts_humongous() { set_from(HumStartsTag, FreeTag); }
brutisso@7195 122 void set_continues_humongous() { set_from(HumContTag, FreeTag); }
brutisso@7195 123
brutisso@7195 124 void set_old() { set(OldTag); }
brutisso@7195 125
brutisso@7195 126 // Misc
brutisso@7195 127
brutisso@7195 128 const char* get_str() const;
brutisso@7195 129 const char* get_short_str() const;
brutisso@7195 130
brutisso@7195 131 HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
brutisso@7195 132 };
brutisso@7195 133
brutisso@7195 134 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP

mercurial