8156156: Add module specific NMT MemoryType

Change NMT tag for allocations for modules support to mtModule

Reviewed-by: coleenp, lfoltan, gtriantafill
This commit is contained in:
Harold Seigel 2016-06-01 11:14:58 -04:00
parent 737a2a5946
commit 1fae073d9c
11 changed files with 38 additions and 32 deletions

@ -657,7 +657,7 @@ void ClassLoader::setup_xpatch_entries() {
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 @@ void ClassLoader::initialize_module_loader_map(JImageFile* jimage) {
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

@ -848,7 +848,7 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
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();

@ -113,7 +113,7 @@ void ModuleEntry::add_read(ModuleEntry* m) {
} 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 @@ void ModuleEntry::delete_reads() {
}
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 @@ ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle
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 @@ ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle
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,

@ -49,7 +49,7 @@ class ModuleClosure;
//
// 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 @@ public:
}
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 @@ class ModuleClosure: public StackObj {
//
// 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 @@ private:
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 @@ public:
~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

@ -145,7 +145,7 @@ static void add_to_exploded_build_list(char *module_name, TRAPS) {
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

@ -57,7 +57,7 @@ void PackageEntry::add_qexport(ModuleEntry* m) {
// 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 @@ void PackageEntry::delete_qualified_exports() {
}
PackageEntryTable::PackageEntryTable(int table_size)
: Hashtable<Symbol*, mtClass>(table_size, sizeof(PackageEntry))
: Hashtable<Symbol*, mtModule>(table_size, sizeof(PackageEntry))
{
}
@ -155,7 +155,7 @@ PackageEntryTable::~PackageEntryTable() {
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 @@ PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, Modu
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.

@ -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 @@ public:
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 @@ public:
// 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 @@ private:
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 @@ public:
~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.

@ -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 @@ enum MemoryType {
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)
};

@ -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 @@ const char* NMTUtil::_memory_type_names[] = {
"Tracing",
"Logging",
"Arguments",
"Module",
"Unknown"
};

@ -383,6 +383,7 @@ template class BasicHashtable<mtClassShared>;
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>;

@ -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 @@ public class PrintNMTStatistics {
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",