@@ -187,10 +187,9 @@ inline void ShenandoahBarrierSet::keep_alive_if_weak(DecoratorSet decorators, oo
187
187
188
188
template <DecoratorSet decorators, typename T>
189
189
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 ();
194
193
}
195
194
196
195
template <typename T>
@@ -280,8 +279,10 @@ inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_st
280
279
shenandoah_assert_not_forwarded_except (addr, value, value == nullptr || ShenandoahHeap::heap ()->cancelled_gc () || !ShenandoahHeap::heap ()->is_concurrent_mark_in_progress ());
281
280
282
281
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
+ }
285
286
}
286
287
287
288
template <DecoratorSet decorators, typename BarrierSetT>
@@ -303,7 +304,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
303
304
assert ((decorators & (AS_NO_KEEPALIVE | ON_UNKNOWN_OOP_REF)) == 0 , " must be absent" );
304
305
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set ();
305
306
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
+ }
307
310
return result;
308
311
}
309
312
@@ -314,7 +317,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
314
317
DecoratorSet resolved_decorators = AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset);
315
318
auto addr = AccessInternal::oop_field_addr<decorators>(base, offset);
316
319
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
+ }
318
323
return result;
319
324
}
320
325
@@ -332,7 +337,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
332
337
assert ((decorators & (AS_NO_KEEPALIVE | ON_UNKNOWN_OOP_REF)) == 0 , " must be absent" );
333
338
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set ();
334
339
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
+ }
336
343
return result;
337
344
}
338
345
@@ -343,7 +350,9 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
343
350
DecoratorSet resolved_decorators = AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset);
344
351
auto addr = AccessInternal::oop_field_addr<decorators>(base, offset);
345
352
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
+ }
347
356
return result;
348
357
}
349
358
@@ -367,7 +376,9 @@ bool ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_arraycopy
367
376
ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set ();
368
377
bs->arraycopy_barrier (src, dst, length);
369
378
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
+ }
371
382
return result;
372
383
}
373
384
0 commit comments