Skip to content

Commit ba88eb1

Browse files
author
Y. Srinivas Ramakrishna
committed
8316137: GenShen: missing ShenandoahCardBarrier filter
Reviewed-by: wkemper
1 parent 69aa971 commit ba88eb1

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ShenandoahBarrierSet::ShenandoahBarrierSet(ShenandoahHeap* heap, MemRegion heap_
5353
_satb_mark_queue_buffer_allocator("SATB Buffer Allocator", ShenandoahSATBBufferSize),
5454
_satb_mark_queue_set(&_satb_mark_queue_buffer_allocator)
5555
{
56-
if (heap->mode()->is_generational()) {
56+
if (ShenandoahCardBarrier) {
5757
_card_table = new ShenandoahCardTable(heap_region);
5858
_card_table->initialize();
5959
}
@@ -158,9 +158,7 @@ void ShenandoahBarrierSet::clone_barrier_runtime(oop src) {
158158
}
159159

160160
void ShenandoahBarrierSet::write_ref_array(HeapWord* start, size_t count) {
161-
if (!_heap->mode()->is_generational()) {
162-
return;
163-
}
161+
assert(ShenandoahCardBarrier, "Did you mean to enable ShenandoahCardBarrier?");
164162

165163
HeapWord* end = (HeapWord*)((char*) start + (count * heapOopSize));
166164
// In the case of compressed oops, start and end may potentially be misaligned;

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ inline void ShenandoahBarrierSet::keep_alive_if_weak(DecoratorSet decorators, oo
187187

188188
template <DecoratorSet decorators, typename T>
189189
inline void ShenandoahBarrierSet::write_ref_field_post(T* field) {
190-
if (ShenandoahHeap::heap()->mode()->is_generational()) {
191-
volatile CardTable::CardValue* byte = card_table()->byte_for(field);
192-
*byte = CardTable::dirty_card_val();
193-
}
190+
assert(ShenandoahCardBarrier, "Did you mean to enable ShenandoahCardBarrier?");
191+
volatile CardTable::CardValue* byte = card_table()->byte_for(field);
192+
*byte = CardTable::dirty_card_val();
194193
}
195194

196195
template <typename T>
@@ -280,8 +279,10 @@ inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_st
280279
shenandoah_assert_not_forwarded_except (addr, value, value == nullptr || ShenandoahHeap::heap()->cancelled_gc() || !ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
281280

282281
oop_store_common(addr, value);
283-
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set();
284-
bs->write_ref_field_post<decorators>(addr);
282+
if (ShenandoahCardBarrier) {
283+
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set();
284+
bs->write_ref_field_post<decorators>(addr);
285+
}
285286
}
286287

287288
template <DecoratorSet decorators, typename BarrierSetT>
@@ -303,7 +304,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
303304
assert((decorators & (AS_NO_KEEPALIVE | ON_UNKNOWN_OOP_REF)) == 0, "must be absent");
304305
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set();
305306
oop result = bs->oop_cmpxchg(decorators, addr, compare_value, new_value);
306-
bs->write_ref_field_post<decorators>(addr);
307+
if (ShenandoahCardBarrier) {
308+
bs->write_ref_field_post<decorators>(addr);
309+
}
307310
return result;
308311
}
309312

@@ -314,7 +317,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
314317
DecoratorSet resolved_decorators = AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset);
315318
auto addr = AccessInternal::oop_field_addr<decorators>(base, offset);
316319
oop result = bs->oop_cmpxchg(resolved_decorators, addr, compare_value, new_value);
317-
bs->write_ref_field_post<decorators>(addr);
320+
if (ShenandoahCardBarrier) {
321+
bs->write_ref_field_post<decorators>(addr);
322+
}
318323
return result;
319324
}
320325

@@ -332,7 +337,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
332337
assert((decorators & (AS_NO_KEEPALIVE | ON_UNKNOWN_OOP_REF)) == 0, "must be absent");
333338
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set();
334339
oop result = bs->oop_xchg(decorators, addr, new_value);
335-
bs->write_ref_field_post<decorators>(addr);
340+
if (ShenandoahCardBarrier) {
341+
bs->write_ref_field_post<decorators>(addr);
342+
}
336343
return result;
337344
}
338345

@@ -343,7 +350,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
343350
DecoratorSet resolved_decorators = AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset);
344351
auto addr = AccessInternal::oop_field_addr<decorators>(base, offset);
345352
oop result = bs->oop_xchg(resolved_decorators, addr, new_value);
346-
bs->write_ref_field_post<decorators>(addr);
353+
if (ShenandoahCardBarrier) {
354+
bs->write_ref_field_post<decorators>(addr);
355+
}
347356
return result;
348357
}
349358

@@ -367,7 +376,9 @@ bool ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy
367376
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set();
368377
bs->arraycopy_barrier(src, dst, length);
369378
bool result = Raw::oop_arraycopy_in_heap(src_obj, src_offset_in_bytes, src_raw, dst_obj, dst_offset_in_bytes, dst_raw, length);
370-
bs->write_ref_array((HeapWord*) dst, length);
379+
if (ShenandoahCardBarrier) {
380+
bs->write_ref_array((HeapWord*) dst, length);
381+
}
371382
return result;
372383
}
373384

0 commit comments

Comments
 (0)