Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8248652: Shenandoah: SATB buffer handling may assume no forwarded obj…
…ects

Reviewed-by: rkennke
  • Loading branch information
shipilev committed Jul 10, 2020
1 parent d3d29a4 commit 0a38584
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 26 deletions.
Expand Up @@ -82,7 +82,7 @@ inline void ShenandoahBarrierSet::enqueue(oop obj) {
// Filter marked objects before hitting the SATB queues. The same predicate would
// be used by SATBMQ::filter to eliminate already marked objects downstream, but
// filtering here helps to avoid wasteful SATB queueing work to begin with.
if (!_heap->requires_marking<false>(obj)) return;
if (!_heap->requires_marking(obj)) return;

ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue_known_active(obj);
}
Expand Down
Expand Up @@ -203,26 +203,19 @@ class ShenandoahSATBBufferClosure : public SATBBufferClosure {
}

void do_buffer(void **buffer, size_t size) {
if (_heap->has_forwarded_objects()) {
if (ShenandoahStringDedup::is_enabled()) {
do_buffer_impl<RESOLVE, ENQUEUE_DEDUP>(buffer, size);
} else {
do_buffer_impl<RESOLVE, NO_DEDUP>(buffer, size);
}
assert(size == 0 || !_heap->has_forwarded_objects(), "Forwarded objects are not expected here");
if (ShenandoahStringDedup::is_enabled()) {
do_buffer_impl<ENQUEUE_DEDUP>(buffer, size);
} else {
if (ShenandoahStringDedup::is_enabled()) {
do_buffer_impl<NONE, ENQUEUE_DEDUP>(buffer, size);
} else {
do_buffer_impl<NONE, NO_DEDUP>(buffer, size);
}
do_buffer_impl<NO_DEDUP>(buffer, size);
}
}

template<UpdateRefsMode UPDATE_REFS, StringDedupMode STRING_DEDUP>
template<StringDedupMode STRING_DEDUP>
void do_buffer_impl(void **buffer, size_t size) {
for (size_t i = 0; i < size; ++i) {
oop *p = (oop *) &buffer[i];
ShenandoahConcurrentMark::mark_through_ref<oop, UPDATE_REFS, STRING_DEDUP>(p, _heap, _queue, _mark_context);
ShenandoahConcurrentMark::mark_through_ref<oop, NONE, STRING_DEDUP>(p, _heap, _queue, _mark_context);
}
}
};
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
Expand Up @@ -656,7 +656,6 @@ class ShenandoahHeap : public CollectedHeap {
void reset_mark_bitmap();

// SATB barriers hooks
template<bool RESOLVE>
inline bool requires_marking(const void* entry) const;
void force_satb_flush_all_threads();

Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
Expand Up @@ -326,12 +326,8 @@ inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
}
}

template<bool RESOLVE>
inline bool ShenandoahHeap::requires_marking(const void* entry) const {
oop obj = oop(entry);
if (RESOLVE) {
obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
}
return !_marking_context->is_marked(obj);
}

Expand Down
Expand Up @@ -36,7 +36,6 @@ SATBMarkQueue& ShenandoahSATBMarkQueueSet::satb_queue_for_thread(Thread* const t
return ShenandoahThreadLocalData::satb_mark_queue(t);
}

template <bool RESOLVE>
class ShenandoahSATBMarkQueueFilterFn {
ShenandoahHeap* const _heap;

Expand All @@ -46,17 +45,13 @@ class ShenandoahSATBMarkQueueFilterFn {
// Return true if entry should be filtered out (removed), false if
// it should be retained.
bool operator()(const void* entry) const {
return !_heap->requires_marking<RESOLVE>(entry);
return !_heap->requires_marking(entry);
}
};

void ShenandoahSATBMarkQueueSet::filter(SATBMarkQueue* queue) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
if (heap->has_forwarded_objects()) {
apply_filter(ShenandoahSATBMarkQueueFilterFn<true>(heap), queue);
} else {
apply_filter(ShenandoahSATBMarkQueueFilterFn<false>(heap), queue);
}
apply_filter(ShenandoahSATBMarkQueueFilterFn(heap), queue);
}

void ShenandoahSATBMarkQueue::handle_completed_buffer() {
Expand Down

0 comments on commit 0a38584

Please sign in to comment.