Skip to content

Commit 78b0d32

Browse files
author
Thomas Schatzl
committed
8234534: Simplify CardTable code after CMS removal
Reviewed-by: ayang, kbarrett
1 parent ee2f205 commit 78b0d32

File tree

9 files changed

+14
-205
lines changed

9 files changed

+14
-205
lines changed

src/hotspot/share/gc/serial/defNewGeneration.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ void DefNewGeneration::collect(bool full,
556556
// The preserved marks should be empty at the start of the GC.
557557
_preserved_marks_set.init(1);
558558

559-
heap->rem_set()->prepare_for_younger_refs_iterate(false);
560-
561559
assert(heap->no_allocs_since_save_marks(),
562560
"save marks have not been newly set.");
563561

src/hotspot/share/gc/serial/defNewGeneration.inline.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {
6161
// dirty cards in the young gen are never scanned, so the
6262
// extra check probably isn't worthwhile.
6363
if (GenCollectedHeap::heap()->is_in_reserved(p)) {
64-
oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
65-
_rs->inline_write_ref_field_gc(p, obj);
64+
_rs->inline_write_ref_field_gc(p);
6665
}
6766
}
6867

@@ -84,7 +83,7 @@ inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {
8483
// generation pointer.
8584
oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
8685
if ((cast_from_oop<HeapWord*>(obj) < _boundary) && GenCollectedHeap::heap()->is_in_reserved(p)) {
87-
_rs->inline_write_ref_field_gc(p, obj);
86+
_rs->inline_write_ref_field_gc(p);
8887
}
8988
}
9089

src/hotspot/share/gc/serial/serialHeap.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -97,6 +97,5 @@ void SerialHeap::young_process_roots(OopIterateClosure* root_closure,
9797
process_roots(SO_ScavengeCodeCache, root_closure,
9898
cld_closure, cld_closure, &mark_code_closure);
9999

100-
rem_set()->at_younger_refs_iterate();
101100
old_gen()->younger_refs_iterate(old_gen_closure);
102101
}

src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
121121
}
122122

123123
// Smash zero into card
124-
if(!ct->scanned_concurrently()) {
124+
if (!ct->scanned_concurrently()) {
125125
__ store(__ ctrl(), card_adr, zero, T_BYTE, adr_type, MemNode::unordered);
126126
} else {
127127
// Specialized path for CM store barrier

src/hotspot/share/gc/shared/cardGeneration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -309,7 +309,7 @@ void CardGeneration::space_iterate(SpaceClosure* blk,
309309

310310
void CardGeneration::younger_refs_iterate(OopIterateClosure* blk) {
311311
// Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in
312-
// "sp" that point into younger generations.
312+
// "sp" that point into the young generation.
313313
// The iteration is only over objects allocated at the start of the
314314
// iterations; objects allocated as a result of applying the closure are
315315
// not included.

src/hotspot/share/gc/shared/cardTableRS.cpp

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,53 +38,8 @@
3838
#include "runtime/os.hpp"
3939
#include "utilities/macros.hpp"
4040

41-
CardTable::CardValue CardTableRS::find_unused_youngergenP_card_value() {
42-
for (CardValue v = youngergenP1_card;
43-
v < cur_youngergen_and_prev_nonclean_card;
44-
v++) {
45-
bool seen = false;
46-
for (int g = 0; g < _regions_to_iterate; g++) {
47-
if (_last_cur_val_in_gen[g] == v) {
48-
seen = true;
49-
break;
50-
}
51-
}
52-
if (!seen) {
53-
return v;
54-
}
55-
}
56-
ShouldNotReachHere();
57-
return 0;
58-
}
59-
60-
void CardTableRS::prepare_for_younger_refs_iterate(bool parallel) {
61-
// Parallel or sequential, we must always set the prev to equal the
62-
// last one written.
63-
if (parallel) {
64-
// Find a parallel value to be used next.
65-
jbyte next_val = find_unused_youngergenP_card_value();
66-
set_cur_youngergen_card_val(next_val);
67-
68-
} else {
69-
// In an sequential traversal we will always write youngergen, so that
70-
// the inline barrier is correct.
71-
set_cur_youngergen_card_val(youngergen_card);
72-
}
73-
}
74-
75-
void CardTableRS::at_younger_refs_iterate() {
76-
// The indexing in this array is slightly odd. We want to access
77-
// the old generation record here, which is at index 2.
78-
_last_cur_val_in_gen[2] = cur_youngergen_card_val();
79-
}
80-
8141
inline bool ClearNoncleanCardWrapper::clear_card(CardValue* entry) {
82-
CardValue entry_val = *entry;
83-
assert(entry_val != CardTableRS::clean_card_val(),
84-
"We shouldn't be looking at clean cards, and this should "
85-
"be the only place they get cleaned.");
86-
assert(entry_val != CardTableRS::cur_youngergen_and_prev_nonclean_card,
87-
"This should be possible in the sequential case.");
42+
assert(*entry == CardTableRS::dirty_card_val(), "Only look at dirty cards.");
8843
*entry = CardTableRS::clean_card_val();
8944
return true;
9045
}
@@ -480,58 +435,10 @@ void CardTableRS::verify() {
480435
}
481436

482437
CardTableRS::CardTableRS(MemRegion whole_heap, bool scanned_concurrently) :
483-
CardTable(whole_heap, scanned_concurrently),
484-
_cur_youngergen_card_val(youngergenP1_card),
485-
// LNC functionality
486-
_lowest_non_clean(NULL),
487-
_lowest_non_clean_chunk_size(NULL),
488-
_lowest_non_clean_base_chunk_index(NULL),
489-
_last_LNC_resizing_collection(NULL)
490-
{
491-
// max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations()
492-
// (which is always 2, young & old), but GenCollectedHeap has not been initialized yet.
493-
uint max_gens = 2;
494-
_last_cur_val_in_gen = NEW_C_HEAP_ARRAY(CardValue, max_gens + 1, mtGC);
495-
for (uint i = 0; i < max_gens + 1; i++) {
496-
_last_cur_val_in_gen[i] = clean_card_val();
497-
}
498-
}
499-
500-
CardTableRS::~CardTableRS() {
501-
FREE_C_HEAP_ARRAY(CardValue, _last_cur_val_in_gen);
502-
FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean);
503-
FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size);
504-
FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index);
505-
FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection);
506-
}
438+
CardTable(whole_heap, scanned_concurrently) { }
507439

508440
void CardTableRS::initialize() {
509441
CardTable::initialize();
510-
_lowest_non_clean =
511-
NEW_C_HEAP_ARRAY(CardArr, _max_covered_regions, mtGC);
512-
_lowest_non_clean_chunk_size =
513-
NEW_C_HEAP_ARRAY(size_t, _max_covered_regions, mtGC);
514-
_lowest_non_clean_base_chunk_index =
515-
NEW_C_HEAP_ARRAY(uintptr_t, _max_covered_regions, mtGC);
516-
_last_LNC_resizing_collection =
517-
NEW_C_HEAP_ARRAY(int, _max_covered_regions, mtGC);
518-
519-
for (int i = 0; i < _max_covered_regions; i++) {
520-
_lowest_non_clean[i] = NULL;
521-
_lowest_non_clean_chunk_size[i] = 0;
522-
_last_LNC_resizing_collection[i] = -1;
523-
}
524-
}
525-
526-
bool CardTableRS::card_will_be_scanned(CardValue cv) {
527-
return card_is_dirty_wrt_gen_iter(cv) || is_prev_nonclean_card_val(cv);
528-
}
529-
530-
bool CardTableRS::card_may_have_been_dirty(CardValue cv) {
531-
return
532-
cv != clean_card &&
533-
(card_is_dirty_wrt_gen_iter(cv) ||
534-
CardTableRS::youngergen_may_have_been_dirty(cv));
535442
}
536443

537444
void CardTableRS::non_clean_card_iterate(Space* sp,

src/hotspot/share/gc/shared/cardTableRS.hpp

Lines changed: 4 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,74 +36,24 @@ class Space;
3636
// This RemSet uses a card table both as shared data structure
3737
// for a mod ref barrier set and for the rem set information.
3838

39-
class CardTableRS: public CardTable {
39+
class CardTableRS : public CardTable {
4040
friend class VMStructs;
4141
// Below are private classes used in impl.
4242
friend class VerifyCTSpaceClosure;
4343
friend class ClearNoncleanCardWrapper;
4444

4545
void verify_space(Space* s, HeapWord* gen_start);
4646

47-
enum ExtendedCardValue {
48-
youngergen_card = CT_MR_BS_last_reserved + 1,
49-
// These are for parallel collection.
50-
// There are three P (parallel) youngergen card values. In general, this
51-
// needs to be more than the number of generations (including the perm
52-
// gen) that might have younger_refs_do invoked on them separately. So
53-
// if we add more gens, we have to add more values.
54-
youngergenP1_card = CT_MR_BS_last_reserved + 2,
55-
youngergenP2_card = CT_MR_BS_last_reserved + 3,
56-
youngergenP3_card = CT_MR_BS_last_reserved + 4,
57-
cur_youngergen_and_prev_nonclean_card =
58-
CT_MR_BS_last_reserved + 5
59-
};
60-
61-
// An array that contains, for each generation, the card table value last
62-
// used as the current value for a younger_refs_do iteration of that
63-
// portion of the table. The perm gen is index 0. The young gen is index 1,
64-
// but will always have the value "clean_card". The old gen is index 2.
65-
CardValue* _last_cur_val_in_gen;
66-
67-
CardValue _cur_youngergen_card_val;
68-
69-
// Number of generations, plus one for lingering PermGen issues in CardTableRS.
70-
static const int _regions_to_iterate = 3;
71-
72-
CardValue cur_youngergen_card_val() {
73-
return _cur_youngergen_card_val;
74-
}
75-
void set_cur_youngergen_card_val(CardValue v) {
76-
_cur_youngergen_card_val = v;
77-
}
78-
bool is_prev_youngergen_card_val(CardValue v) {
79-
return
80-
youngergen_card <= v &&
81-
v < cur_youngergen_and_prev_nonclean_card &&
82-
v != _cur_youngergen_card_val;
83-
}
84-
// Return a youngergen_card_value that is not currently in use.
85-
CardValue find_unused_youngergenP_card_value();
86-
8747
public:
8848
CardTableRS(MemRegion whole_heap, bool scanned_concurrently);
89-
~CardTableRS();
9049

9150
void younger_refs_in_space_iterate(Space* sp, HeapWord* gen_boundary, OopIterateClosure* cl);
9251

9352
virtual void verify_used_region_at_save_marks(Space* sp) const NOT_DEBUG_RETURN;
9453

95-
// Override.
96-
void prepare_for_younger_refs_iterate(bool parallel);
97-
98-
// Card table entries are cleared before application;
99-
void at_younger_refs_iterate();
100-
101-
void inline_write_ref_field_gc(void* field, oop new_val) {
54+
void inline_write_ref_field_gc(void* field) {
10255
CardValue* byte = byte_for(field);
103-
*byte = youngergen_card;
104-
}
105-
void write_ref_field_gc_work(void* field, oop new_val) {
106-
inline_write_ref_field_gc(field, new_val);
56+
*byte = dirty_card_val();
10757
}
10858

10959
bool is_aligned(HeapWord* addr) {
@@ -117,33 +67,6 @@ class CardTableRS: public CardTable {
11767

11868
void invalidate_or_clear(Generation* old_gen);
11969

120-
bool is_prev_nonclean_card_val(CardValue v) {
121-
return
122-
youngergen_card <= v &&
123-
v <= cur_youngergen_and_prev_nonclean_card &&
124-
v != _cur_youngergen_card_val;
125-
}
126-
127-
static bool youngergen_may_have_been_dirty(CardValue cv) {
128-
return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
129-
}
130-
131-
// *** Support for parallel card scanning.
132-
133-
// dirty and precleaned are equivalent wrt younger_refs_iter.
134-
static bool card_is_dirty_wrt_gen_iter(CardValue cv) {
135-
return cv == dirty_card;
136-
}
137-
138-
// Returns "true" iff the value "cv" will cause the card containing it
139-
// to be scanned in the current traversal. May be overridden by
140-
// subtypes.
141-
bool card_will_be_scanned(CardValue cv);
142-
143-
// Returns "true" iff the value "cv" may have represented a dirty card at
144-
// some point.
145-
bool card_may_have_been_dirty(CardValue cv);
146-
14770
// Iterate over the portion of the card-table which covers the given
14871
// region mr in the given space and apply cl to any dirty sub-regions
14972
// of mr. Clears the dirty cards as they are processed.
@@ -153,18 +76,6 @@ class CardTableRS: public CardTable {
15376
OopIterateClosure* cl,
15477
CardTableRS* ct);
15578

156-
// This is an array, one element per covered region of the card table.
157-
// Each entry is itself an array, with one element per chunk in the
158-
// covered region. Each entry of these arrays is the lowest non-clean
159-
// card of the corresponding chunk containing part of an object from the
160-
// previous chunk, or else NULL.
161-
typedef CardValue* CardPtr;
162-
typedef CardPtr* CardArr;
163-
CardArr* _lowest_non_clean;
164-
size_t* _lowest_non_clean_chunk_size;
165-
uintptr_t* _lowest_non_clean_base_chunk_index;
166-
volatile int* _last_LNC_resizing_collection;
167-
16879
virtual bool is_in_young(oop obj) const;
16980
};
17081

@@ -179,9 +90,6 @@ class ClearNoncleanCardWrapper: public MemRegionClosure {
17990
// Clears the given card, return true if the corresponding card should be
18091
// processed.
18192
inline bool clear_card(CardValue* entry);
182-
// Work methods called by the clear_card()
183-
inline bool clear_card_serial(CardValue* entry);
184-
inline bool clear_card_parallel(CardValue* entry);
18593
// check alignment of pointer
18694
bool is_word_aligned(CardValue* entry);
18795

src/hotspot/share/gc/shared/genOopClosures.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void DefNewYoungerGenClosure::barrier(T* p) {
8282
oop obj = CompressedOops::decode_not_null(heap_oop);
8383
// If p points to a younger generation, mark the card.
8484
if (cast_from_oop<HeapWord*>(obj) < _old_gen_start) {
85-
_rs->inline_write_ref_field_gc(p, obj);
85+
_rs->inline_write_ref_field_gc(p);
8686
}
8787
}
8888

src/hotspot/share/gc/shared/vmStructs_gc.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@
279279
declare_constant(CardTable::card_size) \
280280
declare_constant(CardTable::card_size_in_words) \
281281
\
282-
declare_constant(CardTableRS::youngergen_card) \
283-
\
284282
declare_constant(CollectedHeap::Serial) \
285283
declare_constant(CollectedHeap::Parallel) \
286284
declare_constant(CollectedHeap::G1) \

0 commit comments

Comments
 (0)