< prev index next >

src/hotspot/share/classfile/moduleEntry.cpp

Print this page

@@ -41,10 +41,11 @@
 #include "runtime/safepoint.hpp"
 #include "utilities/events.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/hashtable.inline.hpp"
 #include "utilities/ostream.hpp"
+#include "utilities/quickSort.hpp"
 #include "utilities/resourceHash.hpp"
 
 ModuleEntry* ModuleEntryTable::_javabase_module = NULL;
 
 oop ModuleEntry::module() const { return _module.resolve(); }

@@ -395,11 +396,11 @@
   assert(ptr != NULL && *ptr != NULL, "must have been allocated");
   return *ptr;
 }
 
 // GrowableArrays cannot be directly archived, as they need to be expandable at runtime.
-// Write it out as an Array, and conver it back to GrowableArray at runtime.
+// Write it out as an Array, and convert it back to GrowableArray at runtime.
 Array<ModuleEntry*>* ModuleEntry::write_archived_entry_array(GrowableArray<ModuleEntry*>* array) {
   Array<ModuleEntry*>* archived_array = NULL;
   int length = (array == NULL) ? 0 : array->length();
   if (length > 0) {
     archived_array = MetaspaceShared::new_ro_array<ModuleEntry*>(length);

@@ -483,30 +484,30 @@
   if (loader_data->class_loader() != NULL) {
     java_lang_Module::set_loader(module_handle(), loader_data->class_loader());
   }
 }
 
-static int compare_module_by_name(ModuleEntry** a, ModuleEntry** b) {
-  return a[0]->name()->fast_compare(b[0]->name());
+static int compare_module_by_name(ModuleEntry* a, ModuleEntry* b) {
+  return a->name()->fast_compare(b->name());
 }
 
 Array<ModuleEntry*>* ModuleEntryTable::allocate_archived_entries() {
   Array<ModuleEntry*>* archived_modules = MetaspaceShared::new_rw_array<ModuleEntry*>(number_of_entries());
   int n = 0;
   for (int i = 0; i < table_size(); ++i) {
     for (ModuleEntry* m = bucket(i); m != NULL; m = m->next()) {
       archived_modules->at_put(n++, m);
     }
   }
-  if (n > 0) {
+  if (n > 1) {
     // Always allocate in the same order to produce deterministic archive.
-    qsort(archived_modules->adr_at(0), n, sizeof(ModuleEntry*), (_sort_Fn)compare_module_by_name);
+    QuickSort::sort(archived_modules->data(), n, (_sort_Fn)compare_module_by_name, true);
+  }
     for (int i = 0; i < n; i++) {
       archived_modules->at_put(i, archived_modules->at(i)->allocate_archived_entry());
       ArchivePtrMarker::mark_pointer((address*)archived_modules->adr_at(i));
     }
-  }
   return archived_modules;
 }
 
 void ModuleEntryTable::init_archived_entries(Array<ModuleEntry*>* archived_modules) {
   assert(DumpSharedSpaces, "dump time only");

@@ -526,11 +527,10 @@
 
 void ModuleEntryTable::load_archived_entries(ClassLoaderData* loader_data,
                                              Array<ModuleEntry*>* archived_modules) {
   assert(UseSharedSpaces, "runtime only");
 
-  MutexLocker m1(Module_lock);
   for (int i = 0; i < archived_modules->length(); i++) {
     ModuleEntry* archived_entry = archived_modules->at(i);
     archived_entry->load_from_archive(loader_data);
 
     unsigned int hash = compute_hash(archived_entry->name());
< prev index next >