mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 13:54:38 +02:00
6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
This commit is contained in:
parent
8e42425c92
commit
a39b17624a
315 changed files with 7245 additions and 1477 deletions
|
@ -64,9 +64,9 @@ Symbol* SymbolTable::allocate_symbol(const u1* name, int len, bool c_heap, TRAPS
|
|||
void SymbolTable::initialize_symbols(int arena_alloc_size) {
|
||||
// Initialize the arena for global symbols, size passed in depends on CDS.
|
||||
if (arena_alloc_size == 0) {
|
||||
_arena = new Arena();
|
||||
_arena = new (mtSymbol) Arena();
|
||||
} else {
|
||||
_arena = new Arena(arena_alloc_size);
|
||||
_arena = new (mtSymbol) Arena(arena_alloc_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ void SymbolTable::initialize_symbols(int arena_alloc_size) {
|
|||
void SymbolTable::symbols_do(SymbolClosure *cl) {
|
||||
const int n = the_table()->table_size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (HashtableEntry<Symbol*>* p = the_table()->bucket(i);
|
||||
for (HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
|
||||
p != NULL;
|
||||
p = p->next()) {
|
||||
cl->do_symbol(p->literal_addr());
|
||||
|
@ -92,8 +92,8 @@ void SymbolTable::unlink() {
|
|||
int total = 0;
|
||||
size_t memory_total = 0;
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<Symbol*>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<Symbol*>* entry = the_table()->bucket(i);
|
||||
HashtableEntry<Symbol*, mtSymbol>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<Symbol*, mtSymbol>* entry = the_table()->bucket(i);
|
||||
while (entry != NULL) {
|
||||
// Shared entries are normally at the end of the bucket and if we run into
|
||||
// a shared entry, then there is nothing more to remove. However, if we
|
||||
|
@ -117,7 +117,7 @@ void SymbolTable::unlink() {
|
|||
p = entry->next_addr();
|
||||
}
|
||||
// get next entry
|
||||
entry = (HashtableEntry<Symbol*>*)HashtableEntry<Symbol*>::make_ptr(*p);
|
||||
entry = (HashtableEntry<Symbol*, mtSymbol>*)HashtableEntry<Symbol*, mtSymbol>::make_ptr(*p);
|
||||
}
|
||||
}
|
||||
symbols_removed += removed;
|
||||
|
@ -164,7 +164,7 @@ void SymbolTable::rehash_table() {
|
|||
Symbol* SymbolTable::lookup(int index, const char* name,
|
||||
int len, unsigned int hash) {
|
||||
int count = 0;
|
||||
for (HashtableEntry<Symbol*>* e = bucket(index); e != NULL; e = e->next()) {
|
||||
for (HashtableEntry<Symbol*, mtSymbol>* e = bucket(index); e != NULL; e = e->next()) {
|
||||
count++; // count all entries in this bucket, not just ones with same hash
|
||||
if (e->hash() == hash) {
|
||||
Symbol* sym = e->literal();
|
||||
|
@ -176,7 +176,7 @@ Symbol* SymbolTable::lookup(int index, const char* name,
|
|||
}
|
||||
}
|
||||
// If the bucket size is too deep check if this hash code is insufficient.
|
||||
if (count >= BasicHashtable::rehash_count && !needs_rehashing()) {
|
||||
if (count >= BasicHashtable<mtSymbol>::rehash_count && !needs_rehashing()) {
|
||||
_needs_rehashing = check_rehash_table(count);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -268,7 +268,7 @@ Symbol** SymbolTable::lookup_symbol_addr(Symbol* sym){
|
|||
unsigned int hash = hash_symbol((char*)sym->bytes(), sym->utf8_length());
|
||||
int index = the_table()->hash_to_index(hash);
|
||||
|
||||
for (HashtableEntry<Symbol*>* e = the_table()->bucket(index); e != NULL; e = e->next()) {
|
||||
for (HashtableEntry<Symbol*, mtSymbol>* e = the_table()->bucket(index); e != NULL; e = e->next()) {
|
||||
if (e->hash() == hash) {
|
||||
Symbol* literal_sym = e->literal();
|
||||
if (sym == literal_sym) {
|
||||
|
@ -387,7 +387,7 @@ Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len,
|
|||
Symbol* sym = allocate_symbol(name, len, c_heap, CHECK_NULL);
|
||||
assert(sym->equals((char*)name, len), "symbol must be properly initialized");
|
||||
|
||||
HashtableEntry<Symbol*>* entry = new_entry(hashValue, sym);
|
||||
HashtableEntry<Symbol*, mtSymbol>* entry = new_entry(hashValue, sym);
|
||||
add_entry(index, entry);
|
||||
return sym;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ bool SymbolTable::basic_add(Handle class_loader, constantPoolHandle cp,
|
|||
bool c_heap = class_loader() != NULL;
|
||||
Symbol* sym = allocate_symbol((const u1*)names[i], lengths[i], c_heap, CHECK_(false));
|
||||
assert(sym->equals(names[i], lengths[i]), "symbol must be properly initialized"); // why wouldn't it be???
|
||||
HashtableEntry<Symbol*>* entry = new_entry(hashValue, sym);
|
||||
HashtableEntry<Symbol*, mtSymbol>* entry = new_entry(hashValue, sym);
|
||||
add_entry(index, entry);
|
||||
cp->symbol_at_put(cp_indices[i], sym);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ bool SymbolTable::basic_add(Handle class_loader, constantPoolHandle cp,
|
|||
|
||||
void SymbolTable::verify() {
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<Symbol*>* p = the_table()->bucket(i);
|
||||
HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
|
||||
for ( ; p != NULL; p = p->next()) {
|
||||
Symbol* s = (Symbol*)(p->literal());
|
||||
guarantee(s != NULL, "symbol is NULL");
|
||||
|
@ -462,7 +462,7 @@ void SymbolTable::dump(outputStream* st) {
|
|||
NumberSeq summary;
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
int count = 0;
|
||||
for (HashtableEntry<Symbol*>* e = the_table()->bucket(i);
|
||||
for (HashtableEntry<Symbol*, mtSymbol>* e = the_table()->bucket(i);
|
||||
e != NULL; e = e->next()) {
|
||||
count++;
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ void SymbolTable::print_histogram() {
|
|||
int memory_total = 0;
|
||||
int count = 0;
|
||||
for (i = 0; i < the_table()->table_size(); i++) {
|
||||
HashtableEntry<Symbol*>* p = the_table()->bucket(i);
|
||||
HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
|
||||
for ( ; p != NULL; p = p->next()) {
|
||||
memory_total += p->literal()->object_size();
|
||||
count++;
|
||||
|
@ -560,15 +560,15 @@ void SymbolTable::print_histogram() {
|
|||
|
||||
void SymbolTable::print() {
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<Symbol*>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<Symbol*>* entry = the_table()->bucket(i);
|
||||
HashtableEntry<Symbol*, mtSymbol>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<Symbol*, mtSymbol>* entry = the_table()->bucket(i);
|
||||
if (entry != NULL) {
|
||||
while (entry != NULL) {
|
||||
tty->print(PTR_FORMAT " ", entry->literal());
|
||||
entry->literal()->print();
|
||||
tty->print(" %d", entry->literal()->refcount());
|
||||
p = entry->next_addr();
|
||||
entry = (HashtableEntry<Symbol*>*)HashtableEntry<Symbol*>::make_ptr(*p);
|
||||
entry = (HashtableEntry<Symbol*, mtSymbol>*)HashtableEntry<Symbol*, mtSymbol>::make_ptr(*p);
|
||||
}
|
||||
tty->cr();
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ unsigned int StringTable::hash_string(const jchar* s, int len) {
|
|||
oop StringTable::lookup(int index, jchar* name,
|
||||
int len, unsigned int hash) {
|
||||
int count = 0;
|
||||
for (HashtableEntry<oop>* l = bucket(index); l != NULL; l = l->next()) {
|
||||
for (HashtableEntry<oop, mtSymbol>* l = bucket(index); l != NULL; l = l->next()) {
|
||||
count++;
|
||||
if (l->hash() == hash) {
|
||||
if (java_lang_String::equals(l->literal(), name, len)) {
|
||||
|
@ -640,7 +640,7 @@ oop StringTable::lookup(int index, jchar* name,
|
|||
}
|
||||
}
|
||||
// If the bucket size is too deep check if this hash code is insufficient.
|
||||
if (count >= BasicHashtable::rehash_count && !needs_rehashing()) {
|
||||
if (count >= BasicHashtable<mtSymbol>::rehash_count && !needs_rehashing()) {
|
||||
_needs_rehashing = check_rehash_table(count);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -676,7 +676,7 @@ oop StringTable::basic_add(int index_arg, Handle string, jchar* name,
|
|||
return test;
|
||||
}
|
||||
|
||||
HashtableEntry<oop>* entry = new_entry(hashValue, string());
|
||||
HashtableEntry<oop, mtSymbol>* entry = new_entry(hashValue, string());
|
||||
add_entry(index, entry);
|
||||
return string();
|
||||
}
|
||||
|
@ -761,8 +761,8 @@ void StringTable::unlink(BoolObjectClosure* is_alive) {
|
|||
// entries at a safepoint.
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<oop>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<oop>* entry = the_table()->bucket(i);
|
||||
HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i);
|
||||
while (entry != NULL) {
|
||||
// Shared entries are normally at the end of the bucket and if we run into
|
||||
// a shared entry, then there is nothing more to remove. However, if we
|
||||
|
@ -778,15 +778,15 @@ void StringTable::unlink(BoolObjectClosure* is_alive) {
|
|||
*p = entry->next();
|
||||
the_table()->free_entry(entry);
|
||||
}
|
||||
entry = (HashtableEntry<oop>*)HashtableEntry<oop>::make_ptr(*p);
|
||||
entry = (HashtableEntry<oop, mtSymbol>*)HashtableEntry<oop, mtSymbol>::make_ptr(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StringTable::oops_do(OopClosure* f) {
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<oop>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<oop>* entry = the_table()->bucket(i);
|
||||
HashtableEntry<oop, mtSymbol>** p = the_table()->bucket_addr(i);
|
||||
HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i);
|
||||
while (entry != NULL) {
|
||||
f->do_oop((oop*)entry->literal_addr());
|
||||
|
||||
|
@ -798,14 +798,14 @@ void StringTable::oops_do(OopClosure* f) {
|
|||
} else {
|
||||
p = entry->next_addr();
|
||||
}
|
||||
entry = (HashtableEntry<oop>*)HashtableEntry<oop>::make_ptr(*p);
|
||||
entry = (HashtableEntry<oop, mtSymbol>*)HashtableEntry<oop, mtSymbol>::make_ptr(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StringTable::verify() {
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<oop>* p = the_table()->bucket(i);
|
||||
HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i);
|
||||
for ( ; p != NULL; p = p->next()) {
|
||||
oop s = p->literal();
|
||||
guarantee(s != NULL, "interned string is NULL");
|
||||
|
@ -821,7 +821,7 @@ void StringTable::verify() {
|
|||
void StringTable::dump(outputStream* st) {
|
||||
NumberSeq summary;
|
||||
for (int i = 0; i < the_table()->table_size(); ++i) {
|
||||
HashtableEntry<oop>* p = the_table()->bucket(i);
|
||||
HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i);
|
||||
int count = 0;
|
||||
for ( ; p != NULL; p = p->next()) {
|
||||
count++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue