8212992: Change mirror accessor in Klass::verify_on() to use AS_NO_KEEPALIVE
authoreosterlund
Tue, 20 Nov 2018 10:08:19 +0100
changeset 52620 5f47b56cb867
parent 52619 5b4242996d8c
child 52621 f7309a1491d9
8212992: Change mirror accessor in Klass::verify_on() to use AS_NO_KEEPALIVE Reviewed-by: coleenp, pliden
src/hotspot/share/oops/klass.cpp
src/hotspot/share/oops/klass.hpp
src/hotspot/share/oops/oopHandle.hpp
src/hotspot/share/oops/oopHandle.inline.hpp
--- a/src/hotspot/share/oops/klass.cpp	Tue Nov 20 10:08:18 2018 +0100
+++ b/src/hotspot/share/oops/klass.cpp	Tue Nov 20 10:08:19 2018 +0100
@@ -59,6 +59,10 @@
   return _java_mirror.resolve();
 }
 
+oop Klass::java_mirror_no_keepalive() const {
+  return _java_mirror.peek();
+}
+
 bool Klass::is_cloneable() const {
   return _access_flags.is_cloneable_fast() ||
          is_subtype_of(SystemDictionary::Cloneable_klass());
@@ -746,8 +750,8 @@
     }
   }
 
-  if (java_mirror() != NULL) {
-    guarantee(oopDesc::is_oop(java_mirror()), "should be instance");
+  if (java_mirror_no_keepalive() != NULL) {
+    guarantee(oopDesc::is_oop(java_mirror_no_keepalive()), "should be instance");
   }
 }
 
--- a/src/hotspot/share/oops/klass.hpp	Tue Nov 20 10:08:18 2018 +0100
+++ b/src/hotspot/share/oops/klass.hpp	Tue Nov 20 10:08:19 2018 +0100
@@ -257,6 +257,7 @@
 
   // java mirror
   oop java_mirror() const;
+  oop java_mirror_no_keepalive() const;
   void set_java_mirror(Handle m);
 
   oop archived_java_mirror_raw() NOT_CDS_JAVA_HEAP_RETURN_(NULL); // no GC barrier
--- a/src/hotspot/share/oops/oopHandle.hpp	Tue Nov 20 10:08:18 2018 +0100
+++ b/src/hotspot/share/oops/oopHandle.hpp	Tue Nov 20 10:08:19 2018 +0100
@@ -44,6 +44,7 @@
   OopHandle(oop* w) : _obj(w) {}
 
   inline oop resolve() const;
+  inline oop peek() const;
 
   // Used only for removing handle.
   oop* ptr_raw() const { return _obj; }
--- a/src/hotspot/share/oops/oopHandle.inline.hpp	Tue Nov 20 10:08:18 2018 +0100
+++ b/src/hotspot/share/oops/oopHandle.inline.hpp	Tue Nov 20 10:08:19 2018 +0100
@@ -32,5 +32,8 @@
   return (_obj == NULL) ? (oop)NULL : NativeAccess<>::oop_load(_obj);
 }
 
+inline oop OopHandle::peek() const {
+  return (_obj == NULL) ? (oop)NULL : NativeAccess<AS_NO_KEEPALIVE>::oop_load(_obj);
+}
+
 #endif //  SHARE_VM_OOPS_OOPHANDLE_INLINE_HPP
-