8256516: Simplify clearing References
Provide and use explicit referent clearing instead of set to null. Reviewed-by: rkennke, shade, pliden, mchung
This commit is contained in:
parent
ba721f5f2f
commit
675d1d56e6
@ -875,7 +875,7 @@ class java_lang_ref_Reference: AllStatic {
|
||||
static inline oop weak_referent_no_keepalive(oop ref);
|
||||
static inline oop phantom_referent_no_keepalive(oop ref);
|
||||
static inline oop unknown_referent_no_keepalive(oop ref);
|
||||
static inline void set_referent_raw(oop ref, oop value);
|
||||
static inline void clear_referent(oop ref);
|
||||
static inline HeapWord* referent_addr_raw(oop ref);
|
||||
static inline oop next(oop ref);
|
||||
static inline void set_next(oop ref, oop value);
|
||||
|
@ -113,8 +113,8 @@ oop java_lang_ref_Reference::unknown_referent_no_keepalive(oop ref) {
|
||||
return ref->obj_field_access<ON_UNKNOWN_OOP_REF | AS_NO_KEEPALIVE>(_referent_offset);
|
||||
}
|
||||
|
||||
void java_lang_ref_Reference::set_referent_raw(oop ref, oop value) {
|
||||
ref->obj_field_put_raw(_referent_offset, value);
|
||||
void java_lang_ref_Reference::clear_referent(oop ref) {
|
||||
ref->obj_field_put_raw(_referent_offset, nullptr);
|
||||
}
|
||||
|
||||
HeapWord* java_lang_ref_Reference::referent_addr_raw(oop ref) {
|
||||
|
@ -260,8 +260,6 @@ void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
|
||||
assert(_current_discovered_addr && oopDesc::is_oop_or_null(discovered),
|
||||
"Expected an oop or NULL for discovered field at " PTR_FORMAT, p2i(discovered));
|
||||
_next_discovered = discovered;
|
||||
|
||||
_referent_addr = java_lang_ref_Reference::referent_addr_raw(_current_discovered);
|
||||
_referent = java_lang_ref_Reference::unknown_referent_no_keepalive(_current_discovered);
|
||||
assert(Universe::heap()->is_in_or_null(_referent),
|
||||
"Wrong oop found in java.lang.Reference object");
|
||||
@ -295,8 +293,17 @@ void DiscoveredListIterator::remove() {
|
||||
_refs_list.dec_length(1);
|
||||
}
|
||||
|
||||
void DiscoveredListIterator::make_referent_alive() {
|
||||
HeapWord* addr = java_lang_ref_Reference::referent_addr_raw(_current_discovered);
|
||||
if (UseCompressedOops) {
|
||||
_keep_alive->do_oop((narrowOop*)addr);
|
||||
} else {
|
||||
_keep_alive->do_oop((oop*)addr);
|
||||
}
|
||||
}
|
||||
|
||||
void DiscoveredListIterator::clear_referent() {
|
||||
RawAccess<>::oop_store(_referent_addr, oop(NULL));
|
||||
java_lang_ref_Reference::clear_referent(_current_discovered);
|
||||
}
|
||||
|
||||
void DiscoveredListIterator::enqueue() {
|
||||
|
@ -71,7 +71,6 @@ private:
|
||||
HeapWord* _current_discovered_addr;
|
||||
oop _next_discovered;
|
||||
|
||||
HeapWord* _referent_addr;
|
||||
oop _referent;
|
||||
|
||||
OopClosure* _keep_alive;
|
||||
@ -120,14 +119,8 @@ public:
|
||||
// Remove the current reference from the list
|
||||
void remove();
|
||||
|
||||
// Make the referent alive.
|
||||
inline void make_referent_alive() {
|
||||
if (UseCompressedOops) {
|
||||
_keep_alive->do_oop((narrowOop*)_referent_addr);
|
||||
} else {
|
||||
_keep_alive->do_oop((oop*)_referent_addr);
|
||||
}
|
||||
}
|
||||
// Apply the keep_alive function to the referent address.
|
||||
void make_referent_alive();
|
||||
|
||||
// Do enqueuing work, i.e. notifying the GC about the changed discovered pointers.
|
||||
void enqueue();
|
||||
|
@ -61,7 +61,6 @@ DiscoveredListIterator::DiscoveredListIterator(DiscoveredList& refs_list,
|
||||
_current_discovered(refs_list.head()),
|
||||
_current_discovered_addr(NULL),
|
||||
_next_discovered(NULL),
|
||||
_referent_addr(NULL),
|
||||
_referent(NULL),
|
||||
_keep_alive(keep_alive),
|
||||
_is_alive(is_alive),
|
||||
|
@ -88,8 +88,8 @@ static oop reference_referent(oop reference) {
|
||||
return CompressedOops::decode(heap_oop);
|
||||
}
|
||||
|
||||
static void reference_set_referent(oop reference, oop referent) {
|
||||
java_lang_ref_Reference::set_referent_raw(reference, referent);
|
||||
static void reference_clear_referent(oop reference) {
|
||||
java_lang_ref_Reference::clear_referent(reference);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -316,7 +316,7 @@ void ShenandoahReferenceProcessor::make_inactive(oop reference, ReferenceType ty
|
||||
reference_set_next(reference, reference);
|
||||
} else {
|
||||
// Clear referent
|
||||
reference_set_referent(reference, NULL);
|
||||
reference_clear_referent(reference);
|
||||
}
|
||||
}
|
||||
|
||||
@ -590,4 +590,4 @@ void ShenandoahReferenceProcessor::collect_statistics() {
|
||||
discovered[REF_SOFT], discovered[REF_WEAK], discovered[REF_FINAL], discovered[REF_PHANTOM]);
|
||||
log_info(gc,ref)("Enqueued references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT,
|
||||
enqueued[REF_SOFT], enqueued[REF_WEAK], enqueued[REF_FINAL], enqueued[REF_PHANTOM]);
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ static oop reference_referent(oop reference) {
|
||||
return Atomic::load(reference_referent_addr(reference));
|
||||
}
|
||||
|
||||
static void reference_set_referent(oop reference, oop referent) {
|
||||
java_lang_ref_Reference::set_referent_raw(reference, referent);
|
||||
static void reference_clear_referent(oop reference) {
|
||||
java_lang_ref_Reference::clear_referent(reference);
|
||||
}
|
||||
|
||||
static oop* reference_discovered_addr(oop reference) {
|
||||
@ -226,7 +226,7 @@ void ZReferenceProcessor::make_inactive(oop reference, ReferenceType type) const
|
||||
reference_set_next(reference, reference);
|
||||
} else {
|
||||
// Clear referent
|
||||
reference_set_referent(reference, NULL);
|
||||
reference_clear_referent(reference);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user