author | coleenp |
Sat, 01 Sep 2012 13:25:18 -0400 | |
changeset 13728 | 882756847a04 |
parent 12118 | 36458db4ccf5 |
child 17026 | 72b2233861f1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
12118
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
2 |
* Copyright (c) 2001, 2012, 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 |
||
7397 | 25 |
#ifndef SHARE_VM_MEMORY_CARDTABLERS_HPP |
26 |
#define SHARE_VM_MEMORY_CARDTABLERS_HPP |
|
27 |
||
28 |
#include "memory/cardTableModRefBS.hpp" |
|
29 |
#include "memory/genRemSet.hpp" |
|
30 |
#include "memory/memRegion.hpp" |
|
31 |
||
1 | 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 |
||
12118
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
48 |
static intptr_t clean_card_row() { |
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
49 |
return CardTableModRefBS::clean_card_row; |
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
50 |
} |
36458db4ccf5
7068625: Testing 8 bytes of card table entries at a time speeds up card-scanning
brutisso
parents:
9624
diff
changeset
|
51 |
|
1 | 52 |
static bool |
53 |
card_is_dirty_wrt_gen_iter(jbyte cv) { |
|
54 |
return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv); |
|
55 |
} |
|
56 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
57 |
CardTableModRefBSForCTRS* _ct_bs; |
1 | 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 = |
|
74 |
CardTableModRefBS::CT_MR_BS_last_reserved + 5 |
|
75 |
}; |
|
76 |
||
77 |
// An array that contains, for each generation, the card table value last |
|
78 |
// used as the current value for a younger_refs_do iteration of that |
|
79 |
// portion of the table. (The perm gen is index 0; other gens are at |
|
80 |
// their level plus 1. They youngest gen is in the table, but will |
|
81 |
// always have the value "clean_card".) |
|
82 |
jbyte* _last_cur_val_in_gen; |
|
83 |
||
84 |
jbyte _cur_youngergen_card_val; |
|
85 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
86 |
int _regions_to_iterate; |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
87 |
|
1 | 88 |
jbyte cur_youngergen_card_val() { |
89 |
return _cur_youngergen_card_val; |
|
90 |
} |
|
91 |
void set_cur_youngergen_card_val(jbyte v) { |
|
92 |
_cur_youngergen_card_val = v; |
|
93 |
} |
|
94 |
bool is_prev_youngergen_card_val(jbyte v) { |
|
95 |
return |
|
96 |
youngergen_card <= v && |
|
97 |
v < cur_youngergen_and_prev_nonclean_card && |
|
98 |
v != _cur_youngergen_card_val; |
|
99 |
} |
|
100 |
// Return a youngergen_card_value that is not currently in use. |
|
101 |
jbyte find_unused_youngergenP_card_value(); |
|
102 |
||
103 |
public: |
|
104 |
CardTableRS(MemRegion whole_heap, int max_covered_regions); |
|
105 |
||
106 |
// *** GenRemSet functions. |
|
107 |
GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } |
|
108 |
||
109 |
CardTableRS* as_CardTableRS() { return this; } |
|
110 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
111 |
CardTableModRefBS* ct_bs() { return _ct_bs; } |
1 | 112 |
|
113 |
// Override. |
|
114 |
void prepare_for_younger_refs_iterate(bool parallel); |
|
115 |
||
116 |
// Card table entries are cleared before application; "blk" is |
|
117 |
// responsible for dirtying if the oop is still older-to-younger after |
|
118 |
// closure application. |
|
119 |
void younger_refs_iterate(Generation* g, OopsInGenClosure* blk); |
|
120 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
179
diff
changeset
|
121 |
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
|
122 |
jbyte* byte = _ct_bs->byte_for(field); |
1 | 123 |
*byte = youngergen_card; |
124 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
179
diff
changeset
|
125 |
void write_ref_field_gc_work(void* field, oop new_val) { |
1 | 126 |
inline_write_ref_field_gc(field, new_val); |
127 |
} |
|
128 |
||
129 |
// Override. Might want to devirtualize this in the same fashion as |
|
130 |
// above. Ensures that the value of the card for field says that it's |
|
131 |
// 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
|
132 |
virtual void write_ref_field_gc_par(void* field, oop new_val); |
1 | 133 |
|
134 |
void resize_covered_region(MemRegion new_region); |
|
135 |
||
136 |
bool is_aligned(HeapWord* addr) { |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
137 |
return _ct_bs->is_card_aligned(addr); |
1 | 138 |
} |
139 |
||
140 |
void verify(); |
|
179
59e3abf83f72
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
1
diff
changeset
|
141 |
void verify_aligned_region_empty(MemRegion mr); |
1 | 142 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
143 |
void clear(MemRegion mr) { _ct_bs->clear(mr); } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12118
diff
changeset
|
144 |
void clear_into_younger(Generation* gen); |
1 | 145 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
146 |
void invalidate(MemRegion mr, bool whole_heap = false) { |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
147 |
_ct_bs->invalidate(mr, whole_heap); |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
148 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12118
diff
changeset
|
149 |
void invalidate_or_clear(Generation* gen, bool younger); |
1 | 150 |
|
151 |
static uintx ct_max_alignment_constraint() { |
|
152 |
return CardTableModRefBS::ct_max_alignment_constraint(); |
|
153 |
} |
|
154 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); } |
1 | 158 |
|
159 |
bool is_prev_nonclean_card_val(jbyte v) { |
|
160 |
return |
|
161 |
youngergen_card <= v && |
|
162 |
v <= 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 |
}; |
|
7397 | 171 |
|
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
172 |
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
|
173 |
DirtyCardToOopClosure* _dirty_card_closure; |
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
174 |
CardTableRS* _ct; |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
175 |
bool _is_par; |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
176 |
private: |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
177 |
// 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
|
178 |
// processed. |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
179 |
inline bool clear_card(jbyte* entry); |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
180 |
// Work methods called by the clear_card() |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
181 |
inline bool clear_card_serial(jbyte* entry); |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
182 |
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
|
183 |
// 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
|
184 |
bool is_word_aligned(jbyte* entry); |
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
185 |
|
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
186 |
public: |
9624
c3657c3324ee
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
9336
diff
changeset
|
187 |
ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct); |
9336
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
188 |
void do_MemRegion(MemRegion mr); |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
189 |
}; |
413920193f83
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
7397
diff
changeset
|
190 |
|
7397 | 191 |
#endif // SHARE_VM_MEMORY_CARDTABLERS_HPP |