# HG changeset patch # User kevinw # Date 1381221231 -3600 # Node ID c90e76575b031b793cb4e7f19042d316517f1e8a # Parent ac9cb1d5a202cc73f10a472ddd648eb6b046674d 8019375: Internal symbol table size should be tunable. Reviewed-by: coleenp, kamg diff -r ac9cb1d5a202 -r c90e76575b03 agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java --- a/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java Mon Oct 07 12:20:28 2013 -0400 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java Tue Oct 08 09:33:51 2013 +0100 @@ -44,12 +44,10 @@ private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("SymbolTable"); theTableField = type.getAddressField("_the_table"); - symbolTableSize = db.lookupIntConstant("SymbolTable::symbol_table_size").intValue(); } // Fields private static AddressField theTableField; - private static int symbolTableSize; // Accessors public static SymbolTable getTheTable() { @@ -57,10 +55,6 @@ return (SymbolTable) VMObjectFactory.newObject(SymbolTable.class, tmp); } - public static int getSymbolTableSize() { - return symbolTableSize; - } - public SymbolTable(Address addr) { super(addr); } diff -r ac9cb1d5a202 -r c90e76575b03 src/share/vm/classfile/symbolTable.hpp --- a/src/share/vm/classfile/symbolTable.hpp Mon Oct 07 12:20:28 2013 -0400 +++ b/src/share/vm/classfile/symbolTable.hpp Tue Oct 08 09:33:51 2013 +0100 @@ -107,18 +107,13 @@ add(loader_data, cp, names_count, name, lengths, cp_indices, hashValues, THREAD); } - // Table size - enum { - symbol_table_size = 20011 - }; - Symbol* lookup(int index, const char* name, int len, unsigned int hash); SymbolTable() - : Hashtable(symbol_table_size, sizeof (HashtableEntry)) {} + : Hashtable(SymbolTableSize, sizeof (HashtableEntry)) {} SymbolTable(HashtableBucket* t, int number_of_entries) - : Hashtable(symbol_table_size, sizeof (HashtableEntry), t, + : Hashtable(SymbolTableSize, sizeof (HashtableEntry), t, number_of_entries) {} // Arena for permanent symbols (null class loader) that are never unloaded @@ -136,6 +131,9 @@ // The symbol table static SymbolTable* the_table() { return _the_table; } + // Size of one bucket in the string table. Used when checking for rollover. + static uint bucket_size() { return sizeof(HashtableBucket); } + static void create_table() { assert(_the_table == NULL, "One symbol table allowed."); _the_table = new SymbolTable(); @@ -145,8 +143,11 @@ static void create_table(HashtableBucket* t, int length, int number_of_entries) { assert(_the_table == NULL, "One symbol table allowed."); - assert(length == symbol_table_size * sizeof(HashtableBucket), - "bad shared symbol size."); + + // If CDS archive used a different symbol table size, use that size instead + // which is better than giving an error. + SymbolTableSize = length/bucket_size(); + _the_table = new SymbolTable(t, number_of_entries); // if CDS give symbol table a default arena size since most symbols // are already allocated in the shared misc section. diff -r ac9cb1d5a202 -r c90e76575b03 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Mon Oct 07 12:20:28 2013 -0400 +++ b/src/share/vm/runtime/arguments.cpp Tue Oct 08 09:33:51 2013 +0100 @@ -2045,6 +2045,9 @@ status = status && verify_interval(StringTableSize, minimumStringTableSize, (max_uintx / StringTable::bucket_size()), "StringTable size"); + status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize, + (max_uintx / SymbolTable::bucket_size()), "SymbolTable size"); + if (MinHeapFreeRatio > MaxHeapFreeRatio) { jio_fprintf(defaultStream::error_stream(), "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " diff -r ac9cb1d5a202 -r c90e76575b03 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Mon Oct 07 12:20:28 2013 -0400 +++ b/src/share/vm/runtime/globals.hpp Tue Oct 08 09:33:51 2013 +0100 @@ -3727,6 +3727,9 @@ product(uintx, StringTableSize, defaultStringTableSize, \ "Number of buckets in the interned String table") \ \ + experimental(uintx, SymbolTableSize, defaultSymbolTableSize, \ + "Number of buckets in the JVM internal Symbol table") \ + \ develop(bool, TraceDefaultMethods, false, \ "Trace the default method processing steps") \ \ diff -r ac9cb1d5a202 -r c90e76575b03 src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Mon Oct 07 12:20:28 2013 -0400 +++ b/src/share/vm/runtime/vmStructs.cpp Tue Oct 08 09:33:51 2013 +0100 @@ -27,7 +27,6 @@ #include "classfile/javaClasses.hpp" #include "classfile/loaderConstraints.hpp" #include "classfile/placeholders.hpp" -#include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "ci/ciField.hpp" #include "ci/ciInstance.hpp" @@ -2249,12 +2248,6 @@ declare_preprocessor_constant("PERFDATA_BIG_ENDIAN", PERFDATA_BIG_ENDIAN) \ declare_preprocessor_constant("PERFDATA_LITTLE_ENDIAN", PERFDATA_LITTLE_ENDIAN) \ \ - /***************/ \ - /* SymbolTable */ \ - /***************/ \ - \ - declare_constant(SymbolTable::symbol_table_size) \ - \ /***********************************/ \ /* LoaderConstraintTable constants */ \ /***********************************/ \ diff -r ac9cb1d5a202 -r c90e76575b03 src/share/vm/utilities/globalDefinitions.hpp --- a/src/share/vm/utilities/globalDefinitions.hpp Mon Oct 07 12:20:28 2013 -0400 +++ b/src/share/vm/utilities/globalDefinitions.hpp Tue Oct 08 09:33:51 2013 +0100 @@ -333,6 +333,9 @@ const int defaultStringTableSize = NOT_LP64(1009) LP64_ONLY(60013); const int minimumStringTableSize=1009; +const int defaultSymbolTableSize = 20011; +const int minimumSymbolTableSize = 1009; + //---------------------------------------------------------------------------------------------------- // HotSwap - for JVMTI aka Class File Replacement and PopFrame