author | trims |
Thu, 27 May 2010 19:08:38 -0700 | |
changeset 5547 | f4b087cbb361 |
parent 3590 | a268fa66d7fb |
child 6247 | 00e5cc407d03 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3590
diff
changeset
|
2 |
* Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. |
1374 | 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:
3590
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3590
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:
3590
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
// A G1RemSet provides ways of iterating over pointers into a selected |
|
26 |
// collection set. |
|
27 |
||
28 |
class G1CollectedHeap; |
|
29 |
class CardTableModRefBarrierSet; |
|
30 |
class HRInto_G1RemSet; |
|
31 |
class ConcurrentG1Refine; |
|
32 |
||
2013
49e915da0905
6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents:
1374
diff
changeset
|
33 |
class G1RemSet: public CHeapObj { |
1374 | 34 |
protected: |
35 |
G1CollectedHeap* _g1; |
|
36 |
unsigned _conc_refine_cards; |
|
37 |
size_t n_workers(); |
|
38 |
||
39 |
public: |
|
40 |
G1RemSet(G1CollectedHeap* g1) : |
|
2881 | 41 |
_g1(g1), _conc_refine_cards(0) |
1374 | 42 |
{} |
43 |
||
44 |
// Invoke "blk->do_oop" on all pointers into the CS in object in regions |
|
45 |
// outside the CS (having invoked "blk->set_region" to set the "from" |
|
46 |
// region correctly beforehand.) The "worker_i" param is for the |
|
47 |
// parallel case where the number of the worker thread calling this |
|
48 |
// function can be helpful in partitioning the work to be done. It |
|
49 |
// should be the same as the "i" passed to the calling thread's |
|
50 |
// work(i) function. In the sequential case this param will be ingored. |
|
51 |
virtual void oops_into_collection_set_do(OopsInHeapRegionClosure* blk, |
|
52 |
int worker_i) = 0; |
|
53 |
||
54 |
// Prepare for and cleanup after an oops_into_collection_set_do |
|
55 |
// call. Must call each of these once before and after (in sequential |
|
56 |
// code) any threads call oops into collection set do. (This offers an |
|
57 |
// opportunity to sequential setup and teardown of structures needed by a |
|
58 |
// parallel iteration over the CS's RS.) |
|
59 |
virtual void prepare_for_oops_into_collection_set_do() = 0; |
|
60 |
virtual void cleanup_after_oops_into_collection_set_do() = 0; |
|
61 |
||
62 |
// If "this" is of the given subtype, return "this", else "NULL". |
|
63 |
virtual HRInto_G1RemSet* as_HRInto_G1RemSet() { return NULL; } |
|
64 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
65 |
// Record, if necessary, the fact that *p (where "p" is in region "from", |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
66 |
// and is, a fortiori, required to be non-NULL) has changed to its new value. |
1374 | 67 |
virtual void write_ref(HeapRegion* from, oop* p) = 0; |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
68 |
virtual void write_ref(HeapRegion* from, narrowOop* p) = 0; |
1374 | 69 |
virtual void par_write_ref(HeapRegion* from, oop* p, int tid) = 0; |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
70 |
virtual void par_write_ref(HeapRegion* from, narrowOop* p, int tid) = 0; |
1374 | 71 |
|
72 |
// Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region |
|
73 |
// or card, respectively, such that a region or card with a corresponding |
|
74 |
// 0 bit contains no part of any live object. Eliminates any remembered |
|
75 |
// set entries that correspond to dead heap ranges. |
|
76 |
virtual void scrub(BitMap* region_bm, BitMap* card_bm) = 0; |
|
77 |
// Like the above, but assumes is called in parallel: "worker_num" is the |
|
78 |
// parallel thread id of the current thread, and "claim_val" is the |
|
79 |
// value that should be used to claim heap regions. |
|
80 |
virtual void scrub_par(BitMap* region_bm, BitMap* card_bm, |
|
81 |
int worker_num, int claim_val) = 0; |
|
82 |
||
83 |
// Refine the card corresponding to "card_ptr". If "sts" is non-NULL, |
|
84 |
// join and leave around parts that must be atomic wrt GC. (NULL means |
|
85 |
// being done at a safepoint.) |
|
86 |
virtual void concurrentRefineOneCard(jbyte* card_ptr, int worker_i) {} |
|
87 |
||
88 |
// Print any relevant summary info. |
|
89 |
virtual void print_summary_info() {} |
|
90 |
||
91 |
// Prepare remebered set for verification. |
|
92 |
virtual void prepare_for_verify() {}; |
|
93 |
}; |
|
94 |
||
95 |
||
96 |
// The simplest possible G1RemSet: iterates over all objects in non-CS |
|
97 |
// regions, searching for pointers into the CS. |
|
98 |
class StupidG1RemSet: public G1RemSet { |
|
99 |
public: |
|
100 |
StupidG1RemSet(G1CollectedHeap* g1) : G1RemSet(g1) {} |
|
101 |
||
102 |
void oops_into_collection_set_do(OopsInHeapRegionClosure* blk, |
|
103 |
int worker_i); |
|
104 |
||
105 |
void prepare_for_oops_into_collection_set_do() {} |
|
106 |
void cleanup_after_oops_into_collection_set_do() {} |
|
107 |
||
108 |
// Nothing is necessary in the version below. |
|
109 |
void write_ref(HeapRegion* from, oop* p) {} |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
110 |
void write_ref(HeapRegion* from, narrowOop* p) {} |
1374 | 111 |
void par_write_ref(HeapRegion* from, oop* p, int tid) {} |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
112 |
void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {} |
1374 | 113 |
|
114 |
void scrub(BitMap* region_bm, BitMap* card_bm) {} |
|
115 |
void scrub_par(BitMap* region_bm, BitMap* card_bm, |
|
116 |
int worker_num, int claim_val) {} |
|
117 |
||
118 |
}; |
|
119 |
||
120 |
// A G1RemSet in which each heap region has a rem set that records the |
|
121 |
// external heap references into it. Uses a mod ref bs to track updates, |
|
122 |
// so that they can be used to update the individual region remsets. |
|
123 |
||
124 |
class HRInto_G1RemSet: public G1RemSet { |
|
125 |
protected: |
|
126 |
enum SomePrivateConstants { |
|
127 |
UpdateRStoMergeSync = 0, |
|
128 |
MergeRStoDoDirtySync = 1, |
|
129 |
DoDirtySync = 2, |
|
130 |
LastSync = 3, |
|
131 |
||
132 |
SeqTask = 0, |
|
133 |
NumSeqTasks = 1 |
|
134 |
}; |
|
135 |
||
136 |
CardTableModRefBS* _ct_bs; |
|
137 |
SubTasksDone* _seq_task; |
|
138 |
G1CollectorPolicy* _g1p; |
|
139 |
||
140 |
ConcurrentG1Refine* _cg1r; |
|
141 |
||
142 |
size_t* _cards_scanned; |
|
143 |
size_t _total_cards_scanned; |
|
144 |
||
145 |
// _par_traversal_in_progress is "true" iff a parallel traversal is in |
|
146 |
// progress. If so, then cards added to remembered sets should also have |
|
147 |
// their references into the collection summarized in "_new_refs". |
|
148 |
bool _par_traversal_in_progress; |
|
2881 | 149 |
void set_par_traversal(bool b) { _par_traversal_in_progress = b; } |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
150 |
GrowableArray<OopOrNarrowOopStar>** _new_refs; |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
151 |
template <class T> void new_refs_iterate_work(OopClosure* cl); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
152 |
void new_refs_iterate(OopClosure* cl) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
153 |
if (UseCompressedOops) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
154 |
new_refs_iterate_work<narrowOop>(cl); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
155 |
} else { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
156 |
new_refs_iterate_work<oop>(cl); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
157 |
} |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
158 |
} |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
159 |
|
3590
a268fa66d7fb
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
3262
diff
changeset
|
160 |
// The routine that performs the actual work of refining a dirty |
a268fa66d7fb
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
3262
diff
changeset
|
161 |
// card. |
a268fa66d7fb
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
3262
diff
changeset
|
162 |
void concurrentRefineOneCard_impl(jbyte* card_ptr, int worker_i); |
a268fa66d7fb
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
3262
diff
changeset
|
163 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
164 |
protected: |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
165 |
template <class T> void write_ref_nv(HeapRegion* from, T* p); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
166 |
template <class T> void par_write_ref_nv(HeapRegion* from, T* p, int tid); |
1374 | 167 |
|
168 |
public: |
|
169 |
// This is called to reset dual hash tables after the gc pause |
|
170 |
// is finished and the initial hash table is no longer being |
|
171 |
// scanned. |
|
172 |
void cleanupHRRS(); |
|
173 |
||
174 |
HRInto_G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs); |
|
175 |
~HRInto_G1RemSet(); |
|
176 |
||
177 |
void oops_into_collection_set_do(OopsInHeapRegionClosure* blk, |
|
178 |
int worker_i); |
|
179 |
||
180 |
void prepare_for_oops_into_collection_set_do(); |
|
181 |
void cleanup_after_oops_into_collection_set_do(); |
|
182 |
void scanRS(OopsInHeapRegionClosure* oc, int worker_i); |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
183 |
template <class T> void scanNewRefsRS_work(OopsInHeapRegionClosure* oc, int worker_i); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
184 |
void scanNewRefsRS(OopsInHeapRegionClosure* oc, int worker_i) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
185 |
if (UseCompressedOops) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
186 |
scanNewRefsRS_work<narrowOop>(oc, worker_i); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
187 |
} else { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
188 |
scanNewRefsRS_work<oop>(oc, worker_i); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
189 |
} |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
190 |
} |
1374 | 191 |
void updateRS(int worker_i); |
192 |
HeapRegion* calculateStartRegion(int i); |
|
193 |
||
194 |
HRInto_G1RemSet* as_HRInto_G1RemSet() { return this; } |
|
195 |
||
196 |
CardTableModRefBS* ct_bs() { return _ct_bs; } |
|
197 |
size_t cardsScanned() { return _total_cards_scanned; } |
|
198 |
||
199 |
// Record, if necessary, the fact that *p (where "p" is in region "from", |
|
200 |
// which is required to be non-NULL) has changed to a new non-NULL value. |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
201 |
// [Below the virtual version calls a non-virtual protected |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
202 |
// workhorse that is templatified for narrow vs wide oop.] |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
203 |
inline void write_ref(HeapRegion* from, oop* p) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
204 |
write_ref_nv(from, p); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
205 |
} |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
206 |
inline void write_ref(HeapRegion* from, narrowOop* p) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
207 |
write_ref_nv(from, p); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
208 |
} |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
209 |
inline void par_write_ref(HeapRegion* from, oop* p, int tid) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
210 |
par_write_ref_nv(from, p, tid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
211 |
} |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
212 |
inline void par_write_ref(HeapRegion* from, narrowOop* p, int tid) { |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
213 |
par_write_ref_nv(from, p, tid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
214 |
} |
1374 | 215 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
216 |
bool self_forwarded(oop obj); |
1374 | 217 |
|
218 |
void scrub(BitMap* region_bm, BitMap* card_bm); |
|
219 |
void scrub_par(BitMap* region_bm, BitMap* card_bm, |
|
220 |
int worker_num, int claim_val); |
|
221 |
||
222 |
virtual void concurrentRefineOneCard(jbyte* card_ptr, int worker_i); |
|
223 |
||
224 |
virtual void print_summary_info(); |
|
225 |
virtual void prepare_for_verify(); |
|
226 |
}; |
|
227 |
||
228 |
#define G1_REM_SET_LOGGING 0 |
|
229 |
||
230 |
class CountNonCleanMemRegionClosure: public MemRegionClosure { |
|
231 |
G1CollectedHeap* _g1; |
|
232 |
int _n; |
|
233 |
HeapWord* _start_first; |
|
234 |
public: |
|
235 |
CountNonCleanMemRegionClosure(G1CollectedHeap* g1) : |
|
236 |
_g1(g1), _n(0), _start_first(NULL) |
|
237 |
{} |
|
238 |
void do_MemRegion(MemRegion mr); |
|
239 |
int n() { return _n; }; |
|
240 |
HeapWord* start_first() { return _start_first; } |
|
241 |
}; |
|
2152
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
242 |
|
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
243 |
class UpdateRSOopClosure: public OopClosure { |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
244 |
HeapRegion* _from; |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
245 |
HRInto_G1RemSet* _rs; |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
246 |
int _worker_i; |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
247 |
|
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
248 |
template <class T> void do_oop_work(T* p); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
249 |
|
2152
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
250 |
public: |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
251 |
UpdateRSOopClosure(HRInto_G1RemSet* rs, int worker_i = 0) : |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
252 |
_from(NULL), _rs(rs), _worker_i(worker_i) { |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
253 |
guarantee(_rs != NULL, "Requires an HRIntoG1RemSet"); |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
254 |
} |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
255 |
|
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
256 |
void set_from(HeapRegion* from) { |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
257 |
assert(from != NULL, "from region must be non-NULL"); |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
258 |
_from = from; |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
259 |
} |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
260 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
261 |
virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2881
diff
changeset
|
262 |
virtual void do_oop(oop* p) { do_oop_work(p); } |
2152
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
263 |
|
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
264 |
// Override: this closure is idempotent. |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
265 |
// bool idempotent() { return true; } |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
266 |
bool apply_to_weak_ref_discovered_field() { return true; } |
99356e7f31b1
6760309: G1: update remembered sets during Full GCs
apetrusenko
parents:
2142
diff
changeset
|
267 |
}; |