Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/cardTableRS.hpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | 73e96e5c30df |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2001-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 class Space; | |
26 class OopsInGenClosure; | |
27 class DirtyCardToOopClosure; | |
28 | |
29 // This kind of "GenRemSet" uses a card table both as shared data structure | |
30 // for a mod ref barrier set and for the rem set information. | |
31 | |
32 class CardTableRS: public GenRemSet { | |
33 friend class VMStructs; | |
34 // Below are private classes used in impl. | |
35 friend class VerifyCTSpaceClosure; | |
36 friend class ClearNoncleanCardWrapper; | |
37 | |
38 static jbyte clean_card_val() { | |
39 return CardTableModRefBS::clean_card; | |
40 } | |
41 | |
42 static bool | |
43 card_is_dirty_wrt_gen_iter(jbyte cv) { | |
44 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv); | |
45 } | |
46 | |
47 CardTableModRefBSForCTRS _ct_bs; | |
48 | |
49 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl); | |
50 | |
51 void verify_space(Space* s, HeapWord* gen_start); | |
52 | |
53 enum ExtendedCardValue { | |
54 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1, | |
55 // These are for parallel collection. | |
56 // There are three P (parallel) youngergen card values. In general, this | |
57 // needs to be more than the number of generations (including the perm | |
58 // gen) that might have younger_refs_do invoked on them separately. So | |
59 // if we add more gens, we have to add more values. | |
60 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2, | |
61 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3, | |
62 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4, | |
63 cur_youngergen_and_prev_nonclean_card = | |
64 CardTableModRefBS::CT_MR_BS_last_reserved + 5 | |
65 }; | |
66 | |
67 // An array that contains, for each generation, the card table value last | |
68 // used as the current value for a younger_refs_do iteration of that | |
69 // portion of the table. (The perm gen is index 0; other gens are at | |
70 // their level plus 1. They youngest gen is in the table, but will | |
71 // always have the value "clean_card".) | |
72 jbyte* _last_cur_val_in_gen; | |
73 | |
74 jbyte _cur_youngergen_card_val; | |
75 | |
76 jbyte cur_youngergen_card_val() { | |
77 return _cur_youngergen_card_val; | |
78 } | |
79 void set_cur_youngergen_card_val(jbyte v) { | |
80 _cur_youngergen_card_val = v; | |
81 } | |
82 bool is_prev_youngergen_card_val(jbyte v) { | |
83 return | |
84 youngergen_card <= v && | |
85 v < cur_youngergen_and_prev_nonclean_card && | |
86 v != _cur_youngergen_card_val; | |
87 } | |
88 // Return a youngergen_card_value that is not currently in use. | |
89 jbyte find_unused_youngergenP_card_value(); | |
90 | |
91 public: | |
92 CardTableRS(MemRegion whole_heap, int max_covered_regions); | |
93 | |
94 // *** GenRemSet functions. | |
95 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } | |
96 | |
97 CardTableRS* as_CardTableRS() { return this; } | |
98 | |
99 CardTableModRefBS* ct_bs() { return &_ct_bs; } | |
100 | |
101 // Override. | |
102 void prepare_for_younger_refs_iterate(bool parallel); | |
103 | |
104 // Card table entries are cleared before application; "blk" is | |
105 // responsible for dirtying if the oop is still older-to-younger after | |
106 // closure application. | |
107 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk); | |
108 | |
109 void inline_write_ref_field_gc(oop* field, oop new_val) { | |
110 jbyte* byte = _ct_bs.byte_for(field); | |
111 *byte = youngergen_card; | |
112 } | |
113 void write_ref_field_gc_work(oop* field, oop new_val) { | |
114 inline_write_ref_field_gc(field, new_val); | |
115 } | |
116 | |
117 // Override. Might want to devirtualize this in the same fashion as | |
118 // above. Ensures that the value of the card for field says that it's | |
119 // a younger card in the current collection. | |
120 virtual void write_ref_field_gc_par(oop* field, oop new_val); | |
121 | |
122 void resize_covered_region(MemRegion new_region); | |
123 | |
124 bool is_aligned(HeapWord* addr) { | |
125 return _ct_bs.is_card_aligned(addr); | |
126 } | |
127 | |
128 void verify(); | |
129 void verify_empty(MemRegion mr); | |
130 | |
131 void clear(MemRegion mr) { _ct_bs.clear(mr); } | |
132 void clear_into_younger(Generation* gen, bool clear_perm); | |
133 | |
134 void invalidate(MemRegion mr) { _ct_bs.invalidate(mr); } | |
135 void invalidate_or_clear(Generation* gen, bool younger, bool perm); | |
136 | |
137 static uintx ct_max_alignment_constraint() { | |
138 return CardTableModRefBS::ct_max_alignment_constraint(); | |
139 } | |
140 | |
141 jbyte* byte_for(void* p) { return _ct_bs.byte_for(p); } | |
142 jbyte* byte_after(void* p) { return _ct_bs.byte_after(p); } | |
143 HeapWord* addr_for(jbyte* p) { return _ct_bs.addr_for(p); } | |
144 | |
145 bool is_prev_nonclean_card_val(jbyte v) { | |
146 return | |
147 youngergen_card <= v && | |
148 v <= cur_youngergen_and_prev_nonclean_card && | |
149 v != _cur_youngergen_card_val; | |
150 } | |
151 | |
152 static bool youngergen_may_have_been_dirty(jbyte cv) { | |
153 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card; | |
154 } | |
155 | |
156 }; |