8210321: Create NO_KEEPALIVE CLD holder accessor
authoreosterlund
Mon, 10 Sep 2018 13:07:42 +0200
changeset 51682 a30461a359f5
parent 51681 72bdaf11dd6a
child 51683 9d494115eda4
8210321: Create NO_KEEPALIVE CLD holder accessor Reviewed-by: coleenp, kbarrett
src/hotspot/share/classfile/classLoaderData.cpp
src/hotspot/share/classfile/classLoaderData.hpp
src/hotspot/share/classfile/classLoaderData.inline.hpp
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Mon Sep 10 13:07:42 2018 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Mon Sep 10 13:07:42 2018 +0200
@@ -671,6 +671,15 @@
   }
 }
 
+// Let the GC read the holder without keeping it alive.
+oop ClassLoaderData::holder_no_keepalive() const {
+  if (!_holder.is_null()) {  // NULL class_loader
+    return _holder.peek();
+  } else {
+    return NULL;
+  }
+}
+
 // Unloading support
 bool ClassLoaderData::is_alive() const {
   bool alive = keep_alive()         // null class loader and incomplete unsafe anonymous klasses.
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Mon Sep 10 13:07:42 2018 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Mon Sep 10 13:07:42 2018 +0200
@@ -307,8 +307,9 @@
   void accumulate_modified_oops()        { if (has_modified_oops()) _accumulated_modified_oops = true; }
   void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
   bool has_accumulated_modified_oops()   { return _accumulated_modified_oops; }
+  oop holder_no_keepalive() const;
+
  private:
-
   void unload();
   bool keep_alive() const       { return _keep_alive > 0; }
 
--- a/src/hotspot/share/classfile/classLoaderData.inline.hpp	Mon Sep 10 13:07:42 2018 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.inline.hpp	Mon Sep 10 13:07:42 2018 +0200
@@ -34,7 +34,7 @@
 
 inline oop ClassLoaderData::class_loader() const {
   assert(!_unloading, "This oop is not available to unloading class loader data");
-  assert(_holder.is_null() || _holder.peek() != NULL , "This class loader data holder must be alive");
+  assert(_holder.is_null() || holder_no_keepalive() != NULL , "This class loader data holder must be alive");
   return _class_loader.resolve();
 }