8299072: java_lang_ref_Reference::clear_referent should be GC agnostic

Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org>
Reviewed-by: dholmes, shade, kbarrett
This commit is contained in:
Erik Österlund 2023-01-04 14:49:44 +00:00
parent ccbcea830d
commit c32a34c2e5
5 changed files with 8 additions and 3 deletions

@ -952,6 +952,7 @@ class java_lang_ref_Reference: AllStatic {
static inline oop phantom_referent_no_keepalive(oop ref);
static inline oop unknown_referent_no_keepalive(oop ref);
static inline void clear_referent(oop ref);
static inline void clear_referent_raw(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);

@ -152,6 +152,10 @@ oop java_lang_ref_Reference::unknown_referent_no_keepalive(oop ref) {
}
void java_lang_ref_Reference::clear_referent(oop ref) {
HeapAccess<ON_UNKNOWN_OOP_REF | AS_NO_KEEPALIVE>::oop_store_at(ref, _referent_offset, nullptr);
}
void java_lang_ref_Reference::clear_referent_raw(oop ref) {
ref->obj_field_put_raw(_referent_offset, nullptr);
}

@ -282,7 +282,7 @@ void DiscoveredListIterator::make_referent_alive() {
}
void DiscoveredListIterator::clear_referent() {
java_lang_ref_Reference::clear_referent(_current_discovered);
java_lang_ref_Reference::clear_referent_raw(_current_discovered);
}
void DiscoveredListIterator::enqueue() {

@ -90,7 +90,7 @@ static oop reference_referent(oop reference) {
}
static void reference_clear_referent(oop reference) {
java_lang_ref_Reference::clear_referent(reference);
java_lang_ref_Reference::clear_referent_raw(reference);
}
template <typename T>

@ -72,7 +72,7 @@ static oop reference_referent(oop reference) {
}
static void reference_clear_referent(oop reference) {
java_lang_ref_Reference::clear_referent(reference);
java_lang_ref_Reference::clear_referent_raw(reference);
}
static oop* reference_discovered_addr(oop reference) {