annotate src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents 8b10f48633dc
children c69b1043dfb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
2 * Copyright (c) 2007, 2010 Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 845
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 845
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: 845
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
26 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
27 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
28 #include "memory/cardTableRS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
29 #include "memory/sharedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
30 #include "memory/space.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
31 #include "memory/universe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
32 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
33 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
34 #include "runtime/virtualspace.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 void CardTableModRefBS::par_non_clean_card_iterate_work(Space* sp, MemRegion mr,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 DirtyCardToOopClosure* dcto_cl,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 MemRegionClosure* cl,
a61af66fc99e Initial load
duke
parents:
diff changeset
39 bool clear,
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int n_threads) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 if (n_threads > 0) {
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 0
diff changeset
42 assert((n_threads == 1 && ParallelGCThreads == 0) ||
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 0
diff changeset
43 n_threads <= (int)ParallelGCThreads,
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 0
diff changeset
44 "# worker threads != # requested!");
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 0
diff changeset
45 // Make sure the LNC array is valid for the space.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 jbyte** lowest_non_clean;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 uintptr_t lowest_non_clean_base_chunk_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 size_t lowest_non_clean_chunk_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 get_LNC_array_for_space(sp, lowest_non_clean,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 lowest_non_clean_base_chunk_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
51 lowest_non_clean_chunk_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int n_strides = n_threads * StridesPerThread;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 SequentialSubTasksDone* pst = sp->par_seq_tasks();
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
55 pst->set_n_threads(n_threads);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 pst->set_n_tasks(n_strides);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int stride = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 while (!pst->is_task_claimed(/* reference */ stride)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 process_stride(sp, mr, stride, n_strides, dcto_cl, cl, clear,
a61af66fc99e Initial load
duke
parents:
diff changeset
61 lowest_non_clean,
a61af66fc99e Initial load
duke
parents:
diff changeset
62 lowest_non_clean_base_chunk_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
63 lowest_non_clean_chunk_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if (pst->all_tasks_completed()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Clear lowest_non_clean array for next time.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 intptr_t first_chunk_index = addr_to_chunk_index(mr.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
68 uintptr_t last_chunk_index = addr_to_chunk_index(mr.last());
a61af66fc99e Initial load
duke
parents:
diff changeset
69 for (uintptr_t ch = first_chunk_index; ch <= last_chunk_index; ch++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 intptr_t ind = ch - lowest_non_clean_base_chunk_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(0 <= ind && ind < (intptr_t)lowest_non_clean_chunk_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 "Bounds error");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 lowest_non_clean[ind] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void
a61af66fc99e Initial load
duke
parents:
diff changeset
80 CardTableModRefBS::
a61af66fc99e Initial load
duke
parents:
diff changeset
81 process_stride(Space* sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 MemRegion used,
a61af66fc99e Initial load
duke
parents:
diff changeset
83 jint stride, int n_strides,
a61af66fc99e Initial load
duke
parents:
diff changeset
84 DirtyCardToOopClosure* dcto_cl,
a61af66fc99e Initial load
duke
parents:
diff changeset
85 MemRegionClosure* cl,
a61af66fc99e Initial load
duke
parents:
diff changeset
86 bool clear,
a61af66fc99e Initial load
duke
parents:
diff changeset
87 jbyte** lowest_non_clean,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 uintptr_t lowest_non_clean_base_chunk_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 size_t lowest_non_clean_chunk_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // We don't have to go downwards here; it wouldn't help anyway,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // because of parallelism.
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Find the first card address of the first chunk in the stride that is
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // at least "bottom" of the used region.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 jbyte* start_card = byte_for(used.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
96 jbyte* end_card = byte_after(used.last());
a61af66fc99e Initial load
duke
parents:
diff changeset
97 uintptr_t start_chunk = addr_to_chunk_index(used.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
98 uintptr_t start_chunk_stride_num = start_chunk % n_strides;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 jbyte* chunk_card_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if ((uintptr_t)stride >= start_chunk_stride_num) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 chunk_card_start = (jbyte*)(start_card +
a61af66fc99e Initial load
duke
parents:
diff changeset
103 (stride - start_chunk_stride_num) *
a61af66fc99e Initial load
duke
parents:
diff changeset
104 CardsPerStrideChunk);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Go ahead to the next chunk group boundary, then to the requested stride.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 chunk_card_start = (jbyte*)(start_card +
a61af66fc99e Initial load
duke
parents:
diff changeset
108 (n_strides - start_chunk_stride_num + stride) *
a61af66fc99e Initial load
duke
parents:
diff changeset
109 CardsPerStrideChunk);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 while (chunk_card_start < end_card) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // We don't have to go downwards here; it wouldn't help anyway,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // because of parallelism. (We take care with "min_done"; see below.)
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Invariant: chunk_mr should be fully contained within the "used" region.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 jbyte* chunk_card_end = chunk_card_start + CardsPerStrideChunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 MemRegion chunk_mr = MemRegion(addr_for(chunk_card_start),
a61af66fc99e Initial load
duke
parents:
diff changeset
118 chunk_card_end >= end_card ?
a61af66fc99e Initial load
duke
parents:
diff changeset
119 used.end() : addr_for(chunk_card_end));
a61af66fc99e Initial load
duke
parents:
diff changeset
120 assert(chunk_mr.word_size() > 0, "[chunk_card_start > used_end)");
a61af66fc99e Initial load
duke
parents:
diff changeset
121 assert(used.contains(chunk_mr), "chunk_mr should be subset of used");
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Process the chunk.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 process_chunk_boundaries(sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
125 dcto_cl,
a61af66fc99e Initial load
duke
parents:
diff changeset
126 chunk_mr,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 used,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 lowest_non_clean,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 lowest_non_clean_base_chunk_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 lowest_non_clean_chunk_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 non_clean_card_iterate_work(chunk_mr, cl, clear);
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Find the next chunk of the stride.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 chunk_card_start += CardsPerStrideChunk * n_strides;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void
a61af66fc99e Initial load
duke
parents:
diff changeset
140 CardTableModRefBS::
a61af66fc99e Initial load
duke
parents:
diff changeset
141 process_chunk_boundaries(Space* sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
142 DirtyCardToOopClosure* dcto_cl,
a61af66fc99e Initial load
duke
parents:
diff changeset
143 MemRegion chunk_mr,
a61af66fc99e Initial load
duke
parents:
diff changeset
144 MemRegion used,
a61af66fc99e Initial load
duke
parents:
diff changeset
145 jbyte** lowest_non_clean,
a61af66fc99e Initial load
duke
parents:
diff changeset
146 uintptr_t lowest_non_clean_base_chunk_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
147 size_t lowest_non_clean_chunk_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
148 {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // We must worry about the chunk boundaries.
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // First, set our max_to_do:
a61af66fc99e Initial load
duke
parents:
diff changeset
152 HeapWord* max_to_do = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 uintptr_t cur_chunk_index = addr_to_chunk_index(chunk_mr.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
154 cur_chunk_index = cur_chunk_index - lowest_non_clean_base_chunk_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 if (chunk_mr.end() < used.end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // This is not the last chunk in the used region. What is the last
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // object?
a61af66fc99e Initial load
duke
parents:
diff changeset
159 HeapWord* last_block = sp->block_start(chunk_mr.end());
a61af66fc99e Initial load
duke
parents:
diff changeset
160 assert(last_block <= chunk_mr.end(), "In case this property changes.");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (last_block == chunk_mr.end()
a61af66fc99e Initial load
duke
parents:
diff changeset
162 || !sp->block_is_obj(last_block)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 max_to_do = chunk_mr.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // It is an object and starts before the end of the current chunk.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // last_obj_card is the card corresponding to the start of the last object
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // in the chunk. Note that the last object may not start in
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // the chunk.
a61af66fc99e Initial load
duke
parents:
diff changeset
170 jbyte* last_obj_card = byte_for(last_block);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 if (!card_may_have_been_dirty(*last_obj_card)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // The card containing the head is not dirty. Any marks in
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // subsequent cards still in this chunk must have been made
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // precisely; we can cap processing at the end.
a61af66fc99e Initial load
duke
parents:
diff changeset
175 max_to_do = chunk_mr.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
176 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // The last object must be considered dirty, and extends onto the
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // following chunk. Look for a dirty card in that chunk that will
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // bound our processing.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 jbyte* limit_card = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 size_t last_block_size = sp->block_size(last_block);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 jbyte* last_card_of_last_obj =
a61af66fc99e Initial load
duke
parents:
diff changeset
183 byte_for(last_block + last_block_size - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 jbyte* first_card_of_next_chunk = byte_for(chunk_mr.end());
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // This search potentially goes a long distance looking
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // for the next card that will be scanned. For example,
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // an object that is an array of primitives will not
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // have any cards covering regions interior to the array
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // that will need to be scanned. The scan can be terminated
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // at the last card of the next chunk. That would leave
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // limit_card as NULL and would result in "max_to_do"
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // being set with the LNC value or with the end
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // of the last block.
a61af66fc99e Initial load
duke
parents:
diff changeset
194 jbyte* last_card_of_next_chunk = first_card_of_next_chunk +
a61af66fc99e Initial load
duke
parents:
diff changeset
195 CardsPerStrideChunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert(byte_for(chunk_mr.end()) - byte_for(chunk_mr.start())
a61af66fc99e Initial load
duke
parents:
diff changeset
197 == CardsPerStrideChunk, "last card of next chunk may be wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 jbyte* last_card_to_check = (jbyte*) MIN2(last_card_of_last_obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
199 last_card_of_next_chunk);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 for (jbyte* cur = first_card_of_next_chunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 cur <= last_card_to_check; cur++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 if (card_will_be_scanned(*cur)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 limit_card = cur; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(0 <= cur_chunk_index+1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
207 cur_chunk_index+1 < lowest_non_clean_chunk_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 "Bounds error.");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // LNC for the next chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
210 jbyte* lnc_card = lowest_non_clean[cur_chunk_index+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (limit_card == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 limit_card = lnc_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (limit_card != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (lnc_card != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 limit_card = (jbyte*)MIN2((intptr_t)limit_card,
a61af66fc99e Initial load
duke
parents:
diff changeset
217 (intptr_t)lnc_card);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 max_to_do = addr_for(limit_card);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 max_to_do = last_block + last_block_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 assert(max_to_do != NULL, "OOPS!");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 max_to_do = used.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // Now we can set the closure we're using so it doesn't to beyond
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // max_to_do.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 dcto_cl->set_min_done(max_to_do);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
233 dcto_cl->set_last_bottom(max_to_do);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Now we set *our" lowest_non_clean entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Find the object that spans our boundary, if one exists.
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Nothing to do on the first chunk.
a61af66fc99e Initial load
duke
parents:
diff changeset
239 if (chunk_mr.start() > used.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // first_block is the block possibly spanning the chunk start
a61af66fc99e Initial load
duke
parents:
diff changeset
241 HeapWord* first_block = sp->block_start(chunk_mr.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Does the block span the start of the chunk and is it
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // an object?
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if (first_block < chunk_mr.start() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
245 sp->block_is_obj(first_block)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 jbyte* first_dirty_card = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 jbyte* last_card_of_first_obj =
a61af66fc99e Initial load
duke
parents:
diff changeset
248 byte_for(first_block + sp->block_size(first_block) - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
250 jbyte* last_card_of_cur_chunk = byte_for(chunk_mr.last());
a61af66fc99e Initial load
duke
parents:
diff changeset
251 jbyte* last_card_to_check =
a61af66fc99e Initial load
duke
parents:
diff changeset
252 (jbyte*) MIN2((intptr_t) last_card_of_cur_chunk,
a61af66fc99e Initial load
duke
parents:
diff changeset
253 (intptr_t) last_card_of_first_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 for (jbyte* cur = first_card_of_cur_chunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 cur <= last_card_to_check; cur++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (card_will_be_scanned(*cur)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 first_dirty_card = cur; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (first_dirty_card != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 assert(0 <= cur_chunk_index &&
a61af66fc99e Initial load
duke
parents:
diff changeset
262 cur_chunk_index < lowest_non_clean_chunk_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
263 "Bounds error.");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 lowest_non_clean[cur_chunk_index] = first_dirty_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 void
a61af66fc99e Initial load
duke
parents:
diff changeset
271 CardTableModRefBS::
a61af66fc99e Initial load
duke
parents:
diff changeset
272 get_LNC_array_for_space(Space* sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
273 jbyte**& lowest_non_clean,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 uintptr_t& lowest_non_clean_base_chunk_index,
a61af66fc99e Initial load
duke
parents:
diff changeset
275 size_t& lowest_non_clean_chunk_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 int i = find_covering_region_containing(sp->bottom());
a61af66fc99e Initial load
duke
parents:
diff changeset
278 MemRegion covered = _covered[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
279 size_t n_chunks = chunks_to_cover(covered);
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Only the first thread to obtain the lock will resize the
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // LNC array for the covered region. Any later expansion can't affect
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // the used_at_save_marks region.
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // (I observed a bug in which the first thread to execute this would
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // resize, and then it would cause "expand_and_allocates" that would
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // Increase the number of chunks in the covered region. Then a second
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // thread would come and execute this, see that the size didn't match,
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // and free and allocate again. So the first thread would be using a
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // freed "_lowest_non_clean" array.)
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // Do a dirty read here. If we pass the conditional then take the rare
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // event lock and do the read again in case some other thread had already
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // succeeded and done the resize.
a61af66fc99e Initial load
duke
parents:
diff changeset
294 int cur_collection = Universe::heap()->total_collections();
a61af66fc99e Initial load
duke
parents:
diff changeset
295 if (_last_LNC_resizing_collection[i] != cur_collection) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 MutexLocker x(ParGCRareEvent_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (_last_LNC_resizing_collection[i] != cur_collection) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 if (_lowest_non_clean[i] == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
299 n_chunks != _lowest_non_clean_chunk_size[i]) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // Should we delete the old?
a61af66fc99e Initial load
duke
parents:
diff changeset
302 if (_lowest_non_clean[i] != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 assert(n_chunks != _lowest_non_clean_chunk_size[i],
a61af66fc99e Initial load
duke
parents:
diff changeset
304 "logical consequence");
a61af66fc99e Initial load
duke
parents:
diff changeset
305 FREE_C_HEAP_ARRAY(CardPtr, _lowest_non_clean[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 _lowest_non_clean[i] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // Now allocate a new one if necessary.
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (_lowest_non_clean[i] == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 _lowest_non_clean[i] = NEW_C_HEAP_ARRAY(CardPtr, n_chunks);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 _lowest_non_clean_chunk_size[i] = n_chunks;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 _lowest_non_clean_base_chunk_index[i] = addr_to_chunk_index(covered.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
313 for (int j = 0; j < (int)n_chunks; j++)
a61af66fc99e Initial load
duke
parents:
diff changeset
314 _lowest_non_clean[i][j] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
317 _last_LNC_resizing_collection[i] = cur_collection;
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // In any case, now do the initialization.
a61af66fc99e Initial load
duke
parents:
diff changeset
321 lowest_non_clean = _lowest_non_clean[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
322 lowest_non_clean_base_chunk_index = _lowest_non_clean_base_chunk_index[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
323 lowest_non_clean_chunk_size = _lowest_non_clean_chunk_size[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }