8023021: Unnecessary clearing of the card table introduced by the fix for JDK-8023013
Reviewed-by: stefank, ehelin
--- a/hotspot/src/share/vm/memory/cardTableRS.cpp Wed Aug 14 13:49:36 2013 +0200
+++ b/hotspot/src/share/vm/memory/cardTableRS.cpp Thu Aug 15 10:05:50 2013 +0200
@@ -310,32 +310,27 @@
_ct_bs->non_clean_card_iterate_possibly_parallel(sp, urasm, cl, this);
}
-void CardTableRS::clear_into_younger(Generation* gen) {
- GenCollectedHeap* gch = GenCollectedHeap::heap();
- // Generations younger than gen have been evacuated. We can clear
- // card table entries for gen (we know that it has no pointers
- // to younger gens) and for those below. The card tables for
- // the youngest gen need never be cleared.
+void CardTableRS::clear_into_younger(Generation* old_gen) {
+ assert(old_gen->level() == 1, "Should only be called for the old generation");
+ // The card tables for the youngest gen need never be cleared.
// There's a bit of subtlety in the clear() and invalidate()
// methods that we exploit here and in invalidate_or_clear()
// below to avoid missing cards at the fringes. If clear() or
// invalidate() are changed in the future, this code should
// be revisited. 20040107.ysr
- Generation* old_gen = gen;
clear(old_gen->prev_used_region());
- Generation* young_gen = gch->prev_gen(old_gen);
- clear(young_gen->prev_used_region());
}
-void CardTableRS::invalidate_or_clear(Generation* gen) {
- // For generation gen invalidate the cards for the currently
- // occupied part of that generation and clear the cards for the
+void CardTableRS::invalidate_or_clear(Generation* old_gen) {
+ assert(old_gen->level() == 1, "Should only be called for the old generation");
+ // Invalidate the cards for the currently occupied part of
+ // the old generation and clear the cards for the
// unoccupied part of the generation (if any, making use
// of that generation's prev_used_region to determine that
// region). No need to do anything for the youngest
// generation. Also see note#20040107.ysr above.
- MemRegion used_mr = gen->used_region();
- MemRegion to_be_cleared_mr = gen->prev_used_region().minus(used_mr);
+ MemRegion used_mr = old_gen->used_region();
+ MemRegion to_be_cleared_mr = old_gen->prev_used_region().minus(used_mr);
if (!to_be_cleared_mr.is_empty()) {
clear(to_be_cleared_mr);
}
--- a/hotspot/src/share/vm/memory/cardTableRS.hpp Wed Aug 14 13:49:36 2013 +0200
+++ b/hotspot/src/share/vm/memory/cardTableRS.hpp Thu Aug 15 10:05:50 2013 +0200
@@ -142,12 +142,12 @@
void verify_aligned_region_empty(MemRegion mr);
void clear(MemRegion mr) { _ct_bs->clear(mr); }
- void clear_into_younger(Generation* gen);
+ void clear_into_younger(Generation* old_gen);
void invalidate(MemRegion mr, bool whole_heap = false) {
_ct_bs->invalidate(mr, whole_heap);
}
- void invalidate_or_clear(Generation* gen);
+ void invalidate_or_clear(Generation* old_gen);
static uintx ct_max_alignment_constraint() {
return CardTableModRefBS::ct_max_alignment_constraint();
--- a/hotspot/src/share/vm/memory/genMarkSweep.cpp Wed Aug 14 13:49:36 2013 +0200
+++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp Thu Aug 15 10:05:50 2013 +0200
@@ -121,17 +121,15 @@
all_empty = all_empty && gch->get_gen(i)->used() == 0;
}
GenRemSet* rs = gch->rem_set();
+ Generation* old_gen = gch->get_gen(level);
// Clear/invalidate below make use of the "prev_used_regions" saved earlier.
if (all_empty) {
// We've evacuated all generations below us.
- Generation* g = gch->get_gen(level);
- rs->clear_into_younger(g);
+ rs->clear_into_younger(old_gen);
} else {
// Invalidate the cards corresponding to the currently used
- // region and clear those corresponding to the evacuated region
- // of all generations just collected.
- rs->invalidate_or_clear(gch->get_gen(1));
- rs->invalidate_or_clear(gch->get_gen(0));
+ // region and clear those corresponding to the evacuated region.
+ rs->invalidate_or_clear(old_gen);
}
Threads::gc_epilogue();
--- a/hotspot/src/share/vm/memory/genRemSet.hpp Wed Aug 14 13:49:36 2013 +0200
+++ b/hotspot/src/share/vm/memory/genRemSet.hpp Thu Aug 15 10:05:50 2013 +0200
@@ -135,7 +135,7 @@
// younger than gen from generations gen and older.
// The parameter clear_perm indicates if the perm_gen's
// remembered set should also be processed/cleared.
- virtual void clear_into_younger(Generation* gen) = 0;
+ virtual void clear_into_younger(Generation* old_gen) = 0;
// Informs the RS that refs in the given "mr" may have changed
// arbitrarily, and therefore may contain old-to-young pointers.
@@ -147,7 +147,7 @@
// Informs the RS that refs in this generation
// may have changed arbitrarily, and therefore may contain
// old-to-young pointers in arbitrary locations.
- virtual void invalidate_or_clear(Generation* gen) = 0;
+ virtual void invalidate_or_clear(Generation* old_gen) = 0;
};
#endif // SHARE_VM_MEMORY_GENREMSET_HPP