Mercurial > hg > graal-compiler
annotate src/share/vm/memory/cardTableRS.hpp @ 2447:e863062e521d
7032458: Zero and Shark fixes
Reviewed-by: twisti
Contributed-by: Gary Benson <gbenson@redhat.com>
author | twisti |
---|---|
date | Mon, 04 Apr 2011 03:02:00 -0700 |
parents | f95d63e2154a |
children | c48ad6ab8bdf |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 2001, 2010, 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 class DirtyCardToOopClosure; | |
35 | |
36 // This kind of "GenRemSet" uses a card table both as shared data structure | |
37 // for a mod ref barrier set and for the rem set information. | |
38 | |
39 class CardTableRS: public GenRemSet { | |
40 friend class VMStructs; | |
41 // Below are private classes used in impl. | |
42 friend class VerifyCTSpaceClosure; | |
43 friend class ClearNoncleanCardWrapper; | |
44 | |
45 static jbyte clean_card_val() { | |
46 return CardTableModRefBS::clean_card; | |
47 } | |
48 | |
49 static bool | |
50 card_is_dirty_wrt_gen_iter(jbyte cv) { | |
51 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv); | |
52 } | |
53 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
54 CardTableModRefBSForCTRS* _ct_bs; |
0 | 55 |
56 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl); | |
57 | |
58 void verify_space(Space* s, HeapWord* gen_start); | |
59 | |
60 enum ExtendedCardValue { | |
61 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1, | |
62 // These are for parallel collection. | |
63 // There are three P (parallel) youngergen card values. In general, this | |
64 // needs to be more than the number of generations (including the perm | |
65 // gen) that might have younger_refs_do invoked on them separately. So | |
66 // if we add more gens, we have to add more values. | |
67 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2, | |
68 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3, | |
69 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4, | |
70 cur_youngergen_and_prev_nonclean_card = | |
71 CardTableModRefBS::CT_MR_BS_last_reserved + 5 | |
72 }; | |
73 | |
74 // An array that contains, for each generation, the card table value last | |
75 // used as the current value for a younger_refs_do iteration of that | |
76 // portion of the table. (The perm gen is index 0; other gens are at | |
77 // their level plus 1. They youngest gen is in the table, but will | |
78 // always have the value "clean_card".) | |
79 jbyte* _last_cur_val_in_gen; | |
80 | |
81 jbyte _cur_youngergen_card_val; | |
82 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
83 int _regions_to_iterate; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
84 |
0 | 85 jbyte cur_youngergen_card_val() { |
86 return _cur_youngergen_card_val; | |
87 } | |
88 void set_cur_youngergen_card_val(jbyte v) { | |
89 _cur_youngergen_card_val = v; | |
90 } | |
91 bool is_prev_youngergen_card_val(jbyte v) { | |
92 return | |
93 youngergen_card <= v && | |
94 v < cur_youngergen_and_prev_nonclean_card && | |
95 v != _cur_youngergen_card_val; | |
96 } | |
97 // Return a youngergen_card_value that is not currently in use. | |
98 jbyte find_unused_youngergenP_card_value(); | |
99 | |
100 public: | |
101 CardTableRS(MemRegion whole_heap, int max_covered_regions); | |
102 | |
103 // *** GenRemSet functions. | |
104 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } | |
105 | |
106 CardTableRS* as_CardTableRS() { return this; } | |
107 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
108 CardTableModRefBS* ct_bs() { return _ct_bs; } |
0 | 109 |
110 // Override. | |
111 void prepare_for_younger_refs_iterate(bool parallel); | |
112 | |
113 // Card table entries are cleared before application; "blk" is | |
114 // responsible for dirtying if the oop is still older-to-younger after | |
115 // closure application. | |
116 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk); | |
117 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
118 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
|
119 jbyte* byte = _ct_bs->byte_for(field); |
0 | 120 *byte = youngergen_card; |
121 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
122 void write_ref_field_gc_work(void* field, oop new_val) { |
0 | 123 inline_write_ref_field_gc(field, new_val); |
124 } | |
125 | |
126 // Override. Might want to devirtualize this in the same fashion as | |
127 // above. Ensures that the value of the card for field says that it's | |
128 // 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
|
129 virtual void write_ref_field_gc_par(void* field, oop new_val); |
0 | 130 |
131 void resize_covered_region(MemRegion new_region); | |
132 | |
133 bool is_aligned(HeapWord* addr) { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
134 return _ct_bs->is_card_aligned(addr); |
0 | 135 } |
136 | |
137 void verify(); | |
6
73e96e5c30df
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
0
diff
changeset
|
138 void verify_aligned_region_empty(MemRegion mr); |
0 | 139 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
140 void clear(MemRegion mr) { _ct_bs->clear(mr); } |
0 | 141 void clear_into_younger(Generation* gen, bool clear_perm); |
142 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
143 void invalidate(MemRegion mr, bool whole_heap = false) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
144 _ct_bs->invalidate(mr, whole_heap); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
145 } |
0 | 146 void invalidate_or_clear(Generation* gen, bool younger, bool perm); |
147 | |
148 static uintx ct_max_alignment_constraint() { | |
149 return CardTableModRefBS::ct_max_alignment_constraint(); | |
150 } | |
151 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
152 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
|
153 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
|
154 HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); } |
0 | 155 |
156 bool is_prev_nonclean_card_val(jbyte v) { | |
157 return | |
158 youngergen_card <= v && | |
159 v <= cur_youngergen_and_prev_nonclean_card && | |
160 v != _cur_youngergen_card_val; | |
161 } | |
162 | |
163 static bool youngergen_may_have_been_dirty(jbyte cv) { | |
164 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card; | |
165 } | |
166 | |
167 }; | |
1972 | 168 |
169 #endif // SHARE_VM_MEMORY_CARDTABLERS_HPP |