8156156: Add module specific NMT MemoryType
authorhseigel
Wed, 01 Jun 2016 11:14:58 -0400
changeset 38733 2b65f4db449e
parent 38732 bb77e0dcc7e5
child 38734 69ced2325f58
8156156: Add module specific NMT MemoryType Summary: Change NMT tag for allocations for modules support to mtModule Reviewed-by: coleenp, lfoltan, gtriantafill
hotspot/src/share/vm/classfile/classLoader.cpp
hotspot/src/share/vm/classfile/javaClasses.cpp
hotspot/src/share/vm/classfile/moduleEntry.cpp
hotspot/src/share/vm/classfile/moduleEntry.hpp
hotspot/src/share/vm/classfile/modules.cpp
hotspot/src/share/vm/classfile/packageEntry.cpp
hotspot/src/share/vm/classfile/packageEntry.hpp
hotspot/src/share/vm/memory/allocation.hpp
hotspot/src/share/vm/services/nmtCommon.cpp
hotspot/src/share/vm/utilities/hashtable.cpp
hotspot/test/runtime/NMT/PrintNMTStatistics.java
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -657,7 +657,7 @@
   int num_of_entries = xpatch_args->length();
 
   // Set up the boot loader's xpatch_entries list
-  _xpatch_entries = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
+  _xpatch_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
 
   for (int i = 0; i < num_of_entries; i++) {
     const char* module_name = (xpatch_args->at(i))->module_name();
@@ -1069,9 +1069,9 @@
   char* begin_ptr = char_buf;
   char* end_ptr = strchr(begin_ptr, '\n');
   bool process_boot_modules = false;
-  _boot_modules_array = new (ResourceObj::C_HEAP, mtInternal)
+  _boot_modules_array = new (ResourceObj::C_HEAP, mtModule)
     GrowableArray<char*>(INITIAL_BOOT_MODULES_ARRAY_SIZE, true);
-  _platform_modules_array = new (ResourceObj::C_HEAP, mtInternal)
+  _platform_modules_array = new (ResourceObj::C_HEAP, mtModule)
     GrowableArray<char*>(INITIAL_PLATFORM_MODULES_ARRAY_SIZE, true);
   while (end_ptr != NULL && (end_ptr - char_buf) < buflen) {
     // Allocate a buffer from the C heap to be appended to the _boot_modules_array
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -848,7 +848,7 @@
     if (!ModuleEntryTable::javabase_defined()) {
       if (fixup_module_field_list() == NULL) {
         GrowableArray<Klass*>* list =
-          new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(500, true);
+          new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
         set_fixup_module_field_list(list);
       }
       k->class_loader_data()->inc_keep_alive();
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -113,7 +113,7 @@
   } else {
     if (_reads == NULL) {
       // Lazily create a module's reads list
-      _reads = new (ResourceObj::C_HEAP, mtClass)GrowableArray<ModuleEntry*>(MODULE_READS_SIZE, true);
+      _reads = new (ResourceObj::C_HEAP, mtModule)GrowableArray<ModuleEntry*>(MODULE_READS_SIZE, true);
     }
     _reads->append_if_missing(m);
   }
@@ -159,7 +159,7 @@
 }
 
 ModuleEntryTable::ModuleEntryTable(int table_size)
-  : Hashtable<Symbol*, mtClass>(table_size, sizeof(ModuleEntry)), _unnamed_module(NULL)
+  : Hashtable<Symbol*, mtModule>(table_size, sizeof(ModuleEntry)), _unnamed_module(NULL)
 {
 }
 
@@ -228,7 +228,7 @@
                                          Symbol* version, Symbol* location,
                                          ClassLoaderData* loader_data) {
   assert_locked_or_safepoint(Module_lock);
-  ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtClass);
+  ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtModule);
 
   // Initialize everything BasicHashtable would
   entry->set_next(NULL);
@@ -259,7 +259,7 @@
 
 void ModuleEntryTable::add_entry(int index, ModuleEntry* new_entry) {
   assert_locked_or_safepoint(Module_lock);
-  Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry);
+  Hashtable<Symbol*, mtModule>::add_entry(index, (HashtableEntry<Symbol*, mtModule>*)new_entry);
 }
 
 ModuleEntry* ModuleEntryTable::locked_create_entry_or_null(Handle module_handle,
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp	Wed Jun 01 11:14:58 2016 -0400
@@ -49,7 +49,7 @@
 //
 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
 // data structure.
-class ModuleEntry : public HashtableEntry<Symbol*, mtClass> {
+class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
 private:
   jobject _module;                     // java.lang.reflect.Module
   jobject _pd;                         // java.security.ProtectionDomain, cached
@@ -127,10 +127,10 @@
   }
 
   ModuleEntry* next() const {
-    return (ModuleEntry*)HashtableEntry<Symbol*, mtClass>::next();
+    return (ModuleEntry*)HashtableEntry<Symbol*, mtModule>::next();
   }
   ModuleEntry** next_addr() {
-    return (ModuleEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
+    return (ModuleEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
   }
 
   // iteration support for readability
@@ -166,7 +166,7 @@
 //
 // The ModuleEntryTable's lookup is lock free.
 //
-class ModuleEntryTable : public Hashtable<Symbol*, mtClass> {
+class ModuleEntryTable : public Hashtable<Symbol*, mtModule> {
   friend class VMStructs;
 public:
   enum Constants {
@@ -181,10 +181,10 @@
                          Symbol* location, ClassLoaderData* class_loader);
   void add_entry(int index, ModuleEntry* new_entry);
 
-  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
+  int entry_size() const { return BasicHashtable<mtModule>::entry_size(); }
 
   ModuleEntry** bucket_addr(int i) {
-    return (ModuleEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
+    return (ModuleEntry**)Hashtable<Symbol*, mtModule>::bucket_addr(i);
   }
 
   static unsigned int compute_hash(Symbol* name) { return ((name == NULL) ? 0 : (unsigned int)(name->identity_hash())); }
@@ -195,7 +195,7 @@
   ~ModuleEntryTable();
 
   ModuleEntry* bucket(int i) {
-    return (ModuleEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
+    return (ModuleEntry*)Hashtable<Symbol*, mtModule>::bucket(i);
   }
 
   // Create module in loader's module entry table, if already exists then
--- a/hotspot/src/share/vm/classfile/modules.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -145,7 +145,7 @@
 
   const char* home = Arguments::get_java_home();
   size_t len = strlen(home) + module_len + 32;
-  char* path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
+  char* path = NEW_C_HEAP_ARRAY(char, len, mtModule);
   jio_snprintf(path, len, "%s%cmodules%c%s", home, file_sep, file_sep, module_name);
   struct stat st;
   // See if exploded module path exists
--- a/hotspot/src/share/vm/classfile/packageEntry.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/packageEntry.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -57,7 +57,7 @@
     // Lazily create a package's qualified exports list.
     // Initial size is small, do not anticipate export lists to be large.
     _qualified_exports =
-      new (ResourceObj::C_HEAP, mtClass) GrowableArray<ModuleEntry*>(QUAL_EXP_SIZE, true);
+      new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleEntry*>(QUAL_EXP_SIZE, true);
   }
   _qualified_exports->append_if_missing(m);
 }
@@ -124,7 +124,7 @@
 }
 
 PackageEntryTable::PackageEntryTable(int table_size)
-  : Hashtable<Symbol*, mtClass>(table_size, sizeof(PackageEntry))
+  : Hashtable<Symbol*, mtModule>(table_size, sizeof(PackageEntry))
 {
 }
 
@@ -155,7 +155,7 @@
 
 PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, ModuleEntry* module) {
   assert_locked_or_safepoint(Module_lock);
-  PackageEntry* entry = (PackageEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtClass);
+  PackageEntry* entry = (PackageEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtModule);
 
   // Initialize everything BasicHashtable would
   entry->set_next(NULL);
@@ -178,7 +178,7 @@
 
 void PackageEntryTable::add_entry(int index, PackageEntry* new_entry) {
   assert_locked_or_safepoint(Module_lock);
-  Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry);
+  Hashtable<Symbol*, mtModule>::add_entry(index, (HashtableEntry<Symbol*, mtModule>*)new_entry);
 }
 
 // Create package in loader's package entry table and return the entry.
--- a/hotspot/src/share/vm/classfile/packageEntry.hpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/classfile/packageEntry.hpp	Wed Jun 01 11:14:58 2016 -0400
@@ -47,7 +47,7 @@
 //
 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
 // data structure.
-class PackageEntry : public HashtableEntry<Symbol*, mtClass> {
+class PackageEntry : public HashtableEntry<Symbol*, mtModule> {
 private:
   ModuleEntry* _module;
   // Used to indicate for packages with classes loaded by the boot loader that
@@ -129,11 +129,11 @@
   void add_qexport(ModuleEntry* m);
 
   PackageEntry* next() const {
-    return (PackageEntry*)HashtableEntry<Symbol*, mtClass>::next();
+    return (PackageEntry*)HashtableEntry<Symbol*, mtModule>::next();
   }
 
   PackageEntry** next_addr() {
-    return (PackageEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
+    return (PackageEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
   }
 
   // iteration of qualified exports
@@ -153,7 +153,7 @@
 // by a particular class loader.  Each package is represented as a PackageEntry node.
 // The PackageEntryTable's lookup is lock free.
 //
-class PackageEntryTable : public Hashtable<Symbol*, mtClass> {
+class PackageEntryTable : public Hashtable<Symbol*, mtModule> {
   friend class VMStructs;
 public:
   enum Constants {
@@ -164,10 +164,10 @@
   PackageEntry* new_entry(unsigned int hash, Symbol* name, ModuleEntry* module);
   void add_entry(int index, PackageEntry* new_entry);
 
-  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
+  int entry_size() const { return BasicHashtable<mtModule>::entry_size(); }
 
   PackageEntry** bucket_addr(int i) {
-    return (PackageEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
+    return (PackageEntry**)Hashtable<Symbol*, mtModule>::bucket_addr(i);
   }
 
   static unsigned int compute_hash(Symbol* name) { return (unsigned int)(name->identity_hash()); }
@@ -178,7 +178,7 @@
   ~PackageEntryTable();
 
   PackageEntry* bucket(int i) {
-    return (PackageEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
+    return (PackageEntry*)Hashtable<Symbol*, mtModule>::bucket(i);
   }
 
   // Create package in loader's package entry table and return the entry.
--- a/hotspot/src/share/vm/memory/allocation.hpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/memory/allocation.hpp	Wed Jun 01 11:14:58 2016 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -144,8 +144,9 @@
   mtTracing           = 0x0E,  // memory used for Tracing
   mtLogging           = 0x0F,  // memory for logging
   mtArguments         = 0x10,  // memory for argument processing
-  mtNone              = 0x11,  // undefined
-  mt_number_of_types  = 0x12   // number of memory types (mtDontTrack
+  mtModule            = 0x11,  // memory for module processing
+  mtNone              = 0x12,  // undefined
+  mt_number_of_types  = 0x13   // number of memory types (mtDontTrack
                                  // is not included as validate type)
 };
 
--- a/hotspot/src/share/vm/services/nmtCommon.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/services/nmtCommon.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
   "Tracing",
   "Logging",
   "Arguments",
+  "Module",
   "Unknown"
 };
 
--- a/hotspot/src/share/vm/utilities/hashtable.cpp	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/src/share/vm/utilities/hashtable.cpp	Wed Jun 01 11:14:58 2016 -0400
@@ -383,6 +383,7 @@
 template class BasicHashtable<mtSymbol>;
 template class BasicHashtable<mtCode>;
 template class BasicHashtable<mtInternal>;
+template class BasicHashtable<mtModule>;
 #if INCLUDE_TRACE
 template class Hashtable<Symbol*, mtTracing>;
 template class HashtableEntry<Symbol*, mtTracing>;
--- a/hotspot/test/runtime/NMT/PrintNMTStatistics.java	Wed Jun 01 07:44:43 2016 -0400
+++ b/hotspot/test/runtime/NMT/PrintNMTStatistics.java	Wed Jun 01 11:14:58 2016 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,9 @@
     output_detail.shouldNotContain("error");
     output_detail.shouldHaveExitValue(0);
 
+    // Make sure memory reserved for Module processing is recorded.
+    output_detail.shouldContain(" Module (reserved=");
+
     ProcessBuilder pb1 = ProcessTools.createJavaProcessBuilder(
       "-XX:+UnlockDiagnosticVMOptions",
       "-XX:+PrintNMTStatistics",