8166862: CMS needs klass_or_null_acquire
Summary: Change CMS non-assert uses of klass_or_null to klass_or_null_acquire.
Reviewed-by: tschatzl, mgerdin
--- a/hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp Fri Oct 21 17:51:33 2016 -0700
+++ b/hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp Fri Oct 21 22:26:51 2016 -0400
@@ -922,18 +922,13 @@
return res;
}
} else {
- // must read from what 'p' points to in each loop.
- Klass* k = ((volatile oopDesc*)p)->klass_or_null();
+ // Ensure klass read before size.
+ Klass* k = oop(p)->klass_or_null_acquire();
if (k != NULL) {
assert(k->is_klass(), "Should really be klass oop.");
oop o = (oop)p;
assert(o->is_oop(true /* ignore mark word */), "Should be an oop.");
- // Bugfix for systems with weak memory model (PPC64/IA64).
- // The object o may be an array. Acquire to make sure that the array
- // size (third word) is consistent.
- OrderAccess::acquire();
-
size_t res = o->size_given_klass(k);
res = adjustObjectSize(res);
assert(res != 0, "Block size should not be 0");
@@ -977,21 +972,13 @@
return res;
}
} else {
- // must read from what 'p' points to in each loop.
- Klass* k = ((volatile oopDesc*)p)->klass_or_null();
- // We trust the size of any object that has a non-NULL
- // klass and (for those in the perm gen) is parsable
- // -- irrespective of its conc_safe-ty.
+ // Ensure klass read before size.
+ Klass* k = oop(p)->klass_or_null_acquire();
if (k != NULL) {
assert(k->is_klass(), "Should really be klass oop.");
oop o = (oop)p;
assert(o->is_oop(), "Should be an oop");
- // Bugfix for systems with weak memory model (PPC64/IA64).
- // The object o may be an array. Acquire to make sure that the array
- // size (third word) is consistent.
- OrderAccess::acquire();
-
size_t res = o->size_given_klass(k);
res = adjustObjectSize(res);
assert(res != 0, "Block size should not be 0");
@@ -1028,7 +1015,7 @@
FreeChunk* fc = (FreeChunk*)p;
assert(is_in_reserved(p), "Should be in space");
if (FreeChunk::indicatesFreeChunk(p)) return false;
- Klass* k = oop(p)->klass_or_null();
+ Klass* k = oop(p)->klass_or_null_acquire();
if (k != NULL) {
// Ignore mark word because it may have been used to
// chain together promoted objects (the last one
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp Fri Oct 21 17:51:33 2016 -0700
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp Fri Oct 21 22:26:51 2016 -0400
@@ -5630,7 +5630,7 @@
HeapWord* CMSCollector::next_card_start_after_block(HeapWord* addr) const {
size_t sz = 0;
oop p = (oop)addr;
- if (p->klass_or_null() != NULL) {
+ if (p->klass_or_null_acquire() != NULL) {
sz = CompactibleFreeListSpace::adjustObjectSize(p->size());
} else {
sz = block_size_using_printezis_bits(addr);
@@ -6076,7 +6076,7 @@
}
if (_bitMap->isMarked(addr)) {
// it's marked; is it potentially uninitialized?
- if (p->klass_or_null() != NULL) {
+ if (p->klass_or_null_acquire() != NULL) {
// an initialized object; ignore mark word in verification below
// since we are running concurrent with mutators
assert(p->is_oop(true), "should be an oop");
@@ -6121,7 +6121,7 @@
}
} else {
// Either a not yet marked object or an uninitialized object
- if (p->klass_or_null() == NULL) {
+ if (p->klass_or_null_acquire() == NULL) {
// An uninitialized object, skip to the next card, since
// we may not be able to read its P-bits yet.
assert(size == 0, "Initial value");
@@ -6320,7 +6320,7 @@
assert(_skipBits == 0, "tautology");
_skipBits = 2; // skip next two marked bits ("Printezis-marks")
oop p = oop(addr);
- if (p->klass_or_null() == NULL) {
+ if (p->klass_or_null_acquire() == NULL) {
DEBUG_ONLY(if (!_verifying) {)
// We re-dirty the cards on which this object lies and increase
// the _threshold so that we'll come back to scan this object
@@ -6340,7 +6340,7 @@
if (_threshold < end_card_addr) {
_threshold = end_card_addr;
}
- if (p->klass_or_null() != NULL) {
+ if (p->klass_or_null_acquire() != NULL) {
// Redirty the range of cards...
_mut->mark_range(redirty_range);
} // ...else the setting of klass will dirty the card anyway.
@@ -6483,7 +6483,7 @@
assert(_skip_bits == 0, "tautology");
_skip_bits = 2; // skip next two marked bits ("Printezis-marks")
oop p = oop(addr);
- if (p->klass_or_null() == NULL) {
+ if (p->klass_or_null_acquire() == NULL) {
// in the case of Clean-on-Enter optimization, redirty card
// and avoid clearing card by increasing the threshold.
return true;
@@ -7354,7 +7354,7 @@
"alignment problem");
#ifdef ASSERT
- if (oop(addr)->klass_or_null() != NULL) {
+ if (oop(addr)->klass_or_null_acquire() != NULL) {
// Ignore mark word because we are running concurrent with mutators
assert(oop(addr)->is_oop(true), "live block should be an oop");
assert(size ==
@@ -7365,7 +7365,7 @@
} else {
// This should be an initialized object that's alive.
- assert(oop(addr)->klass_or_null() != NULL,
+ assert(oop(addr)->klass_or_null_acquire() != NULL,
"Should be an initialized object");
// Ignore mark word because we are running concurrent with mutators
assert(oop(addr)->is_oop(true), "live block should be an oop");