Skip to content

Commit 3e11708

Browse files
committed
8369013: Shenandoah: passive mode should support enabling ShenandoahCardBarrier
1 parent 62f11cd commit 3e11708

File tree

8 files changed

+40
-10
lines changed

8 files changed

+40
-10
lines changed

src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ void ShenandoahPassiveMode::initialize_flags() const {
4848
SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahCloneBarrier);
4949
SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahStackWatermarkBarrier);
5050
SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahCardBarrier);
51-
52-
// Final configuration checks
53-
// Passive mode does not instantiate the machinery to support the card table.
54-
// Exit if the flag has been explicitly set.
55-
SHENANDOAH_CHECK_FLAG_UNSET(ShenandoahCardBarrier);
5651
}
5752

5853
ShenandoahHeuristics* ShenandoahPassiveMode::initialize_heuristics(ShenandoahSpaceInfo* space_info) const {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,5 +1172,10 @@ ShenandoahGenerationalHeap::TransferResult ShenandoahFullGC::phase5_epilog() {
11721172
result = ShenandoahGenerationalFullGC::balance_generations_after_rebuilding_free_set();
11731173
ShenandoahGenerationalFullGC::rebuild_remembered_set(heap);
11741174
}
1175+
1176+
// passive mode with ShenandoahCardBarrier turned on, clean the write table without swapping the tables
1177+
if (ShenandoahCardBarrier && !heap->mode()->is_generational()) {
1178+
heap->old_generation()->card_scan()->mark_write_table_as_clean();
1179+
}
11751180
return result;
11761181
}

src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ class ShenandoahGenerationalHeap : public ShenandoahHeap {
4444
void initialize_heuristics() override;
4545

4646
static ShenandoahGenerationalHeap* heap() {
47-
shenandoah_assert_generational();
4847
CollectedHeap* heap = Universe::heap();
4948
return cast(heap);
5049
}
5150

5251
static ShenandoahGenerationalHeap* cast(CollectedHeap* heap) {
53-
shenandoah_assert_generational();
5452
return checked_cast<ShenandoahGenerationalHeap*>(heap);
5553
}
5654

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,19 @@ jint ShenandoahHeap::initialize() {
248248
// Now we know the number of regions and heap sizes, initialize the heuristics.
249249
initialize_heuristics();
250250

251+
// If ShenandoahCardBarrier is enabled but it's not generational mode
252+
// it means we're under passive mode and we have to initialize old gen
253+
// for the purpose of having card table.
254+
if (ShenandoahCardBarrier && !(mode()->is_generational())) {
255+
_generation_sizer.heap_size_changed(max_capacity());
256+
size_t initial_capacity_young = _generation_sizer.max_young_size();
257+
size_t max_capacity_young = _generation_sizer.max_young_size();
258+
size_t initial_capacity_old = max_capacity() - max_capacity_young;
259+
size_t max_capacity_old = max_capacity() - initial_capacity_young;
260+
261+
_old_generation = new ShenandoahOldGeneration(max_workers(), max_capacity_old);
262+
}
263+
251264
assert(_heap_region.byte_size() == heap_rs.size(), "Need to know reserved size for card table");
252265

253266
//

src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ class ShenandoahHeap : public CollectedHeap {
530530
}
531531

532532
ShenandoahOldGeneration* old_generation() const {
533-
assert(mode()->is_generational(), "Old generation requires generational mode");
534533
return _old_generation;
535534
}
536535

@@ -564,6 +563,7 @@ class ShenandoahHeap : public CollectedHeap {
564563
ConcurrentGCTimer* _gc_timer;
565564
// For exporting to SA
566565
int _log_min_obj_alignment_in_bytes;
566+
ShenandoahGenerationSizer _generation_sizer;
567567
public:
568568
ShenandoahMonitoringSupport* monitoring_support() const { return _monitoring_support; }
569569
GCMemoryManager* cycle_memory_manager() { return &_cycle_memory_manager; }

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ void ShenandoahDirectCardMarkRememberedSet::mark_read_table_as_clean() {
123123
log_develop_debug(gc, barrier)("Cleaned read_table from " PTR_FORMAT " to " PTR_FORMAT, p2i(&(read_table[0])), p2i(end_bp));
124124
}
125125

126+
void ShenandoahDirectCardMarkRememberedSet::mark_write_table_as_clean() {
127+
CardValue* write_table = _card_table->write_byte_map();
128+
CardValue* bp = &(write_table)[0];
129+
CardValue* end_bp = &(write_table)[_card_table->last_valid_index()];
130+
131+
while (bp <= end_bp) {
132+
*bp++ = CardTable::clean_card_val();
133+
}
134+
135+
log_develop_debug(gc, barrier)("Cleaned write_table from " PTR_FORMAT " to " PTR_FORMAT, p2i(&(write_table[0])), p2i(end_bp));
136+
}
137+
126138
// No lock required because arguments align with card boundaries.
127139
void ShenandoahCardCluster::reset_object_range(HeapWord* from, HeapWord* to) {
128140
assert(((((unsigned long long) from) & (CardTable::card_size() - 1)) == 0) &&
@@ -330,6 +342,10 @@ void ShenandoahScanRemembered::mark_read_table_as_clean() {
330342
_rs->mark_read_table_as_clean();
331343
}
332344

345+
void ShenandoahScanRemembered::mark_write_table_as_clean() {
346+
_rs->mark_write_table_as_clean();
347+
}
348+
333349
void ShenandoahScanRemembered::reset_object_range(HeapWord* from, HeapWord* to) {
334350
_scc->reset_object_range(from, to);
335351
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ class ShenandoahDirectCardMarkRememberedSet: public CHeapObj<mtGC> {
244244
// See comment in ShenandoahScanRemembered
245245
inline void mark_read_table_as_clean();
246246

247+
inline void mark_write_table_as_clean();
248+
247249
// Merge any dirty values from write table into the read table, while leaving
248250
// the write table unchanged.
249251
void merge_write_table(HeapWord* start, size_t word_count);
@@ -769,6 +771,8 @@ class ShenandoahScanRemembered: public CHeapObj<mtGC> {
769771
// the "write" table.
770772
void mark_read_table_as_clean();
771773

774+
void mark_write_table_as_clean();
775+
772776
// Swaps read and write card tables pointers in effect setting a clean card
773777
// table for the next GC cycle.
774778
void swap_card_tables() { _rs->swap_card_tables(); }

test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierEnable.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ public static void main(String[] args) throws Exception {
4545
shouldPassAll("-XX:ShenandoahGCHeuristics=static", concurrent);
4646
shouldPassAll("-XX:ShenandoahGCHeuristics=compact", concurrent);
4747
shouldPassAll("-XX:ShenandoahGCHeuristics=aggressive", concurrent);
48-
shouldPassAll("-XX:ShenandoahGCMode=passive", concurrent);
48+
shouldPassAll("-XX:ShenandoahGCMode=passive", all);
4949
shouldPassAll("-XX:ShenandoahGCMode=generational", all);
5050
shouldFailAll("-XX:ShenandoahGCMode=satb", generational);
51-
shouldFailAll("-XX:ShenandoahGCMode=passive", generational);
5251
}
5352

5453
private static void shouldFailAll(String h, String[] barriers) throws Exception {

0 commit comments

Comments
 (0)