8204474: Have instanceRefKlass use HeapAccess when loading the referent
Reviewed-by: stefank, eosterlund
--- a/src/hotspot/share/oops/instanceRefKlass.inline.hpp Wed Jun 06 23:36:08 2018 +0300
+++ b/src/hotspot/share/oops/instanceRefKlass.inline.hpp Thu Jun 07 21:57:17 2018 +0200
@@ -53,13 +53,20 @@
}
}
+static inline oop load_referent(oop obj, ReferenceType type) {
+ if (type == REF_PHANTOM) {
+ return HeapAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(java_lang_ref_Reference::referent_addr_raw(obj));
+ } else {
+ return HeapAccess<ON_WEAK_OOP_REF | AS_NO_KEEPALIVE>::oop_load(java_lang_ref_Reference::referent_addr_raw(obj));
+ }
+}
+
template <typename T, class OopClosureType>
bool InstanceRefKlass::try_discover(oop obj, ReferenceType type, OopClosureType* closure) {
ReferenceDiscoverer* rd = closure->ref_discoverer();
if (rd != NULL) {
- T referent_oop = RawAccess<>::oop_load((T*)java_lang_ref_Reference::referent_addr_raw(obj));
- if (!CompressedOops::is_null(referent_oop)) {
- oop referent = CompressedOops::decode_not_null(referent_oop);
+ oop referent = load_referent(obj, type);
+ if (referent != NULL) {
if (!referent->is_gc_marked()) {
// Only try to discover if not yet marked.
return rd->discover_reference(obj, type);
@@ -179,9 +186,9 @@
log_develop_trace(gc, ref)("InstanceRefKlass %s for obj " PTR_FORMAT, s, p2i(obj));
log_develop_trace(gc, ref)(" referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
- p2i(referent_addr), p2i(referent_addr ? RawAccess<>::oop_load(referent_addr) : (oop)NULL));
+ p2i(referent_addr), p2i((oop)HeapAccess<ON_UNKNOWN_OOP_REF | AS_NO_KEEPALIVE>::oop_load_at(obj, java_lang_ref_Reference::referent_offset)));
log_develop_trace(gc, ref)(" discovered_addr/* " PTR_FORMAT " / " PTR_FORMAT,
- p2i(discovered_addr), p2i(discovered_addr ? RawAccess<>::oop_load(discovered_addr) : (oop)NULL));
+ p2i(discovered_addr), p2i((oop)HeapAccess<AS_NO_KEEPALIVE>::oop_load(discovered_addr)));
}
#endif