author | eosterlund |
Mon, 20 Nov 2017 13:07:44 +0100 | |
changeset 47998 | fb0275c320a0 |
parent 47580 | 96392e113a0a |
child 49164 | 7e958a8ebcd3 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
47580 | 2 |
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1388
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1388
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1388
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_SHARED_CARDTABLERS_HPP |
26 |
#define SHARE_VM_GC_SHARED_CARDTABLERS_HPP |
|
7397 | 27 |
|
31964 | 28 |
#include "gc/shared/cardTableModRefBSForCTRS.hpp" |
7397 | 29 |
#include "memory/memRegion.hpp" |
30 |
||
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47580
diff
changeset
|
31 |
class Generation; |
1 | 32 |
class Space; |
33 |
class OopsInGenClosure; |
|
34 |
||
47580 | 35 |
// Helper to remember modified oops in all clds. |
36 |
class CLDRemSet { |
|
33212 | 37 |
bool _accumulate_modified_oops; |
38 |
public: |
|
47580 | 39 |
CLDRemSet() : _accumulate_modified_oops(false) {} |
33212 | 40 |
void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; } |
41 |
bool accumulate_modified_oops() { return _accumulate_modified_oops; } |
|
42 |
bool mod_union_is_clear(); |
|
43 |
void clear_mod_union(); |
|
44 |
}; |
|
45 |
||
46 |
// This RemSet uses a card table both as shared data structure |
|
1 | 47 |
// for a mod ref barrier set and for the rem set information. |
48 |
||
33212 | 49 |
class CardTableRS: public CHeapObj<mtGC> { |
1 | 50 |
friend class VMStructs; |
51 |
// Below are private classes used in impl. |
|
52 |
friend class VerifyCTSpaceClosure; |
|
53 |
friend class ClearNoncleanCardWrapper; |
|
54 |
||
55 |
static jbyte clean_card_val() { |
|
31964 | 56 |
return CardTableModRefBSForCTRS::clean_card; |
1 | 57 |
} |
58 |
||
12118
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
59 |
static intptr_t clean_card_row() { |
31964 | 60 |
return CardTableModRefBSForCTRS::clean_card_row; |
12118
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
61 |
} |
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
62 |
|
1 | 63 |
static bool |
64 |
card_is_dirty_wrt_gen_iter(jbyte cv) { |
|
31964 | 65 |
return CardTableModRefBSForCTRS::card_is_dirty_wrt_gen_iter(cv); |
1 | 66 |
} |
67 |
||
47580 | 68 |
CLDRemSet _cld_rem_set; |
33212 | 69 |
BarrierSet* _bs; |
1 | 70 |
|
33212 | 71 |
CardTableModRefBSForCTRS* _ct_bs; |
1 | 72 |
|
73 |
void verify_space(Space* s, HeapWord* gen_start); |
|
74 |
||
75 |
enum ExtendedCardValue { |
|
31964 | 76 |
youngergen_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 1, |
1 | 77 |
// These are for parallel collection. |
78 |
// There are three P (parallel) youngergen card values. In general, this |
|
79 |
// needs to be more than the number of generations (including the perm |
|
80 |
// gen) that might have younger_refs_do invoked on them separately. So |
|
81 |
// if we add more gens, we have to add more values. |
|
31964 | 82 |
youngergenP1_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 2, |
83 |
youngergenP2_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 3, |
|
84 |
youngergenP3_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 4, |
|
1 | 85 |
cur_youngergen_and_prev_nonclean_card = |
31964 | 86 |
CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 5 |
1 | 87 |
}; |
88 |
||
89 |
// An array that contains, for each generation, the card table value last |
|
90 |
// used as the current value for a younger_refs_do iteration of that |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
30870
diff
changeset
|
91 |
// portion of the table. The perm gen is index 0. The young gen is index 1, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
30870
diff
changeset
|
92 |
// but will always have the value "clean_card". The old gen is index 2. |
1 | 93 |
jbyte* _last_cur_val_in_gen; |
94 |
||
95 |
jbyte _cur_youngergen_card_val; |
|
96 |
||
27687
3a6367d7110b
8064721: The card tables only ever need two covering regions
ehelin
parents:
22548
diff
changeset
|
97 |
// Number of generations, plus one for lingering PermGen issues in CardTableRS. |
3a6367d7110b
8064721: The card tables only ever need two covering regions
ehelin
parents:
22548
diff
changeset
|
98 |
static const int _regions_to_iterate = 3; |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
99 |
|
1 | 100 |
jbyte cur_youngergen_card_val() { |
101 |
return _cur_youngergen_card_val; |
|
102 |
} |
|
103 |
void set_cur_youngergen_card_val(jbyte v) { |
|
104 |
_cur_youngergen_card_val = v; |
|
105 |
} |
|
106 |
bool is_prev_youngergen_card_val(jbyte v) { |
|
107 |
return |
|
108 |
youngergen_card <= v && |
|
109 |
v < cur_youngergen_and_prev_nonclean_card && |
|
110 |
v != _cur_youngergen_card_val; |
|
111 |
} |
|
112 |
// Return a youngergen_card_value that is not currently in use. |
|
113 |
jbyte find_unused_youngergenP_card_value(); |
|
114 |
||
115 |
public: |
|
27687
3a6367d7110b
8064721: The card tables only ever need two covering regions
ehelin
parents:
22548
diff
changeset
|
116 |
CardTableRS(MemRegion whole_heap); |
17376
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
17031
diff
changeset
|
117 |
~CardTableRS(); |
1 | 118 |
|
33212 | 119 |
// Return the barrier set associated with "this." |
120 |
BarrierSet* bs() { return _bs; } |
|
121 |
||
122 |
// Set the barrier set. |
|
123 |
void set_bs(BarrierSet* bs) { _bs = bs; } |
|
124 |
||
47580 | 125 |
CLDRemSet* cld_rem_set() { return &_cld_rem_set; } |
1 | 126 |
|
31964 | 127 |
CardTableModRefBSForCTRS* ct_bs() { return _ct_bs; } |
1 | 128 |
|
33212 | 129 |
void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl, uint n_threads); |
130 |
||
1 | 131 |
// Override. |
132 |
void prepare_for_younger_refs_iterate(bool parallel); |
|
133 |
||
134 |
// Card table entries are cleared before application; "blk" is |
|
135 |
// responsible for dirtying if the oop is still older-to-younger after |
|
136 |
// closure application. |
|
30870
3050fdcdc60b
8080112: Replace and remove the last usages of CollectedHeap::n_par_threads()
stefank
parents:
30764
diff
changeset
|
137 |
void younger_refs_iterate(Generation* g, OopsInGenClosure* blk, uint n_threads); |
1 | 138 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
179
diff
changeset
|
139 |
void inline_write_ref_field_gc(void* field, oop new_val) { |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
140 |
jbyte* byte = _ct_bs->byte_for(field); |
1 | 141 |
*byte = youngergen_card; |
142 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
179
diff
changeset
|
143 |
void write_ref_field_gc_work(void* field, oop new_val) { |
1 | 144 |
inline_write_ref_field_gc(field, new_val); |
145 |
} |
|
146 |
||
147 |
// Override. Might want to devirtualize this in the same fashion as |
|
148 |
// above. Ensures that the value of the card for field says that it's |
|
149 |
// a younger card in the current collection. |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
179
diff
changeset
|
150 |
virtual void write_ref_field_gc_par(void* field, oop new_val); |
1 | 151 |
|
152 |
void resize_covered_region(MemRegion new_region); |
|
153 |
||
154 |
bool is_aligned(HeapWord* addr) { |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
155 |
return _ct_bs->is_card_aligned(addr); |
1 | 156 |
} |
157 |
||
158 |
void verify(); |
|
159 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
160 |
void clear(MemRegion mr) { _ct_bs->clear(mr); } |
19289
213031f03f61
8023021: Unnecessary clearing of the card table introduced by the fix for JDK-8023013
brutisso
parents:
19286
diff
changeset
|
161 |
void clear_into_younger(Generation* old_gen); |
1 | 162 |
|
42598
45562c0473fb
8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents:
33212
diff
changeset
|
163 |
void invalidate(MemRegion mr) { |
45562c0473fb
8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents:
33212
diff
changeset
|
164 |
_ct_bs->invalidate(mr); |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
165 |
} |
19289
213031f03f61
8023021: Unnecessary clearing of the card table introduced by the fix for JDK-8023013
brutisso
parents:
19286
diff
changeset
|
166 |
void invalidate_or_clear(Generation* old_gen); |
1 | 167 |
|
168 |
static uintx ct_max_alignment_constraint() { |
|
31964 | 169 |
return CardTableModRefBSForCTRS::ct_max_alignment_constraint(); |
1 | 170 |
} |
171 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
172 |
jbyte* byte_for(void* p) { return _ct_bs->byte_for(p); } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
173 |
jbyte* byte_after(void* p) { return _ct_bs->byte_after(p); } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
174 |
HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); } |
1 | 175 |
|
176 |
bool is_prev_nonclean_card_val(jbyte v) { |
|
177 |
return |
|
178 |
youngergen_card <= v && |
|
179 |
v <= cur_youngergen_and_prev_nonclean_card && |
|
180 |
v != _cur_youngergen_card_val; |
|
181 |
} |
|
182 |
||
183 |
static bool youngergen_may_have_been_dirty(jbyte cv) { |
|
184 |
return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card; |
|
185 |
} |
|
186 |
||
187 |
}; |
|
7397 | 188 |
|
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
189 |
class ClearNoncleanCardWrapper: public MemRegionClosure { |
9624
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
9336
diff
changeset
|
190 |
DirtyCardToOopClosure* _dirty_card_closure; |
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
191 |
CardTableRS* _ct; |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
192 |
bool _is_par; |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
193 |
private: |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
194 |
// Clears the given card, return true if the corresponding card should be |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
195 |
// processed. |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
196 |
inline bool clear_card(jbyte* entry); |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
197 |
// Work methods called by the clear_card() |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
198 |
inline bool clear_card_serial(jbyte* entry); |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
199 |
inline bool clear_card_parallel(jbyte* entry); |
12118
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
200 |
// check alignment of pointer |
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
201 |
bool is_word_aligned(jbyte* entry); |
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
202 |
|
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
203 |
public: |
30870
3050fdcdc60b
8080112: Replace and remove the last usages of CollectedHeap::n_par_threads()
stefank
parents:
30764
diff
changeset
|
204 |
ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par); |
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
205 |
void do_MemRegion(MemRegion mr); |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
206 |
}; |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
207 |
|
30764 | 208 |
#endif // SHARE_VM_GC_SHARED_CARDTABLERS_HPP |