< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page

@@ -1205,14 +1205,10 @@
   };
 #endif
 
 public:
   static void copy_and_compact() {
-    // We should no longer allocate anything from the metaspace, so that
-    // we can have a stable set of MetaspaceObjs to work with.
-    Metaspace::freeze();
-
     ResourceMark rm;
     SortedSymbolClosure the_ssc; // StackObj
     _ssc = &the_ssc;
 
     tty->print_cr("Scanning all metaspace objects ... ");

@@ -1355,10 +1351,18 @@
 
   return buckets_top;
 }
 
 void VM_PopulateDumpSharedSpace::doit() {
+  // We should no longer allocate anything from the metaspace, so that:
+  //
+  // (1) Metaspace::allocate might trigger GC if we have run out of
+  //     committed metaspace, but we can't GC because we're running
+  //     in the VM thread.
+  // (2) ArchiveCompactor needs to work with a stable set of MetaspaceObjs.
+  Metaspace::freeze();
+
   Thread* THREAD = VMThread::vm_thread();
 
   FileMapInfo::check_nonempty_dir_in_shared_path_table();
 
   NOT_PRODUCT(SystemDictionary::verify();)

@@ -1419,12 +1423,10 @@
 
   // We don't support archiving unsafe anonymous classes. Verify that they are not stored in
   // any dictionaries.
   NOT_PRODUCT(assert_no_unsafe_anonymous_classes_in_dictionaries());
 
-  SystemDictionaryShared::finalize_verification_constraints();
-
   ArchiveCompactor::initialize();
   ArchiveCompactor::copy_and_compact();
 
   dump_symbols();
 
< prev index next >