Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8250589: Move Universe::_reference_pending_list into OopHandle
Browse files Browse the repository at this point in the history
Use synchronization to reference the _reference_pending_list with OopHandle

Reviewed-by: shade, kbarrett, dholmes, eosterlund
  • Loading branch information
coleenp committed Jul 28, 2020
1 parent c993ee4 commit 695a785
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/hotspot/share/memory/universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ OopHandle Universe::_null_ptr_exception_instance;
OopHandle Universe::_arithmetic_exception_instance;
OopHandle Universe::_virtual_machine_error_instance;

oop Universe::_reference_pending_list = NULL;
OopHandle Universe::_reference_pending_list;

Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
LatestMethodCache* Universe::_finalizer_register_cache = NULL;
Expand Down Expand Up @@ -225,7 +225,6 @@ void Universe::basic_type_classes_do(KlassClosure *closure) {

void Universe::oops_do(OopClosure* f) {

f->do_oop(&_reference_pending_list);
ThreadsSMRSupport::exiting_threads_oops_do(f);
}

Expand Down Expand Up @@ -392,6 +391,9 @@ void Universe::genesis(TRAPS) {
_the_null_sentinel = OopHandle(vm_global(), tns());
}

// Create a handle for reference_pending_list
_reference_pending_list = OopHandle(vm_global(), NULL);

// Maybe this could be lifted up now that object array can be initialized
// during the bootstrapping.

Expand Down Expand Up @@ -512,22 +514,22 @@ oop Universe::reference_pending_list() {
} else {
assert_pll_ownership();
}
return _reference_pending_list;
return _reference_pending_list.resolve();
}

void Universe::clear_reference_pending_list() {
assert_pll_ownership();
_reference_pending_list = NULL;
_reference_pending_list.replace(NULL);
}

bool Universe::has_reference_pending_list() {
assert_pll_ownership();
return _reference_pending_list != NULL;
return _reference_pending_list.peek() != NULL;
}

oop Universe::swap_reference_pending_list(oop list) {
assert_pll_locked(is_locked);
return Atomic::xchg(&_reference_pending_list, list);
return _reference_pending_list.xchg(list);
}

#undef assert_pll_locked
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/memory/universe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Universe: AllStatic {
static OopHandle _virtual_machine_error_instance; // preallocated exception object

// References waiting to be transferred to the ReferenceHandler
static oop _reference_pending_list;
static OopHandle _reference_pending_list;

// The particular choice of collected heap.
static CollectedHeap* _collectedHeap;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/oops/oopHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class OopHandle {

inline void replace(oop obj);

inline oop xchg(oop new_value);

// Used only for removing handle.
oop* ptr_raw() const { return _obj; }
};
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/oops/oopHandle.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ inline void OopHandle::replace(oop obj) {
NativeAccess<>::oop_store(ptr, obj);
}

inline oop OopHandle::xchg(oop new_value) {
return NativeAccess<MO_SEQ_CST>::oop_atomic_xchg(_obj, new_value);
}

#endif // SHARE_OOPS_OOPHANDLE_INLINE_HPP

0 comments on commit 695a785

Please sign in to comment.