1 /*
2 * Copyright (c) 2001, 2011, 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 *
28 #include "memory/cardTableModRefBS.hpp"
29 #include "memory/genRemSet.hpp"
30 #include "memory/memRegion.hpp"
31
32 class Space;
33 class OopsInGenClosure;
34
35 // This kind of "GenRemSet" uses a card table both as shared data structure
36 // for a mod ref barrier set and for the rem set information.
37
38 class CardTableRS: public GenRemSet {
39 friend class VMStructs;
40 // Below are private classes used in impl.
41 friend class VerifyCTSpaceClosure;
42 friend class ClearNoncleanCardWrapper;
43
44 static jbyte clean_card_val() {
45 return CardTableModRefBS::clean_card;
46 }
47
48 static bool
49 card_is_dirty_wrt_gen_iter(jbyte cv) {
50 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
51 }
52
53 CardTableModRefBSForCTRS* _ct_bs;
54
55 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
56
57 void verify_space(Space* s, HeapWord* gen_start);
58
59 enum ExtendedCardValue {
60 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
61 // These are for parallel collection.
62 // There are three P (parallel) youngergen card values. In general, this
63 // needs to be more than the number of generations (including the perm
64 // gen) that might have younger_refs_do invoked on them separately. So
65 // if we add more gens, we have to add more values.
66 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
67 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
68 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
69 cur_youngergen_and_prev_nonclean_card =
159 v != _cur_youngergen_card_val;
160 }
161
162 static bool youngergen_may_have_been_dirty(jbyte cv) {
163 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
164 }
165
166 };
167
168 class ClearNoncleanCardWrapper: public MemRegionClosure {
169 DirtyCardToOopClosure* _dirty_card_closure;
170 CardTableRS* _ct;
171 bool _is_par;
172 private:
173 // Clears the given card, return true if the corresponding card should be
174 // processed.
175 inline bool clear_card(jbyte* entry);
176 // Work methods called by the clear_card()
177 inline bool clear_card_serial(jbyte* entry);
178 inline bool clear_card_parallel(jbyte* entry);
179
180 public:
181 ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct);
182 void do_MemRegion(MemRegion mr);
183 };
184
185 #endif // SHARE_VM_MEMORY_CARDTABLERS_HPP
|
1 /*
2 * Copyright (c) 2001, 2012, 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 *
28 #include "memory/cardTableModRefBS.hpp"
29 #include "memory/genRemSet.hpp"
30 #include "memory/memRegion.hpp"
31
32 class Space;
33 class OopsInGenClosure;
34
35 // This kind of "GenRemSet" uses a card table both as shared data structure
36 // for a mod ref barrier set and for the rem set information.
37
38 class CardTableRS: public GenRemSet {
39 friend class VMStructs;
40 // Below are private classes used in impl.
41 friend class VerifyCTSpaceClosure;
42 friend class ClearNoncleanCardWrapper;
43
44 static jbyte clean_card_val() {
45 return CardTableModRefBS::clean_card;
46 }
47
48 // making this constants into inline methods kills performance for some reason
49 static intptr_t clean_card_row() {
50 return CardTableModRefBS::clean_card_row;
51 }
52
53 static bool card_is_dirty_wrt_gen_iter(jbyte cv) {
54 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
55 }
56
57 CardTableModRefBSForCTRS* _ct_bs;
58
59 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl);
60
61 void verify_space(Space* s, HeapWord* gen_start);
62
63 enum ExtendedCardValue {
64 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
65 // These are for parallel collection.
66 // There are three P (parallel) youngergen card values. In general, this
67 // needs to be more than the number of generations (including the perm
68 // gen) that might have younger_refs_do invoked on them separately. So
69 // if we add more gens, we have to add more values.
70 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
71 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
72 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
73 cur_youngergen_and_prev_nonclean_card =
163 v != _cur_youngergen_card_val;
164 }
165
166 static bool youngergen_may_have_been_dirty(jbyte cv) {
167 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
168 }
169
170 };
171
172 class ClearNoncleanCardWrapper: public MemRegionClosure {
173 DirtyCardToOopClosure* _dirty_card_closure;
174 CardTableRS* _ct;
175 bool _is_par;
176 private:
177 // Clears the given card, return true if the corresponding card should be
178 // processed.
179 inline bool clear_card(jbyte* entry);
180 // Work methods called by the clear_card()
181 inline bool clear_card_serial(jbyte* entry);
182 inline bool clear_card_parallel(jbyte* entry);
183 // check alignment of pointer
184 bool is_word_aligned(jbyte* entry);
185
186 public:
187 ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct);
188 void do_MemRegion(MemRegion mr);
189 };
190
191 #endif // SHARE_VM_MEMORY_CARDTABLERS_HPP
|