src/share/vm/classfile/symbolTable.hpp

changeset 5850
c90e76575b03
parent 5743
63147986a428
child 6229
5a32d2a3cc1e
equal deleted inserted replaced
5848:ac9cb1d5a202 5850:c90e76575b03
105 int* cp_indices, unsigned int* hashValues, 105 int* cp_indices, unsigned int* hashValues,
106 TRAPS) { 106 TRAPS) {
107 add(loader_data, cp, names_count, name, lengths, cp_indices, hashValues, THREAD); 107 add(loader_data, cp, names_count, name, lengths, cp_indices, hashValues, THREAD);
108 } 108 }
109 109
110 // Table size
111 enum {
112 symbol_table_size = 20011
113 };
114
115 Symbol* lookup(int index, const char* name, int len, unsigned int hash); 110 Symbol* lookup(int index, const char* name, int len, unsigned int hash);
116 111
117 SymbolTable() 112 SymbolTable()
118 : Hashtable<Symbol*, mtSymbol>(symbol_table_size, sizeof (HashtableEntry<Symbol*, mtSymbol>)) {} 113 : Hashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>)) {}
119 114
120 SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries) 115 SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
121 : Hashtable<Symbol*, mtSymbol>(symbol_table_size, sizeof (HashtableEntry<Symbol*, mtSymbol>), t, 116 : Hashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>), t,
122 number_of_entries) {} 117 number_of_entries) {}
123 118
124 // Arena for permanent symbols (null class loader) that are never unloaded 119 // Arena for permanent symbols (null class loader) that are never unloaded
125 static Arena* _arena; 120 static Arena* _arena;
126 static Arena* arena() { return _arena; } // called for statistics 121 static Arena* arena() { return _arena; } // called for statistics
134 }; 129 };
135 130
136 // The symbol table 131 // The symbol table
137 static SymbolTable* the_table() { return _the_table; } 132 static SymbolTable* the_table() { return _the_table; }
138 133
134 // Size of one bucket in the string table. Used when checking for rollover.
135 static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
136
139 static void create_table() { 137 static void create_table() {
140 assert(_the_table == NULL, "One symbol table allowed."); 138 assert(_the_table == NULL, "One symbol table allowed.");
141 _the_table = new SymbolTable(); 139 _the_table = new SymbolTable();
142 initialize_symbols(symbol_alloc_arena_size); 140 initialize_symbols(symbol_alloc_arena_size);
143 } 141 }
144 142
145 static void create_table(HashtableBucket<mtSymbol>* t, int length, 143 static void create_table(HashtableBucket<mtSymbol>* t, int length,
146 int number_of_entries) { 144 int number_of_entries) {
147 assert(_the_table == NULL, "One symbol table allowed."); 145 assert(_the_table == NULL, "One symbol table allowed.");
148 assert(length == symbol_table_size * sizeof(HashtableBucket<mtSymbol>), 146
149 "bad shared symbol size."); 147 // If CDS archive used a different symbol table size, use that size instead
148 // which is better than giving an error.
149 SymbolTableSize = length/bucket_size();
150
150 _the_table = new SymbolTable(t, number_of_entries); 151 _the_table = new SymbolTable(t, number_of_entries);
151 // if CDS give symbol table a default arena size since most symbols 152 // if CDS give symbol table a default arena size since most symbols
152 // are already allocated in the shared misc section. 153 // are already allocated in the shared misc section.
153 initialize_symbols(); 154 initialize_symbols();
154 } 155 }

mercurial