1.1 --- a/src/share/vm/classfile/symbolTable.hpp Thu Mar 15 13:37:13 2012 +0100 1.2 +++ b/src/share/vm/classfile/symbolTable.hpp Fri Mar 23 11:16:05 2012 -0400 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -82,24 +82,24 @@ 1.11 static int symbols_removed; 1.12 static int symbols_counted; 1.13 1.14 - Symbol* allocate_symbol(const u1* name, int len, TRAPS); // Assumes no characters larger than 0x7F 1.15 - bool allocate_symbols(int names_count, const u1** names, int* lengths, Symbol** syms, TRAPS); 1.16 + Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F 1.17 1.18 // Adding elements 1.19 - Symbol* basic_add(int index, u1* name, int len, 1.20 - unsigned int hashValue, TRAPS); 1.21 - bool basic_add(constantPoolHandle cp, int names_count, 1.22 + Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue, 1.23 + bool c_heap, TRAPS); 1.24 + 1.25 + bool basic_add(Handle class_loader, constantPoolHandle cp, int names_count, 1.26 const char** names, int* lengths, int* cp_indices, 1.27 unsigned int* hashValues, TRAPS); 1.28 1.29 - static void new_symbols(constantPoolHandle cp, int names_count, 1.30 + static void new_symbols(Handle class_loader, constantPoolHandle cp, 1.31 + int names_count, 1.32 const char** name, int* lengths, 1.33 int* cp_indices, unsigned int* hashValues, 1.34 TRAPS) { 1.35 - add(cp, names_count, name, lengths, cp_indices, hashValues, THREAD); 1.36 + add(class_loader, cp, names_count, name, lengths, cp_indices, hashValues, THREAD); 1.37 } 1.38 1.39 - 1.40 // Table size 1.41 enum { 1.42 symbol_table_size = 20011 1.43 @@ -114,10 +114,16 @@ 1.44 : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t, 1.45 number_of_entries) {} 1.46 1.47 + // Arena for permanent symbols (null class loader) that are never unloaded 1.48 + static Arena* _arena; 1.49 + static Arena* arena() { return _arena; } // called for statistics 1.50 1.51 + static void initialize_symbols(int arena_alloc_size = 0); 1.52 public: 1.53 enum { 1.54 - symbol_alloc_batch_size = 8 1.55 + symbol_alloc_batch_size = 8, 1.56 + // Pick initial size based on java -version size measurements 1.57 + symbol_alloc_arena_size = 360*K 1.58 }; 1.59 1.60 // The symbol table 1.61 @@ -126,6 +132,7 @@ 1.62 static void create_table() { 1.63 assert(_the_table == NULL, "One symbol table allowed."); 1.64 _the_table = new SymbolTable(); 1.65 + initialize_symbols(symbol_alloc_arena_size); 1.66 } 1.67 1.68 static void create_table(HashtableBucket* t, int length, 1.69 @@ -134,6 +141,9 @@ 1.70 assert(length == symbol_table_size * sizeof(HashtableBucket), 1.71 "bad shared symbol size."); 1.72 _the_table = new SymbolTable(t, number_of_entries); 1.73 + // if CDS give symbol table a default arena size since most symbols 1.74 + // are already allocated in the shared misc section. 1.75 + initialize_symbols(); 1.76 } 1.77 1.78 static Symbol* lookup(const char* name, int len, TRAPS); 1.79 @@ -151,7 +161,7 @@ 1.80 static Symbol* lookup_unicode(const jchar* name, int len, TRAPS); 1.81 static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash); 1.82 1.83 - static void add(constantPoolHandle cp, int names_count, 1.84 + static void add(Handle class_loader, constantPoolHandle cp, int names_count, 1.85 const char** names, int* lengths, int* cp_indices, 1.86 unsigned int* hashValues, TRAPS); 1.87 1.88 @@ -174,6 +184,9 @@ 1.89 return lookup(sym, begin, end, THREAD); 1.90 } 1.91 1.92 + // Create a symbol in the arena for symbols that are not deleted 1.93 + static Symbol* new_permanent_symbol(const char* name, TRAPS); 1.94 + 1.95 // Symbol lookup 1.96 static Symbol* lookup(int index, const char* name, int len, TRAPS); 1.97