Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/symbolTable.hpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 893ce66f7473 |
children | 52b4284cb496 |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
84 | 84 |
85 // Set if one bucket is out of balance due to hash algorithm deficiency | 85 // Set if one bucket is out of balance due to hash algorithm deficiency |
86 static bool _needs_rehashing; | 86 static bool _needs_rehashing; |
87 | 87 |
88 // For statistics | 88 // For statistics |
89 static int _symbols_removed; | 89 static int symbols_removed; |
90 static int _symbols_counted; | 90 static int symbols_counted; |
91 | 91 |
92 Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F | 92 Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F |
93 | 93 |
94 // Adding elements | 94 // Adding elements |
95 Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue, | 95 Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue, |
119 // Arena for permanent symbols (null class loader) that are never unloaded | 119 // Arena for permanent symbols (null class loader) that are never unloaded |
120 static Arena* _arena; | 120 static Arena* _arena; |
121 static Arena* arena() { return _arena; } // called for statistics | 121 static Arena* arena() { return _arena; } // called for statistics |
122 | 122 |
123 static void initialize_symbols(int arena_alloc_size = 0); | 123 static void initialize_symbols(int arena_alloc_size = 0); |
124 | |
125 static volatile int _parallel_claimed_idx; | |
126 | |
127 // Release any dead symbols | |
128 static void buckets_unlink(int start_idx, int end_idx, int* processed, int* removed, size_t* memory_total); | |
129 public: | 124 public: |
130 enum { | 125 enum { |
131 symbol_alloc_batch_size = 8, | 126 symbol_alloc_batch_size = 8, |
132 // Pick initial size based on java -version size measurements | 127 // Pick initial size based on java -version size measurements |
133 symbol_alloc_arena_size = 360*K | 128 symbol_alloc_arena_size = 360*K |
180 constantPoolHandle cp, int names_count, | 175 constantPoolHandle cp, int names_count, |
181 const char** names, int* lengths, int* cp_indices, | 176 const char** names, int* lengths, int* cp_indices, |
182 unsigned int* hashValues, TRAPS); | 177 unsigned int* hashValues, TRAPS); |
183 | 178 |
184 // Release any dead symbols | 179 // Release any dead symbols |
185 static void unlink() { | 180 static void unlink(); |
186 int processed = 0; | |
187 int removed = 0; | |
188 unlink(&processed, &removed); | |
189 } | |
190 static void unlink(int* processed, int* removed); | |
191 // Release any dead symbols, possibly parallel version | |
192 static void possibly_parallel_unlink(int* processed, int* removed); | |
193 | 181 |
194 // iterate over symbols | 182 // iterate over symbols |
195 static void symbols_do(SymbolClosure *cl); | 183 static void symbols_do(SymbolClosure *cl); |
196 | 184 |
197 // Symbol creation | 185 // Symbol creation |
245 } | 233 } |
246 | 234 |
247 // Rehash the symbol table if it gets out of balance | 235 // Rehash the symbol table if it gets out of balance |
248 static void rehash_table(); | 236 static void rehash_table(); |
249 static bool needs_rehashing() { return _needs_rehashing; } | 237 static bool needs_rehashing() { return _needs_rehashing; } |
250 // Parallel chunked scanning | |
251 static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; } | |
252 static int parallel_claimed_index() { return _parallel_claimed_idx; } | |
253 }; | 238 }; |
254 | 239 |
255 class StringTable : public Hashtable<oop, mtSymbol> { | 240 class StringTable : public Hashtable<oop, mtSymbol> { |
256 friend class VMStructs; | 241 friend class VMStructs; |
257 | 242 |
271 | 256 |
272 oop lookup(int index, jchar* chars, int length, unsigned int hashValue); | 257 oop lookup(int index, jchar* chars, int length, unsigned int hashValue); |
273 | 258 |
274 // Apply the give oop closure to the entries to the buckets | 259 // Apply the give oop closure to the entries to the buckets |
275 // in the range [start_idx, end_idx). | 260 // in the range [start_idx, end_idx). |
276 static void buckets_oops_do(OopClosure* f, int start_idx, int end_idx); | 261 static void buckets_do(OopClosure* f, int start_idx, int end_idx); |
277 // Unlink or apply the give oop closure to the entries to the buckets | |
278 // in the range [start_idx, end_idx). | |
279 static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed); | |
280 | 262 |
281 StringTable() : Hashtable<oop, mtSymbol>((int)StringTableSize, | 263 StringTable() : Hashtable<oop, mtSymbol>((int)StringTableSize, |
282 sizeof (HashtableEntry<oop, mtSymbol>)) {} | 264 sizeof (HashtableEntry<oop, mtSymbol>)) {} |
283 | 265 |
284 StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries) | 266 StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries) |
296 _the_table = new StringTable(); | 278 _the_table = new StringTable(); |
297 } | 279 } |
298 | 280 |
299 // GC support | 281 // GC support |
300 // Delete pointers to otherwise-unreachable objects. | 282 // Delete pointers to otherwise-unreachable objects. |
301 static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f) { | 283 static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f); |
302 int processed = 0; | |
303 int removed = 0; | |
304 unlink_or_oops_do(cl, f, &processed, &removed); | |
305 } | |
306 static void unlink(BoolObjectClosure* cl) { | 284 static void unlink(BoolObjectClosure* cl) { |
307 int processed = 0; | 285 unlink_or_oops_do(cl, NULL); |
308 int removed = 0; | 286 } |
309 unlink_or_oops_do(cl, NULL, &processed, &removed); | 287 |
310 } | |
311 static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f, int* processed, int* removed); | |
312 static void unlink(BoolObjectClosure* cl, int* processed, int* removed) { | |
313 unlink_or_oops_do(cl, NULL, processed, removed); | |
314 } | |
315 // Serially invoke "f->do_oop" on the locations of all oops in the table. | 288 // Serially invoke "f->do_oop" on the locations of all oops in the table. |
316 static void oops_do(OopClosure* f); | 289 static void oops_do(OopClosure* f); |
317 | 290 |
318 // Possibly parallel versions of the above | 291 // Possibly parallel version of the above |
319 static void possibly_parallel_unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f, int* processed, int* removed); | |
320 static void possibly_parallel_unlink(BoolObjectClosure* cl, int* processed, int* removed) { | |
321 possibly_parallel_unlink_or_oops_do(cl, NULL, processed, removed); | |
322 } | |
323 static void possibly_parallel_oops_do(OopClosure* f); | 292 static void possibly_parallel_oops_do(OopClosure* f); |
324 | 293 |
325 // Hashing algorithm, used as the hash value used by the | 294 // Hashing algorithm, used as the hash value used by the |
326 // StringTable for bucket selection and comparison (stored in the | 295 // StringTable for bucket selection and comparison (stored in the |
327 // HashtableEntry structures). This is used in the String.intern() method. | 296 // HashtableEntry structures). This is used in the String.intern() method. |
378 static void rehash_table(); | 347 static void rehash_table(); |
379 static bool needs_rehashing() { return _needs_rehashing; } | 348 static bool needs_rehashing() { return _needs_rehashing; } |
380 | 349 |
381 // Parallel chunked scanning | 350 // Parallel chunked scanning |
382 static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; } | 351 static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; } |
383 static int parallel_claimed_index() { return _parallel_claimed_idx; } | |
384 }; | 352 }; |
385 #endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP | 353 #endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP |