Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8251358: Clean up Access configuration after Shenandoah barrier change
Reviewed-by: eosterlund, rkennke, shade
  • Loading branch information
adityamandaleeka authored and shipilev committed Sep 29, 2020
1 parent 9c17a35 commit e63b90cc17d3ad08361f0a959f919ae79dd768bf
Show file tree
Hide file tree
Showing 38 changed files with 110 additions and 202 deletions.
@@ -113,7 +113,7 @@ void java_lang_ref_Reference::set_referent_raw(oop ref, oop value) {
}

HeapWord* java_lang_ref_Reference::referent_addr_raw(oop ref) {
return ref->obj_field_addr_raw<HeapWord>(_referent_offset);
return ref->obj_field_addr<HeapWord>(_referent_offset);
}

oop java_lang_ref_Reference::next(oop ref) {
@@ -129,7 +129,7 @@ void java_lang_ref_Reference::set_next_raw(oop ref, oop value) {
}

HeapWord* java_lang_ref_Reference::next_addr_raw(oop ref) {
return ref->obj_field_addr_raw<HeapWord>(_next_offset);
return ref->obj_field_addr<HeapWord>(_next_offset);
}

oop java_lang_ref_Reference::discovered(oop ref) {
@@ -145,7 +145,7 @@ void java_lang_ref_Reference::set_discovered_raw(oop ref, oop value) {
}

HeapWord* java_lang_ref_Reference::discovered_addr_raw(oop ref) {
return ref->obj_field_addr_raw<HeapWord>(_discovered_offset);
return ref->obj_field_addr<HeapWord>(_discovered_offset);
}

bool java_lang_ref_Reference::is_final(oop ref) {
@@ -48,7 +48,7 @@ class G1ResetHumongousClosure : public HeapRegionClosure {
if (_bitmap->is_marked(obj)) {
// Clear bitmap and fix mark word.
_bitmap->clear(obj);
obj->init_mark_raw();
obj->init_mark();
} else {
assert(current->is_empty(), "Should have been cleared in phase 2.");
}
@@ -71,7 +71,7 @@ size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
assert(obj_addr != destination, "everything in this pass should be moving");
Copy::aligned_conjoint_words(obj_addr, destination, size);
oop(destination)->init_mark_raw();
oop(destination)->init_mark();
assert(oop(destination)->klass() != NULL, "should have a class");

return size;
@@ -112,15 +112,15 @@ void G1FullGCCompactionPoint::forward(oop object, size_t size) {
// with BiasedLocking, in this case forwardee() will return NULL
// even if the mark-word is used. This is no problem since
// forwardee() will return NULL in the compaction phase as well.
object->init_mark_raw();
object->init_mark();
} else {
// Make sure object has the correct mark-word set or that it will be
// fixed when restoring the preserved marks.
assert(object->mark_raw() == markWord::prototype_for_klass(object->klass()) || // Correct mark
assert(object->mark() == markWord::prototype_for_klass(object->klass()) || // Correct mark
object->mark_must_be_preserved() || // Will be restored by PreservedMarksSet
(UseBiasedLocking && object->has_bias_pattern_raw()), // Will be restored by BiasedLocking
(UseBiasedLocking && object->has_bias_pattern()), // Will be restored by BiasedLocking
"should have correct prototype obj: " PTR_FORMAT " mark: " PTR_FORMAT " prototype: " PTR_FORMAT,
p2i(object), object->mark_raw().value(), markWord::prototype_for_klass(object->klass()).value());
p2i(object), object->mark().value(), markWord::prototype_for_klass(object->klass()).value());
}
assert(object->forwardee() == NULL, "should be forwarded to NULL");
}
@@ -50,7 +50,7 @@ inline bool G1FullGCMarker::mark_object(oop obj) {
}

// Marked by us, preserve if needed.
markWord mark = obj->mark_raw();
markWord mark = obj->mark();
if (obj->mark_must_be_preserved(mark) &&
!G1ArchiveAllocator::is_open_archive_object(obj)) {
preserved_stack()->push(obj, mark);
@@ -77,11 +77,11 @@ template <class T> inline void G1AdjustClosure::adjust_pointer(T* p) {
oop forwardee = obj->forwardee();
if (forwardee == NULL) {
// Not forwarded, return current reference.
assert(obj->mark_raw() == markWord::prototype_for_klass(obj->klass()) || // Correct mark
assert(obj->mark() == markWord::prototype_for_klass(obj->klass()) || // Correct mark
obj->mark_must_be_preserved() || // Will be restored by PreservedMarksSet
(UseBiasedLocking && obj->has_bias_pattern_raw()), // Will be restored by BiasedLocking
(UseBiasedLocking && obj->has_bias_pattern()), // Will be restored by BiasedLocking
"Must have correct prototype or be preserved, obj: " PTR_FORMAT ", mark: " PTR_FORMAT ", prototype: " PTR_FORMAT,
p2i(obj), obj->mark_raw().value(), markWord::prototype_for_klass(obj->klass()).value());
p2i(obj), obj->mark().value(), markWord::prototype_for_klass(obj->klass()).value());
return;
}

@@ -47,8 +47,8 @@ inline void G1ScanClosureBase::prefetch_and_push(T* p, const oop obj) {
// stall. We'll try to prefetch the object (for write, given that
// we might need to install the forwarding reference) and we'll
// get back to it when pop it from the queue
Prefetch::write(obj->mark_addr_raw(), 0);
Prefetch::read(obj->mark_addr_raw(), (HeapWordSize*2));
Prefetch::write(obj->mark_addr(), 0);
Prefetch::read(obj->mark_addr(), (HeapWordSize*2));

// slightly paranoid test; I'm trying to catch potential
// problems before we go into push_on_queue to know where the
@@ -231,7 +231,7 @@ void G1ParCopyClosure<barrier, do_mark_object>::do_oop_work(T* p) {
const G1HeapRegionAttr state = _g1h->region_attr(obj);
if (state.is_in_cset()) {
oop forwardee;
markWord m = obj->mark_raw();
markWord m = obj->mark();
if (m.is_marked()) {
forwardee = (oop) m.decode_pointer();
} else {
@@ -193,7 +193,7 @@ void G1ParScanThreadState::do_oop_evac(T* p) {
return;
}

markWord m = obj->mark_raw();
markWord m = obj->mark();
if (m.is_marked()) {
obj = (oop) m.decode_pointer();
} else {
@@ -485,15 +485,15 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
// In this case, we have to install the mark word first,
// otherwise obj looks to be forwarded (the old mark word,
// which contains the forward pointer, was copied)
obj->set_mark_raw(old_mark);
obj->set_mark(old_mark);
markWord new_mark = old_mark.displaced_mark_helper().set_age(age);
old_mark.set_displaced_mark_helper(new_mark);
} else {
obj->set_mark_raw(old_mark.set_age(age));
obj->set_mark(old_mark.set_age(age));
}
_age_table.add(age, word_sz);
} else {
obj->set_mark_raw(old_mark);
obj->set_mark(old_mark);
}

// Most objects are not arrays, so do one array check rather than
@@ -133,7 +133,7 @@ inline void follow_array_specialized(objArrayOop obj, int index, ParCompactionMa

const size_t stride = MIN2(len - beg_index, (size_t)ObjArrayMarkingStride);
const size_t end_index = beg_index + stride;
T* const base = (T*)obj->base_raw();
T* const base = (T*)obj->base();
T* const beg = base + beg_index;
T* const end = base + end_index;

@@ -83,7 +83,7 @@ void PSPromotionLAB::flush() {
// so they can always fill with an array.
HeapWord* tlab_end = end() + filler_header_size;
typeArrayOop filler_oop = (typeArrayOop) top();
filler_oop->set_mark_raw(markWord::prototype());
filler_oop->set_mark(markWord::prototype());
filler_oop->set_klass(Universe::intArrayKlassObj());
const size_t array_length =
pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
@@ -53,7 +53,7 @@ inline void PSPromotionManager::claim_or_forward_depth(T* p) {
assert(should_scavenge(p, true), "revisiting object?");
assert(ParallelScavengeHeap::heap()->is_in(p), "pointer outside heap");
oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
Prefetch::write(obj->mark_addr_raw(), 0);
Prefetch::write(obj->mark_addr(), 0);
push_depth(ScannerTask(p));
}

@@ -141,7 +141,7 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
// NOTE! We must be very careful with any methods that access the mark
// in o. There may be multiple threads racing on it, and it may be forwarded
// at any time. Do not use oop methods for accessing the mark!
markWord test_mark = o->mark_raw();
markWord test_mark = o->mark();

// The same test as "o->is_forwarded()"
if (!test_mark.is_marked()) {
@@ -693,7 +693,7 @@ void DefNewGeneration::handle_promotion_failure(oop old) {

_promotion_failed = true;
_promotion_failed_info.register_copy_failure(old->size());
_preserved_marks_set.get()->push_if_necessary(old, old->mark_raw());
_preserved_marks_set.get()->push_if_necessary(old, old->mark());
// forward to self
old->forward_to(old);

@@ -132,7 +132,7 @@ template <class T> inline void MarkSweep::follow_root(T* p) {
T heap_oop = RawAccess<>::oop_load(p);
if (!CompressedOops::is_null(heap_oop)) {
oop obj = CompressedOops::decode_not_null(heap_oop);
if (!obj->mark_raw().is_marked()) {
if (!obj->mark().is_marked()) {
mark_object(obj);
follow_object(obj);
}
@@ -148,7 +148,7 @@ void PreservedMark::adjust_pointer() {
}

void PreservedMark::restore() {
_obj->set_mark_raw(_mark);
_obj->set_mark(_mark);
}

// We preserve the mark which should be replaced at the end and the location
@@ -205,7 +205,7 @@ void MarkSweep::restore_marks() {
while (!_preserved_oop_stack.is_empty()) {
oop obj = _preserved_oop_stack.pop();
markWord mark = _preserved_mark_stack.pop();
obj->set_mark_raw(mark);
obj->set_mark(mark);
}
}

@@ -38,8 +38,8 @@
inline void MarkSweep::mark_object(oop obj) {
// some marks may contain information we need to preserve so we store them away
// and overwrite the mark. We'll restore it at the end of markSweep.
markWord mark = obj->mark_raw();
obj->set_mark_raw(markWord::prototype().set_marked());
markWord mark = obj->mark();
obj->set_mark(markWord::prototype().set_marked());

if (obj->mark_must_be_preserved(mark)) {
preserve_mark(obj, mark);
@@ -50,7 +50,7 @@ template <class T> inline void MarkSweep::mark_and_push(T* p) {
T heap_oop = RawAccess<>::oop_load(p);
if (!CompressedOops::is_null(heap_oop)) {
oop obj = CompressedOops::decode_not_null(heap_oop);
if (!obj->mark_raw().is_marked()) {
if (!obj->mark().is_marked()) {
mark_object(obj);
_marking_stack.push(obj);
}
@@ -79,11 +79,11 @@ template <class T> inline void MarkSweep::adjust_pointer(T* p) {
oop obj = CompressedOops::decode_not_null(heap_oop);
assert(Universe::heap()->is_in(obj), "should be in heap");

oop new_obj = oop(obj->mark_raw().decode_pointer());
oop new_obj = oop(obj->mark().decode_pointer());

assert(new_obj != NULL || // is forwarding ptr?
obj->mark_raw() == markWord::prototype() || // not gc marked?
(UseBiasedLocking && obj->mark_raw().has_bias_pattern()),
assert(new_obj != NULL || // is forwarding ptr?
obj->mark() == markWord::prototype() || // not gc marked?
(UseBiasedLocking && obj->mark().has_bias_pattern()),
// not gc marked?
"should be forwarded");

@@ -43,20 +43,4 @@
FOR_EACH_ABSTRACT_BARRIER_SET_DO(f) \
FOR_EACH_CONCRETE_BARRIER_SET_DO(f)

// To enable runtime-resolution of GC barriers on primitives, please
// define SUPPORT_BARRIER_ON_PRIMITIVES.
#ifdef SUPPORT_BARRIER_ON_PRIMITIVES
#define ACCESS_PRIMITIVE_SUPPORT INTERNAL_BT_BARRIER_ON_PRIMITIVES
#else
#define ACCESS_PRIMITIVE_SUPPORT DECORATORS_NONE
#endif

#ifdef SUPPORT_NOT_TO_SPACE_INVARIANT
#define ACCESS_TO_SPACE_INVARIANT_SUPPORT DECORATORS_NONE
#else
#define ACCESS_TO_SPACE_INVARIANT_SUPPORT INTERNAL_BT_TO_SPACE_INVARIANT
#endif

#define BT_BUILDTIME_DECORATORS (ACCESS_PRIMITIVE_SUPPORT | ACCESS_TO_SPACE_INVARIANT_SUPPORT)

#endif // SHARE_GC_SHARED_BARRIERSETCONFIG_HPP
@@ -383,10 +383,10 @@ void MemAllocator::mem_clear(HeapWord* mem) const {
oop MemAllocator::finish(HeapWord* mem) const {
assert(mem != NULL, "NULL object pointer");
if (UseBiasedLocking) {
oopDesc::set_mark_raw(mem, _klass->prototype_header());
oopDesc::set_mark(mem, _klass->prototype_header());
} else {
// May be bootstrapping
oopDesc::set_mark_raw(mem, markWord::prototype());
oopDesc::set_mark(mem, markWord::prototype());
}
// Need a release store to ensure array/class length, mark word, and
// object zeroing are visible before setting the klass non-NULL, for
@@ -47,7 +47,7 @@ inline void PreservedMarks::push_if_necessary(oop obj, markWord m) {
}

inline void PreservedMarks::init_forwarded_mark(oop obj) {
obj->init_mark_raw();
obj->init_mark();
}

inline PreservedMarks::PreservedMarks()
@@ -59,7 +59,7 @@ inline PreservedMarks::PreservedMarks()
0 /* max_cache_size */) { }

void PreservedMarks::OopAndMarkWord::set_mark() const {
_o->set_mark_raw(_m);
_o->set_mark(_m);
}

#endif // SHARE_GC_SHARED_PRESERVEDMARKS_INLINE_HPP
@@ -379,7 +379,7 @@ HeapWord* CompactibleSpace::forward(oop q, size_t size,
} else {
// if the object isn't moving we can just set the mark to the default
// mark and handle it specially later on.
q->init_mark_raw();
q->init_mark();
assert(q->forwardee() == NULL, "should be forwarded to NULL");
}

@@ -617,14 +617,14 @@ void ContiguousSpace::allocate_temporary_filler(int factor) {
// allocate uninitialized int array
typeArrayOop t = (typeArrayOop) allocate(size);
assert(t != NULL, "allocation should succeed");
t->set_mark_raw(markWord::prototype());
t->set_mark(markWord::prototype());
t->set_klass(Universe::intArrayKlassObj());
t->set_length((int)length);
} else {
assert(size == CollectedHeap::min_fill_size(),
"size for smallest fake object doesn't match");
instanceOop obj = (instanceOop) allocate(size);
obj->set_mark_raw(markWord::prototype());
obj->set_mark(markWord::prototype());
obj->set_klass_gap(0);
obj->set_klass(SystemDictionary::Object_klass());
}
@@ -117,7 +117,7 @@ class DeadSpacer : StackObj {
_allowed_deadspace_words -= dead_length;
CollectedHeap::fill_with_object(dead_start, dead_length);
oop obj = oop(dead_start);
obj->set_mark_raw(obj->mark_raw().set_marked());
obj->set_mark(obj->mark().set_marked());

assert(dead_length == (size_t)obj->size(), "bad filler object size");
log_develop_trace(gc, compaction)("Inserting object to dead space: " PTR_FORMAT ", " PTR_FORMAT ", " SIZE_FORMAT "b",
@@ -336,7 +336,7 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) {
// copy object and reinit its mark
assert(cur_obj != compaction_top, "everything in this pass should be moving");
Copy::aligned_conjoint_words(cur_obj, compaction_top, size);
oop(compaction_top)->init_mark_raw();
oop(compaction_top)->init_mark();
assert(oop(compaction_top)->klass() != NULL, "should have a class");

debug_only(prev_obj = cur_obj);
@@ -40,7 +40,7 @@ inline HeapWord* ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
// On this path, we can encounter the "marked" object, but with NULL
// fwdptr. That object is still not forwarded, and we need to return
// the object itself.
markWord mark = obj->mark_raw();
markWord mark = obj->mark();
if (mark.is_marked()) {
HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
if (fwdptr != NULL) {
@@ -55,7 +55,7 @@ inline oop ShenandoahForwarding::get_forwardee_mutator(oop obj) {
shenandoah_assert_correct(NULL, obj);
assert(Thread::current()->is_Java_thread(), "Must be a mutator thread");

markWord mark = obj->mark_raw();
markWord mark = obj->mark();
if (mark.is_marked()) {
HeapWord* fwdptr = (HeapWord*) mark.clear_lock_bits().to_pointer();
assert(fwdptr != NULL, "Forwarding pointer is never null here");
@@ -71,17 +71,17 @@ inline oop ShenandoahForwarding::get_forwardee(oop obj) {
}

inline bool ShenandoahForwarding::is_forwarded(oop obj) {
return obj->mark_raw().is_marked();
return obj->mark().is_marked();
}

inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
markWord old_mark = obj->mark_raw();
markWord old_mark = obj->mark();
if (old_mark.is_marked()) {
return oop(old_mark.clear_lock_bits().to_pointer());
}

markWord new_mark = markWord::encode_pointer_as_mark(update);
markWord prev_mark = obj->cas_set_mark_raw(new_mark, old_mark);
markWord prev_mark = obj->cas_set_mark(new_mark, old_mark, memory_order_conservative);
if (prev_mark == old_mark) {
return update;
} else {

0 comments on commit e63b90c

Please sign in to comment.