Mercurial > hg > truffle
annotate src/share/vm/memory/cardTableRS.hpp @ 5334:ecc2b68344de
turn off priority compilation queue
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 02 May 2012 12:59:59 +0200 |
parents | fc2b798ab316 |
children | c7a555a9449a |
rev | line source |
---|---|
0 | 1 /* |
3287
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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 | |
0 | 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 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
53 CardTableModRefBSForCTRS* _ct_bs; |
0 | 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 = | |
70 CardTableModRefBS::CT_MR_BS_last_reserved + 5 | |
71 }; | |
72 | |
73 // An array that contains, for each generation, the card table value last | |
74 // used as the current value for a younger_refs_do iteration of that | |
75 // portion of the table. (The perm gen is index 0; other gens are at | |
76 // their level plus 1. They youngest gen is in the table, but will | |
77 // always have the value "clean_card".) | |
78 jbyte* _last_cur_val_in_gen; | |
79 | |
80 jbyte _cur_youngergen_card_val; | |
81 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
82 int _regions_to_iterate; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
83 |
0 | 84 jbyte cur_youngergen_card_val() { |
85 return _cur_youngergen_card_val; | |
86 } | |
87 void set_cur_youngergen_card_val(jbyte v) { | |
88 _cur_youngergen_card_val = v; | |
89 } | |
90 bool is_prev_youngergen_card_val(jbyte v) { | |
91 return | |
92 youngergen_card <= v && | |
93 v < cur_youngergen_and_prev_nonclean_card && | |
94 v != _cur_youngergen_card_val; | |
95 } | |
96 // Return a youngergen_card_value that is not currently in use. | |
97 jbyte find_unused_youngergenP_card_value(); | |
98 | |
99 public: | |
100 CardTableRS(MemRegion whole_heap, int max_covered_regions); | |
101 | |
102 // *** GenRemSet functions. | |
103 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } | |
104 | |
105 CardTableRS* as_CardTableRS() { return this; } | |
106 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
107 CardTableModRefBS* ct_bs() { return _ct_bs; } |
0 | 108 |
109 // Override. | |
110 void prepare_for_younger_refs_iterate(bool parallel); | |
111 | |
112 // Card table entries are cleared before application; "blk" is | |
113 // responsible for dirtying if the oop is still older-to-younger after | |
114 // closure application. | |
115 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk); | |
116 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
117 void inline_write_ref_field_gc(void* field, oop new_val) { |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
118 jbyte* byte = _ct_bs->byte_for(field); |
0 | 119 *byte = youngergen_card; |
120 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
121 void write_ref_field_gc_work(void* field, oop new_val) { |
0 | 122 inline_write_ref_field_gc(field, new_val); |
123 } | |
124 | |
125 // Override. Might want to devirtualize this in the same fashion as | |
126 // above. Ensures that the value of the card for field says that it's | |
127 // a younger card in the current collection. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
128 virtual void write_ref_field_gc_par(void* field, oop new_val); |
0 | 129 |
130 void resize_covered_region(MemRegion new_region); | |
131 | |
132 bool is_aligned(HeapWord* addr) { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
133 return _ct_bs->is_card_aligned(addr); |
0 | 134 } |
135 | |
136 void verify(); | |
6
73e96e5c30df
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
0
diff
changeset
|
137 void verify_aligned_region_empty(MemRegion mr); |
0 | 138 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
139 void clear(MemRegion mr) { _ct_bs->clear(mr); } |
0 | 140 void clear_into_younger(Generation* gen, bool clear_perm); |
141 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
142 void invalidate(MemRegion mr, bool whole_heap = false) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
143 _ct_bs->invalidate(mr, whole_heap); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
144 } |
0 | 145 void invalidate_or_clear(Generation* gen, bool younger, bool perm); |
146 | |
147 static uintx ct_max_alignment_constraint() { | |
148 return CardTableModRefBS::ct_max_alignment_constraint(); | |
149 } | |
150 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
151 jbyte* byte_for(void* p) { return _ct_bs->byte_for(p); } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
152 jbyte* byte_after(void* p) { return _ct_bs->byte_after(p); } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
153 HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); } |
0 | 154 |
155 bool is_prev_nonclean_card_val(jbyte v) { | |
156 return | |
157 youngergen_card <= v && | |
158 v <= 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 }; | |
1972 | 167 |
3287
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
168 class ClearNoncleanCardWrapper: public MemRegionClosure { |
3357
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
3287
diff
changeset
|
169 DirtyCardToOopClosure* _dirty_card_closure; |
3287
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
170 CardTableRS* _ct; |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
171 bool _is_par; |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
172 private: |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
173 // Clears the given card, return true if the corresponding card should be |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
174 // processed. |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
175 inline bool clear_card(jbyte* entry); |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
176 // Work methods called by the clear_card() |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
177 inline bool clear_card_serial(jbyte* entry); |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
178 inline bool clear_card_parallel(jbyte* entry); |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
179 |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
180 public: |
3357
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
3287
diff
changeset
|
181 ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct); |
3287
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
182 void do_MemRegion(MemRegion mr); |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
183 }; |
c48ad6ab8bdf
7037276: Unnecessary double traversal of dirty card windows
ysr
parents:
1972
diff
changeset
|
184 |
1972 | 185 #endif // SHARE_VM_MEMORY_CARDTABLERS_HPP |