src/share/vm/classfile/symbolTable.hpp

changeset 3900
d2a62e0f25eb
parent 3875
246d977b51f2
child 3904
ace99a6ffc83
equal deleted inserted replaced
3877:74533f63b116 3900:d2a62e0f25eb
69 bool operator == (Symbol* o) const { return _temp == o; } 69 bool operator == (Symbol* o) const { return _temp == o; }
70 // Sneaky conversion function 70 // Sneaky conversion function
71 operator Symbol*() { return _temp; } 71 operator Symbol*() { return _temp; }
72 }; 72 };
73 73
74 class SymbolTable : public Hashtable<Symbol*> { 74 class SymbolTable : public Hashtable<Symbol*, mtSymbol> {
75 friend class VMStructs; 75 friend class VMStructs;
76 friend class ClassFileParser; 76 friend class ClassFileParser;
77 77
78 private: 78 private:
79 // The symbol table 79 // The symbol table
111 }; 111 };
112 112
113 Symbol* lookup(int index, const char* name, int len, unsigned int hash); 113 Symbol* lookup(int index, const char* name, int len, unsigned int hash);
114 114
115 SymbolTable() 115 SymbolTable()
116 : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>)) {} 116 : Hashtable<Symbol*, mtSymbol>(symbol_table_size, sizeof (HashtableEntry<Symbol*, mtSymbol>)) {}
117 117
118 SymbolTable(HashtableBucket* t, int number_of_entries) 118 SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
119 : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t, 119 : Hashtable<Symbol*, mtSymbol>(symbol_table_size, sizeof (HashtableEntry<Symbol*, mtSymbol>), t,
120 number_of_entries) {} 120 number_of_entries) {}
121 121
122 // Arena for permanent symbols (null class loader) that are never unloaded 122 // Arena for permanent symbols (null class loader) that are never unloaded
123 static Arena* _arena; 123 static Arena* _arena;
124 static Arena* arena() { return _arena; } // called for statistics 124 static Arena* arena() { return _arena; } // called for statistics
143 assert(_the_table == NULL, "One symbol table allowed."); 143 assert(_the_table == NULL, "One symbol table allowed.");
144 _the_table = new SymbolTable(); 144 _the_table = new SymbolTable();
145 initialize_symbols(symbol_alloc_arena_size); 145 initialize_symbols(symbol_alloc_arena_size);
146 } 146 }
147 147
148 static void create_table(HashtableBucket* t, int length, 148 static void create_table(HashtableBucket<mtSymbol>* t, int length,
149 int number_of_entries) { 149 int number_of_entries) {
150 assert(_the_table == NULL, "One symbol table allowed."); 150 assert(_the_table == NULL, "One symbol table allowed.");
151 assert(length == symbol_table_size * sizeof(HashtableBucket), 151 assert(length == symbol_table_size * sizeof(HashtableBucket<mtSymbol>),
152 "bad shared symbol size."); 152 "bad shared symbol size.");
153 _the_table = new SymbolTable(t, number_of_entries); 153 _the_table = new SymbolTable(t, number_of_entries);
154 // if CDS give symbol table a default arena size since most symbols 154 // if CDS give symbol table a default arena size since most symbols
155 // are already allocated in the shared misc section. 155 // are already allocated in the shared misc section.
156 initialize_symbols(); 156 initialize_symbols();
222 static void verify(); 222 static void verify();
223 static void dump(outputStream* st); 223 static void dump(outputStream* st);
224 224
225 // Sharing 225 // Sharing
226 static void copy_buckets(char** top, char*end) { 226 static void copy_buckets(char** top, char*end) {
227 the_table()->Hashtable<Symbol*>::copy_buckets(top, end); 227 the_table()->Hashtable<Symbol*, mtSymbol>::copy_buckets(top, end);
228 } 228 }
229 static void copy_table(char** top, char*end) { 229 static void copy_table(char** top, char*end) {
230 the_table()->Hashtable<Symbol*>::copy_table(top, end); 230 the_table()->Hashtable<Symbol*, mtSymbol>::copy_table(top, end);
231 } 231 }
232 static void reverse(void* boundary = NULL) { 232 static void reverse(void* boundary = NULL) {
233 the_table()->Hashtable<Symbol*>::reverse(boundary); 233 the_table()->Hashtable<Symbol*, mtSymbol>::reverse(boundary);
234 } 234 }
235 235
236 // Rehash the symbol table if it gets out of balance 236 // Rehash the symbol table if it gets out of balance
237 static void rehash_table(); 237 static void rehash_table();
238 static bool needs_rehashing() { return _needs_rehashing; } 238 static bool needs_rehashing() { return _needs_rehashing; }
239 }; 239 };
240 240
241 241 class StringTable : public Hashtable<oop, mtSymbol> {
242 class StringTable : public Hashtable<oop> {
243 friend class VMStructs; 242 friend class VMStructs;
244 243
245 private: 244 private:
246 // The string table 245 // The string table
247 static StringTable* _the_table; 246 static StringTable* _the_table;
254 oop basic_add(int index, Handle string_or_null, jchar* name, int len, 253 oop basic_add(int index, Handle string_or_null, jchar* name, int len,
255 unsigned int hashValue, TRAPS); 254 unsigned int hashValue, TRAPS);
256 255
257 oop lookup(int index, jchar* chars, int length, unsigned int hashValue); 256 oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
258 257
259 StringTable() : Hashtable<oop>((int)StringTableSize, 258 StringTable() : Hashtable<oop, mtSymbol>((int)StringTableSize,
260 sizeof (HashtableEntry<oop>)) {} 259 sizeof (HashtableEntry<oop, mtSymbol>)) {}
261 260
262 StringTable(HashtableBucket* t, int number_of_entries) 261 StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
263 : Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t, 262 : Hashtable<oop, mtSymbol>((int)StringTableSize, sizeof (HashtableEntry<oop, mtSymbol>), t,
264 number_of_entries) {} 263 number_of_entries) {}
265 264
266 static bool use_alternate_hashcode() { return _seed != 0; } 265 static bool use_alternate_hashcode() { return _seed != 0; }
267 static jint seed() { return _seed; } 266 static jint seed() { return _seed; }
268 267
274 static void create_table() { 273 static void create_table() {
275 assert(_the_table == NULL, "One string table allowed."); 274 assert(_the_table == NULL, "One string table allowed.");
276 _the_table = new StringTable(); 275 _the_table = new StringTable();
277 } 276 }
278 277
279 static void create_table(HashtableBucket* t, int length, 278 static void create_table(HashtableBucket<mtSymbol>* t, int length,
280 int number_of_entries) { 279 int number_of_entries) {
281 assert(_the_table == NULL, "One string table allowed."); 280 assert(_the_table == NULL, "One string table allowed.");
282 assert((size_t)length == StringTableSize * sizeof(HashtableBucket), 281 assert((size_t)length == StringTableSize * sizeof(HashtableBucket<mtSymbol>),
283 "bad shared string size."); 282 "bad shared string size.");
284 _the_table = new StringTable(t, number_of_entries); 283 _the_table = new StringTable(t, number_of_entries);
285 } 284 }
286 285
287 // GC support 286 // GC support
311 static void verify(); 310 static void verify();
312 static void dump(outputStream* st); 311 static void dump(outputStream* st);
313 312
314 // Sharing 313 // Sharing
315 static void copy_buckets(char** top, char*end) { 314 static void copy_buckets(char** top, char*end) {
316 the_table()->Hashtable<oop>::copy_buckets(top, end); 315 the_table()->Hashtable<oop, mtSymbol>::copy_buckets(top, end);
317 } 316 }
318 static void copy_table(char** top, char*end) { 317 static void copy_table(char** top, char*end) {
319 the_table()->Hashtable<oop>::copy_table(top, end); 318 the_table()->Hashtable<oop, mtSymbol>::copy_table(top, end);
320 } 319 }
321 static void reverse() { 320 static void reverse() {
322 the_table()->Hashtable<oop>::reverse(); 321 the_table()->Hashtable<oop, mtSymbol>::reverse();
323 } 322 }
324 323
325 // Rehash the symbol table if it gets out of balance 324 // Rehash the symbol table if it gets out of balance
326 static void rehash_table(); 325 static void rehash_table();
327 static bool needs_rehashing() { return _needs_rehashing; } 326 static bool needs_rehashing() { return _needs_rehashing; }

mercurial