< prev index next >

src/hotspot/share/classfile/classLoaderDataGraph.cpp

Print this page

        

@@ -36,32 +36,22 @@
 #include "memory/metaspace.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/mutex.hpp"
-#include "runtime/orderAccess.hpp"
 #include "runtime/safepoint.hpp"
 #include "runtime/safepointVerifiers.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
 
 volatile size_t ClassLoaderDataGraph::_num_array_classes = 0;
 volatile size_t ClassLoaderDataGraph::_num_instance_classes = 0;
 
 void ClassLoaderDataGraph::clear_claimed_marks() {
-  // The claimed marks of the CLDs in the ClassLoaderDataGraph are cleared
-  // outside a safepoint and without locking the ClassLoaderDataGraph_lock.
-  // This is required to avoid a deadlock between concurrent GC threads and safepointing.
-  //
-  // We need to make sure that the CLD contents are fully visible to the
-  // reader thread. This is accomplished by acquire/release of the _head,
-  // and is sufficient.
-  //
-  // Any ClassLoaderData added after or during walking the list are prepended to
-  // _head. Their claim mark need not be handled here.
-  for (ClassLoaderData* cld = OrderAccess::load_acquire(&_head); cld != NULL; cld = cld->next()) {
+  assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock);
+  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
     cld->clear_claim();
   }
 }
 
 // Class iterator used by the compiler.  It gets some number of classes at

@@ -177,11 +167,11 @@
   MetadataOnStackMark md_on_stack(walk_all_metadata, /*redefinition_walk*/false);
   clean_deallocate_lists(walk_all_metadata);
 }
 
 // GC root of class loader data created.
-ClassLoaderData* volatile ClassLoaderDataGraph::_head = NULL;
+ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL;
 ClassLoaderData* ClassLoaderDataGraph::_saved_unloading = NULL;
 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL;
 
 bool ClassLoaderDataGraph::_should_purge = false;

@@ -213,11 +203,11 @@
 
   cld = new ClassLoaderData(loader, is_unsafe_anonymous);
 
   // First install the new CLD to the Graph.
   cld->set_next(_head);
-  OrderAccess::release_store(&_head, cld);
+  _head = cld;
 
   // Next associate with the class_loader.
   if (!is_unsafe_anonymous) {
     // Use OrderAccess, since readers need to get the loader_data only after
     // it's added to the Graph
< prev index next >