hotspot/src/share/vm/classfile/classLoaderData.cpp
changeset 47095 9d21da6fe729
parent 46961 c9094b1e5f87
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp	Tue Aug 29 12:17:02 2017 +0200
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp	Wed Aug 30 07:18:02 2017 -0400
@@ -75,6 +75,9 @@
 #include "utilities/growableArray.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc/g1/g1SATBCardTableModRefBS.hpp"
+#endif // INCLUDE_ALL_GCS
 #if INCLUDE_TRACE
 #include "trace/tracing.hpp"
 #endif
@@ -764,6 +767,25 @@
   return OopHandle(_handles.add(h()));
 }
 
+void ClassLoaderData::remove_handle(OopHandle h) {
+  oop* ptr = h.ptr_raw();
+  if (ptr != NULL) {
+    assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
+#if INCLUDE_ALL_GCS
+    // This barrier is used by G1 to remember the old oop values, so
+    // that we don't forget any objects that were live at the snapshot at
+    // the beginning.
+    if (UseG1GC) {
+      oop obj = *ptr;
+      if (obj != NULL) {
+        G1SATBCardTableModRefBS::enqueue(obj);
+      }
+    }
+#endif
+    *ptr = NULL;
+  }
+}
+
 void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) {
   MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
   if (dest.resolve() != NULL) {