Skip to content

Commit d447297

Browse files
author
William Kemper
committed
8367709: GenShen: Dirty cards for objects that get promoted by safepoint that intervenes between allocation and stores
Reviewed-by: ysr
1 parent 844118a commit d447297

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,19 @@ bool ShenandoahBarrierSet::need_keep_alive_barrier(DecoratorSet decorators, Basi
8989

9090
void ShenandoahBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {
9191
#if COMPILER2_OR_JVMCI
92-
assert(!ReduceInitialCardMarks || !ShenandoahCardBarrier || ShenandoahGenerationalHeap::heap()->is_in_young(new_obj),
93-
"Allocating new object outside of young generation: " INTPTR_FORMAT, p2i(new_obj));
92+
if (ReduceInitialCardMarks && ShenandoahCardBarrier && !ShenandoahHeap::heap()->is_in_young(new_obj)) {
93+
log_debug(gc)("Newly allocated object (" PTR_FORMAT ") is not in the young generation", p2i(new_obj));
94+
// This can happen when an object is newly allocated, but we come to a safepoint before returning
95+
// the object. If the safepoint runs a degenerated cycle that is upgraded to a full GC, this object
96+
// will have survived two GC cycles. If the tenuring age is very low (1), this object may be promoted.
97+
// In this case, we have an allocated object, but it has received no stores yet. If card marking barriers
98+
// have been elided, we could end up with an object in old holding pointers to young that won't be in
99+
// the remembered set. The solution here is conservative, but this problem should be rare, and it will
100+
// correct itself on subsequent cycles when the remembered set is updated.
101+
ShenandoahGenerationalHeap::heap()->old_generation()->card_scan()->mark_range_as_dirty(
102+
cast_from_oop<HeapWord*>(new_obj), new_obj->size()
103+
);
104+
}
94105
#endif // COMPILER2_OR_JVMCI
95106
assert(thread->deferred_card_mark().is_empty(), "We don't use this");
96107
}

src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ void ShenandoahMarkingContext::initialize_top_at_mark_start(ShenandoahHeapRegion
7474
_top_at_mark_starts_base[idx] = bottom;
7575
_top_bitmaps[idx] = bottom;
7676

77-
log_debug(gc)("SMC:initialize_top_at_mark_start for Region %zu, TAMS: " PTR_FORMAT ", TopOfBitMap: " PTR_FORMAT,
78-
r->index(), p2i(bottom), p2i(r->end()));
77+
log_debug(gc, mark)("SMC:initialize_top_at_mark_start for Region %zu, TAMS: " PTR_FORMAT ", TopOfBitMap: " PTR_FORMAT,
78+
r->index(), p2i(bottom), p2i(r->end()));
7979
}
8080

8181
HeapWord* ShenandoahMarkingContext::top_bitmap(ShenandoahHeapRegion* r) {
@@ -86,8 +86,8 @@ void ShenandoahMarkingContext::clear_bitmap(ShenandoahHeapRegion* r) {
8686
HeapWord* bottom = r->bottom();
8787
HeapWord* top_bitmap = _top_bitmaps[r->index()];
8888

89-
log_debug(gc)("SMC:clear_bitmap for %s Region %zu, top_bitmap: " PTR_FORMAT,
90-
r->affiliation_name(), r->index(), p2i(top_bitmap));
89+
log_debug(gc, mark)("SMC:clear_bitmap for %s Region %zu, top_bitmap: " PTR_FORMAT,
90+
r->affiliation_name(), r->index(), p2i(top_bitmap));
9191

9292
if (top_bitmap > bottom) {
9393
_mark_bit_map.clear_range_large(MemRegion(bottom, top_bitmap));

src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ inline void ShenandoahMarkingContext::capture_top_at_mark_start(ShenandoahHeapRe
104104
"Region %zu, bitmap should be clear while adjusting TAMS: " PTR_FORMAT " -> " PTR_FORMAT,
105105
idx, p2i(old_tams), p2i(new_tams));
106106

107-
log_debug(gc)("Capturing TAMS for %s Region %zu, was: " PTR_FORMAT ", now: " PTR_FORMAT,
108-
r->affiliation_name(), idx, p2i(old_tams), p2i(new_tams));
107+
log_debug(gc, mark)("Capturing TAMS for %s Region %zu, was: " PTR_FORMAT ", now: " PTR_FORMAT,
108+
r->affiliation_name(), idx, p2i(old_tams), p2i(new_tams));
109109

110110
_top_at_mark_starts_base[idx] = new_tams;
111111
_top_bitmaps[idx] = new_tams;

src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,9 @@ void ShenandoahScanRememberedTask::do_work(uint worker_id) {
683683
struct ShenandoahRegionChunk assignment;
684684
while (_work_list->next(&assignment)) {
685685
ShenandoahHeapRegion* region = assignment._r;
686-
log_debug(gc)("ShenandoahScanRememberedTask::do_work(%u), processing slice of region "
687-
"%zu at offset %zu, size: %zu",
688-
worker_id, region->index(), assignment._chunk_offset, assignment._chunk_size);
686+
log_debug(gc, remset)("ShenandoahScanRememberedTask::do_work(%u), processing slice of region "
687+
"%zu at offset %zu, size: %zu",
688+
worker_id, region->index(), assignment._chunk_offset, assignment._chunk_size);
689689
if (region->is_old()) {
690690
size_t cluster_size =
691691
CardTable::card_size_in_words() * ShenandoahCardCluster::CardsPerCluster;

src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ ShenandoahScanRemembered::process_region_slice(ShenandoahHeapRegion *region, siz
343343
}
344344
}
345345

346-
log_debug(gc)("Remembered set scan processing Region %zu, from " PTR_FORMAT " to " PTR_FORMAT ", using %s table",
347-
region->index(), p2i(start_of_range), p2i(end_of_range),
348-
use_write_table? "read/write (updating)": "read (marking)");
346+
log_debug(gc, remset)("Remembered set scan processing Region %zu, from " PTR_FORMAT " to " PTR_FORMAT ", using %s table",
347+
region->index(), p2i(start_of_range), p2i(end_of_range),
348+
use_write_table? "read/write (updating)": "read (marking)");
349349

350350
// Note that end_of_range may point to the middle of a cluster because we limit scanning to
351351
// region->top() or region->get_update_watermark(). We avoid processing past end_of_range.

0 commit comments

Comments
 (0)