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_G1INCSETSTATE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
27
28 #include "gc_implementation/g1/g1BiasedArray.hpp"
29 #include "memory/allocation.hpp"
30
31 // Per-region state during garbage collection.
32 struct InCSetState {
33 public:
34 // We use different types to represent the state value. Particularly SPARC puts
35 // values in structs from "left to right", i.e. MSB to LSB. This results in many
36 // unnecessary shift operations when loading and storing values of this type.
37 // This degrades performance significantly (>10%) on that platform.
38 // Other tested ABIs do not seem to have this problem, and actually tend to
39 // favor smaller types, so we use the smallest usable type there.
40 #ifdef SPARC
41 #define CSETSTATE_FORMAT INTPTR_FORMAT
42 typedef intptr_t in_cset_state_t;
43 #else
44 #define CSETSTATE_FORMAT "%d"
45 typedef int8_t in_cset_state_t;
46 #endif
47 private:
108 }
109
110 void clear_humongous(uintptr_t index) {
111 set_by_index(index, InCSetState::NotInCSet);
112 }
113
114 void set_in_young(uintptr_t index) {
115 assert(get_by_index(index).is_default(),
116 err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
117 set_by_index(index, InCSetState::Young);
118 }
119
120 void set_in_old(uintptr_t index) {
121 assert(get_by_index(index).is_default(),
122 err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
123 set_by_index(index, InCSetState::Old);
124 }
125
126 bool is_in_cset_or_humongous(HeapWord* addr) const { return at(addr).is_in_cset_or_humongous(); }
127 bool is_in_cset(HeapWord* addr) const { return at(addr).is_in_cset(); }
128 InCSetState at(HeapWord* addr) const { return get_by_address(addr); }
129 void clear() { G1BiasedMappedArray<InCSetState>::clear(); }
130 };
131
132 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_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_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
27
28 #include "gc_implementation/g1/heapRegion.hpp"
29 #include "gc_implementation/g1/g1BiasedArray.hpp"
30 #include "memory/allocation.hpp"
31
32 // Per-region state during garbage collection.
33 struct InCSetState {
34 public:
35 // We use different types to represent the state value. Particularly SPARC puts
36 // values in structs from "left to right", i.e. MSB to LSB. This results in many
37 // unnecessary shift operations when loading and storing values of this type.
38 // This degrades performance significantly (>10%) on that platform.
39 // Other tested ABIs do not seem to have this problem, and actually tend to
40 // favor smaller types, so we use the smallest usable type there.
41 #ifdef SPARC
42 #define CSETSTATE_FORMAT INTPTR_FORMAT
43 typedef intptr_t in_cset_state_t;
44 #else
45 #define CSETSTATE_FORMAT "%d"
46 typedef int8_t in_cset_state_t;
47 #endif
48 private:
109 }
110
111 void clear_humongous(uintptr_t index) {
112 set_by_index(index, InCSetState::NotInCSet);
113 }
114
115 void set_in_young(uintptr_t index) {
116 assert(get_by_index(index).is_default(),
117 err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
118 set_by_index(index, InCSetState::Young);
119 }
120
121 void set_in_old(uintptr_t index) {
122 assert(get_by_index(index).is_default(),
123 err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
124 set_by_index(index, InCSetState::Old);
125 }
126
127 bool is_in_cset_or_humongous(HeapWord* addr) const { return at(addr).is_in_cset_or_humongous(); }
128 bool is_in_cset(HeapWord* addr) const { return at(addr).is_in_cset(); }
129 bool is_in_cset(const HeapRegion* hr) const { return get_by_index(hr->hrm_index()).is_in_cset(); }
130 InCSetState at(HeapWord* addr) const { return get_by_address(addr); }
131 void clear() { G1BiasedMappedArray<InCSetState>::clear(); }
132 void clear(const HeapRegion* hr) { return set_by_index(hr->hrm_index(), InCSetState::NotInCSet); }
133 };
134
135 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
|