Skip to content
Permalink
Browse files
8260630: Templatize literal_size
8260629: Remove explicit instantiation of Hashtable with oop value

Reviewed-by: pliden, tschatzl, coleenp
  • Loading branch information
Kim Barrett committed Jan 30, 2021
1 parent 6b24e98 commit 67a34daf683b36ba97c26063d22707cf4aee7c55
Showing with 3 additions and 13 deletions.
  1. +3 −13 src/hotspot/share/utilities/hashtable.cpp
@@ -110,22 +110,18 @@ template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
_buckets = NULL;
}

// For oops and Strings the size of the literal is interesting. For other types, nobody cares.
static int literal_size(ConstantPool*) { return 0; }
static int literal_size(Klass*) { return 0; }
static int literal_size(nmethod*) { return 0; }
// Default overload, for types that are uninteresting.
template<typename T> static int literal_size(T) { return 0; }

static int literal_size(Symbol *symbol) {
return symbol->size() * HeapWordSize;
}

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) {
return 0;
} 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;
} else {
return obj->size();
@@ -235,10 +231,6 @@ template <class T, MEMFLAGS F> TableStatistics Hashtable<T, F>::statistics_calcu
}

// 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,
const char *table_name,
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, mtServiceability>;
template class Hashtable<Symbol*, mtModule>;
template class Hashtable<oop, mtSymbol>;
template class Hashtable<Symbol*, mtClass>;
template class HashtableEntry<Symbol*, mtSymbol>;
template class HashtableEntry<Symbol*, mtClass>;
template class HashtableEntry<oop, mtSymbol>;
template class HashtableBucket<mtClass>;
template class BasicHashtableEntry<mtSymbol>;
template class BasicHashtableEntry<mtCode>;

1 comment on commit 67a34da

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 67a34da Jan 30, 2021

Please sign in to comment.