Skip to content

Commit 045eea1

Browse files
committed
8327057: Parallel: Refactor ParMarkBitMap::iterate
Reviewed-by: tschatzl, iwalulya
1 parent f615ac4 commit 045eea1

File tree

3 files changed

+22
-55
lines changed

3 files changed

+22
-55
lines changed

src/hotspot/share/gc/parallel/parMarkBitMap.cpp

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,26 @@ ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
173173
// The bitmap routines require the right boundary to be word-aligned.
174174
const idx_t search_end = align_range_end(range_end);
175175

176-
idx_t cur_beg = find_obj_beg(range_beg, search_end);
177-
while (cur_beg < range_end) {
178-
const idx_t cur_end = find_obj_end(cur_beg, search_end);
179-
if (cur_end >= range_end) {
180-
// The obj ends outside the range.
181-
live_closure->set_source(bit_to_addr(cur_beg));
182-
return incomplete;
176+
idx_t cur_beg = range_beg;
177+
while (true) {
178+
cur_beg = find_obj_beg(cur_beg, search_end);
179+
if (cur_beg >= range_end) {
180+
break;
183181
}
184182

185-
const size_t size = obj_size(cur_beg, cur_end);
183+
const size_t size = obj_size(cur_beg);
186184
IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size);
187185
if (status != incomplete) {
188186
assert(status == would_overflow || status == full, "sanity");
189187
return status;
190188
}
191189

192-
// Successfully processed the object; look for the next object.
193-
cur_beg = find_obj_beg(cur_end + 1, search_end);
190+
cur_beg += words_to_bits(size);
191+
if (cur_beg >= range_end) {
192+
break;
193+
}
194194
}
195195

196-
live_closure->set_source(bit_to_addr(range_end));
197196
return complete;
198197
}
199198

@@ -210,45 +209,41 @@ ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
210209
assert(range_end <= dead_range_end, "dead range invalid");
211210

212211
// The bitmap routines require the right boundary to be word-aligned.
213-
const idx_t live_search_end = align_range_end(range_end);
214212
const idx_t dead_search_end = align_range_end(dead_range_end);
215213

216214
idx_t cur_beg = range_beg;
217215
if (range_beg < range_end && is_unmarked(range_beg)) {
218216
// The range starts with dead space. Look for the next object, then fill.
217+
// This must be the beginning of old/eden/from/to-space, so it's must be
218+
// large enough for a filler.
219219
cur_beg = find_obj_beg(range_beg + 1, dead_search_end);
220-
const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
220+
const idx_t dead_space_end = cur_beg - 1;
221221
const size_t size = obj_size(range_beg, dead_space_end);
222222
dead_closure->do_addr(bit_to_addr(range_beg), size);
223223
}
224224

225225
while (cur_beg < range_end) {
226-
const idx_t cur_end = find_obj_end(cur_beg, live_search_end);
227-
if (cur_end >= range_end) {
228-
// The obj ends outside the range.
229-
live_closure->set_source(bit_to_addr(cur_beg));
230-
return incomplete;
231-
}
232-
233-
const size_t size = obj_size(cur_beg, cur_end);
226+
const size_t size = obj_size(cur_beg);
234227
IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size);
235228
if (status != incomplete) {
236229
assert(status == would_overflow || status == full, "sanity");
237230
return status;
238231
}
239232

233+
const idx_t dead_space_beg = cur_beg + words_to_bits(size);
234+
if (dead_space_beg >= dead_search_end) {
235+
break;
236+
}
240237
// Look for the start of the next object.
241-
const idx_t dead_space_beg = cur_end + 1;
242238
cur_beg = find_obj_beg(dead_space_beg, dead_search_end);
243239
if (cur_beg > dead_space_beg) {
244240
// Found dead space; compute the size and invoke the dead closure.
245-
const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
246-
const size_t size = obj_size(dead_space_beg, dead_space_end);
247-
dead_closure->do_addr(bit_to_addr(dead_space_beg), size);
241+
const idx_t dead_space_end = cur_beg - 1;
242+
dead_closure->do_addr(bit_to_addr(dead_space_beg),
243+
obj_size(dead_space_beg, dead_space_end));
248244
}
249245
}
250246

251-
live_closure->set_source(bit_to_addr(range_end));
252247
return complete;
253248
}
254249

src/hotspot/share/gc/parallel/parMarkBitMap.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ class ParMarkBitMap: public CHeapObj<mtGC>
8181
// range [live_range_beg, live_range_end). This is used to iterate over the
8282
// compacted region of the heap. Return values:
8383
//
84-
// incomplete The iteration is not complete. The last object that
85-
// begins in the range does not end in the range;
86-
// closure->source() is set to the start of that object.
87-
//
8884
// complete The iteration is complete. All objects in the range
8985
// were processed and the closure is not full;
9086
// closure->source() is set one past the end of the range.

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,12 +2424,7 @@ PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
24242424
// Create closures and iterate.
24252425
UpdateOnlyClosure update_closure(mbm, cm, space_id);
24262426
FillClosure fill_closure(cm, space_id);
2427-
ParMarkBitMap::IterationStatus status;
2428-
status = mbm->iterate(&update_closure, &fill_closure, beg_addr, end_addr,
2429-
dense_prefix_end);
2430-
if (status == ParMarkBitMap::incomplete) {
2431-
update_closure.do_addr(update_closure.source());
2432-
}
2427+
mbm->iterate(&update_closure, &fill_closure, beg_addr, end_addr, dense_prefix_end);
24332428
}
24342429

24352430
// Mark the regions as filled.
@@ -2740,25 +2735,6 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
27402735
src_space_top);
27412736
IterationStatus status = bitmap->iterate(&closure, cur_addr, end_addr);
27422737

2743-
if (status == ParMarkBitMap::incomplete) {
2744-
// The last obj that starts in the source region does not end in the
2745-
// region.
2746-
assert(closure.source() < end_addr, "sanity");
2747-
HeapWord* const obj_beg = closure.source();
2748-
HeapWord* const range_end = MIN2(obj_beg + closure.words_remaining(),
2749-
src_space_top);
2750-
HeapWord* const obj_end = bitmap->find_obj_end(obj_beg, range_end);
2751-
if (obj_end < range_end) {
2752-
// The end was found; the entire object will fit.
2753-
status = closure.do_addr(obj_beg, bitmap->obj_size(obj_beg, obj_end));
2754-
assert(status != ParMarkBitMap::would_overflow, "sanity");
2755-
} else {
2756-
// The end was not found; the object will not fit.
2757-
assert(range_end < src_space_top, "obj cannot cross space boundary");
2758-
status = ParMarkBitMap::would_overflow;
2759-
}
2760-
}
2761-
27622738
if (status == ParMarkBitMap::would_overflow) {
27632739
// The last object did not fit. Note that interior oop updates were
27642740
// deferred, then copy enough of the object to fill the region.

0 commit comments

Comments
 (0)