Skip to content
Permalink
Browse files
8241081: Shenandoah: Do not modify update-watermark concurrently
Reviewed-by: shade
  • Loading branch information
rkennke committed Mar 17, 2020
1 parent dbd0f0d commit 035100cc8947ddc523b6f3d8d7218339fd4989f2
Showing with 11 additions and 5 deletions.
  1. +0 −1 src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
  2. +11 −4 src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp
@@ -2407,7 +2407,6 @@ class ShenandoahUpdateHeapRefsTask : public AbstractGangTask {
if (r->is_active() && !r->is_cset()) {
_heap->marked_object_oop_iterate(r, &cl, update_watermark);
}
r->set_update_watermark(r->bottom());
if (ShenandoahPacing) {
_heap->pacer()->report_updaterefs(pointer_delta(update_watermark, r->bottom()));
}
@@ -261,7 +261,7 @@ class ShenandoahHeapRegion : public ContiguousSpace {
volatile size_t _live_data;
volatile size_t _critical_pins;

HeapWord* volatile _update_watermark;
HeapWord* _update_watermark;

// Claim some space at the end to protect next region
DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0);
@@ -431,13 +431,20 @@ class ShenandoahHeapRegion : public ContiguousSpace {
}

HeapWord* get_update_watermark() const {
assert(bottom() <= _update_watermark && _update_watermark <= top(), "within bounds");
return Atomic::load_acquire(&_update_watermark);
// Updates to the update-watermark only happen at safepoints or, when pushing
// back the watermark for evacuation regions, under the Shenandoah heap-lock.
// Consequently, we should access the field under the same lock. However, since
// those updates are only monotonically increasing, possibly reading a stale value
// is only conservative - we would not miss to update any fields.
HeapWord* watermark = _update_watermark;
assert(bottom() <= watermark && watermark <= top(), "within bounds");
return watermark;
}

void set_update_watermark(HeapWord* w) {
_heap->assert_heaplock_or_safepoint();
assert(bottom() <= w && w <= top(), "within bounds");
Atomic::release_store(&_update_watermark, w);
_update_watermark = w;
}

private:

0 comments on commit 035100c

Please sign in to comment.