8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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
124
125 // Setters
126
127 void set_free() { set(FreeTag); }
128
129 void set_eden() { set_from(EdenTag, FreeTag); }
130 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
131 void set_survivor() { set_from(SurvTag, FreeTag); }
132
133 void set_starts_humongous() { set_from(StartsHumongousTag, FreeTag); }
134 void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
135
136 void set_old() { set(OldTag); }
137
138 void set_archive() { set_from(ArchiveTag, FreeTag); }
139
140 // Misc
141
142 const char* get_str() const;
143 const char* get_short_str() const;
144
145 HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
146 };
147
148 #endif // SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 "gc/g1/g1HeapRegionTraceType.hpp"
29 #include "memory/allocation.hpp"
30
31 #define hrt_assert_is_valid(tag) \
32 assert(is_valid((tag)), "invalid HR type: %u", (uint) (tag))
33
34 class HeapRegionType VALUE_OBJ_CLASS_SPEC {
35 private:
36 // We encode the value of the heap region type so the generation can be
37 // determined quickly. The tag is split into two parts:
38 //
39 // major type (young, old, humongous, archive) : top N-1 bits
40 // minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
41 //
42 // If there's need to increase the number of minor types in the
43 // future, we'll have to increase the size of the latter and hence
44 // decrease the size of the former.
45 //
46 // 0000 0 [ 0] Free
47 //
48 // 0001 0 [ 2] Young Mask
125
126 // Setters
127
128 void set_free() { set(FreeTag); }
129
130 void set_eden() { set_from(EdenTag, FreeTag); }
131 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
132 void set_survivor() { set_from(SurvTag, FreeTag); }
133
134 void set_starts_humongous() { set_from(StartsHumongousTag, FreeTag); }
135 void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
136
137 void set_old() { set(OldTag); }
138
139 void set_archive() { set_from(ArchiveTag, FreeTag); }
140
141 // Misc
142
143 const char* get_str() const;
144 const char* get_short_str() const;
145 G1HeapRegionTraceType::Type get_trace_type();
146
147 HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
148 };
149
150 #endif // SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
|