1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_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, humongous) : 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 //
114
115 void set_free() { set(FreeTag); }
116
117 void set_eden() { set_from(EdenTag, FreeTag); }
118 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
119 void set_survivor() { set_from(SurvTag, FreeTag); }
120
121 void set_starts_humongous() { set_from(StartsHumongousTag, FreeTag); }
122 void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
123
124 void set_old() { set(OldTag); }
125
126 // Misc
127
128 const char* get_str() const;
129 const char* get_short_str() const;
130
131 HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
132 };
133
134 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP
|
1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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)), 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, humongous) : 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 //
114
115 void set_free() { set(FreeTag); }
116
117 void set_eden() { set_from(EdenTag, FreeTag); }
118 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
119 void set_survivor() { set_from(SurvTag, FreeTag); }
120
121 void set_starts_humongous() { set_from(StartsHumongousTag, FreeTag); }
122 void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
123
124 void set_old() { set(OldTag); }
125
126 // Misc
127
128 const char* get_str() const;
129 const char* get_short_str() const;
130
131 HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
132 };
133
134 #endif // SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
|