diff -r 51612f0c0a79 -r fc9d8850ab8b src/share/vm/classfile/symbolTable.hpp --- a/src/share/vm/classfile/symbolTable.hpp Thu Mar 15 13:37:13 2012 +0100 +++ b/src/share/vm/classfile/symbolTable.hpp Fri Mar 23 11:16:05 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -82,24 +82,24 @@ static int symbols_removed; static int symbols_counted; - Symbol* allocate_symbol(const u1* name, int len, TRAPS); // Assumes no characters larger than 0x7F - bool allocate_symbols(int names_count, const u1** names, int* lengths, Symbol** syms, TRAPS); + Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F // Adding elements - Symbol* basic_add(int index, u1* name, int len, - unsigned int hashValue, TRAPS); - bool basic_add(constantPoolHandle cp, int names_count, + Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue, + bool c_heap, TRAPS); + + bool basic_add(Handle class_loader, constantPoolHandle cp, int names_count, const char** names, int* lengths, int* cp_indices, unsigned int* hashValues, TRAPS); - static void new_symbols(constantPoolHandle cp, int names_count, + static void new_symbols(Handle class_loader, constantPoolHandle cp, + int names_count, const char** name, int* lengths, int* cp_indices, unsigned int* hashValues, TRAPS) { - add(cp, names_count, name, lengths, cp_indices, hashValues, THREAD); + add(class_loader, cp, names_count, name, lengths, cp_indices, hashValues, THREAD); } - // Table size enum { symbol_table_size = 20011 @@ -114,10 +114,16 @@ : Hashtable(symbol_table_size, sizeof (HashtableEntry), t, number_of_entries) {} + // Arena for permanent symbols (null class loader) that are never unloaded + static Arena* _arena; + static Arena* arena() { return _arena; } // called for statistics + static void initialize_symbols(int arena_alloc_size = 0); public: enum { - symbol_alloc_batch_size = 8 + symbol_alloc_batch_size = 8, + // Pick initial size based on java -version size measurements + symbol_alloc_arena_size = 360*K }; // The symbol table @@ -126,6 +132,7 @@ static void create_table() { assert(_the_table == NULL, "One symbol table allowed."); _the_table = new SymbolTable(); + initialize_symbols(symbol_alloc_arena_size); } static void create_table(HashtableBucket* t, int length, @@ -134,6 +141,9 @@ assert(length == symbol_table_size * sizeof(HashtableBucket), "bad shared symbol 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. + initialize_symbols(); } static Symbol* lookup(const char* name, int len, TRAPS); @@ -151,7 +161,7 @@ static Symbol* lookup_unicode(const jchar* name, int len, TRAPS); static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash); - static void add(constantPoolHandle cp, int names_count, + static void add(Handle class_loader, constantPoolHandle cp, int names_count, const char** names, int* lengths, int* cp_indices, unsigned int* hashValues, TRAPS); @@ -174,6 +184,9 @@ return lookup(sym, begin, end, THREAD); } + // Create a symbol in the arena for symbols that are not deleted + static Symbol* new_permanent_symbol(const char* name, TRAPS); + // Symbol lookup static Symbol* lookup(int index, const char* name, int len, TRAPS);