Skip to content

Commit

Permalink
8299072: java_lang_ref_Reference::clear_referent should be GC agnostic
Browse files Browse the repository at this point in the history
Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org>
Reviewed-by: dholmes, shade, kbarrett
  • Loading branch information
fisk and xmas92 committed Jan 4, 2023
1 parent ccbcea8 commit c32a34c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/classfile/javaClasses.hpp
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/classfile/javaClasses.inline.hpp
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/referenceProcessor.cpp
Expand Up @@ -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() {
Expand Down
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/z/zReferenceProcessor.cpp
Expand Up @@ -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) {
Expand Down

1 comment on commit c32a34c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.