8260630: Templatize literal_size
8260629: Remove explicit instantiation of Hashtable with oop value Reviewed-by: pliden, tschatzl, coleenp
This commit is contained in:
parent
6b24e98c42
commit
67a34daf68
@ -110,22 +110,18 @@ template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
|
|||||||
_buckets = NULL;
|
_buckets = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For oops and Strings the size of the literal is interesting. For other types, nobody cares.
|
// Default overload, for types that are uninteresting.
|
||||||
static int literal_size(ConstantPool*) { return 0; }
|
template<typename T> static int literal_size(T) { return 0; }
|
||||||
static int literal_size(Klass*) { return 0; }
|
|
||||||
static int literal_size(nmethod*) { return 0; }
|
|
||||||
|
|
||||||
static int literal_size(Symbol *symbol) {
|
static int literal_size(Symbol *symbol) {
|
||||||
return symbol->size() * HeapWordSize;
|
return symbol->size() * HeapWordSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int literal_size(oop obj) {
|
static int literal_size(oop obj) {
|
||||||
// NOTE: this would over-count if (pre-JDK8) java_lang_Class::has_offset_field() is true,
|
|
||||||
// and the String.value array is shared by several Strings. However, starting from JDK8,
|
|
||||||
// the String.value array is not shared anymore.
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (obj->klass() == SystemDictionary::String_klass()) {
|
} else if (obj->klass() == SystemDictionary::String_klass()) {
|
||||||
|
// This may overcount if String.value arrays are shared.
|
||||||
return (obj->size() + java_lang_String::value(obj)->size()) * HeapWordSize;
|
return (obj->size() + java_lang_String::value(obj)->size()) * HeapWordSize;
|
||||||
} else {
|
} else {
|
||||||
return obj->size();
|
return obj->size();
|
||||||
@ -235,10 +231,6 @@ template <class T, MEMFLAGS F> TableStatistics Hashtable<T, F>::statistics_calcu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dump footprint and bucket length statistics
|
// Dump footprint and bucket length statistics
|
||||||
//
|
|
||||||
// Note: if you create a new subclass of Hashtable<MyNewType, F>, you will need to
|
|
||||||
// add a new function static int literal_size(MyNewType lit)
|
|
||||||
// because I can't get template <class T> int literal_size(T) to pick the specializations for Symbol and oop.
|
|
||||||
template <class T, MEMFLAGS F> void Hashtable<T, F>::print_table_statistics(outputStream* st,
|
template <class T, MEMFLAGS F> void Hashtable<T, F>::print_table_statistics(outputStream* st,
|
||||||
const char *table_name,
|
const char *table_name,
|
||||||
T (*literal_load_barrier)(HashtableEntry<T, F>*)) {
|
T (*literal_load_barrier)(HashtableEntry<T, F>*)) {
|
||||||
@ -318,11 +310,9 @@ template class Hashtable<InstanceKlass*, mtClass>;
|
|||||||
template class Hashtable<WeakHandle, mtClass>;
|
template class Hashtable<WeakHandle, mtClass>;
|
||||||
template class Hashtable<WeakHandle, mtServiceability>;
|
template class Hashtable<WeakHandle, mtServiceability>;
|
||||||
template class Hashtable<Symbol*, mtModule>;
|
template class Hashtable<Symbol*, mtModule>;
|
||||||
template class Hashtable<oop, mtSymbol>;
|
|
||||||
template class Hashtable<Symbol*, mtClass>;
|
template class Hashtable<Symbol*, mtClass>;
|
||||||
template class HashtableEntry<Symbol*, mtSymbol>;
|
template class HashtableEntry<Symbol*, mtSymbol>;
|
||||||
template class HashtableEntry<Symbol*, mtClass>;
|
template class HashtableEntry<Symbol*, mtClass>;
|
||||||
template class HashtableEntry<oop, mtSymbol>;
|
|
||||||
template class HashtableBucket<mtClass>;
|
template class HashtableBucket<mtClass>;
|
||||||
template class BasicHashtableEntry<mtSymbol>;
|
template class BasicHashtableEntry<mtSymbol>;
|
||||||
template class BasicHashtableEntry<mtCode>;
|
template class BasicHashtableEntry<mtCode>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user