8166862: CMS needs klass_or_null_acquire

Change CMS non-assert uses of klass_or_null to klass_or_null_acquire.

Reviewed-by: tschatzl, mgerdin
This commit is contained in:
Kim Barrett 2016-10-21 22:26:51 -04:00
parent a8a3dae37c
commit b82dbd43b5
2 changed files with 13 additions and 26 deletions

View File

@ -922,18 +922,13 @@ size_t CompactibleFreeListSpace::block_size(const HeapWord* p) const {
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 @@ const {
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 @@ bool CompactibleFreeListSpace::block_is_obj(const HeapWord* p) const {
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

View File

@ -5630,7 +5630,7 @@ size_t CMSCollector::block_size_if_printezis_bits(HeapWord* addr) const {
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 @@ size_t ScanMarkedObjectsAgainCarefullyClosure::do_object_careful_m(
}
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 @@ size_t ScanMarkedObjectsAgainCarefullyClosure::do_object_careful_m(
}
} 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 @@ bool MarkFromRootsClosure::do_bit(size_t offset) {
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 @@ bool MarkFromRootsClosure::do_bit(size_t offset) {
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 @@ bool ParMarkFromRootsClosure::do_bit(size_t offset) {
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 @@ size_t SweepClosure::do_live_chunk(FreeChunk* fc) {
"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 @@ size_t SweepClosure::do_live_chunk(FreeChunk* fc) {
} 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");