src/share/vm/classfile/symbolTable.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

## src/share/vm/classfile/symbolTable.hpp

Print this page

      93
      94   // Adding elements
      95   Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue,
      96                     bool c_heap, TRAPS);
      97   bool basic_add(ClassLoaderData* loader_data,
      98                  constantPoolHandle cp, int names_count,
      99                  const char** names, int* lengths, int* cp_indices,
     100                  unsigned int* hashValues, TRAPS);
     101
     102   static void new_symbols(ClassLoaderData* loader_data,
     103                           constantPoolHandle cp, int names_count,
     104                           const char** name, int* lengths,
     105                           int* cp_indices, unsigned int* hashValues,
     106                           TRAPS) {
     107     add(loader_data, cp, names_count, name, lengths, cp_indices, hashValues, THREAD);
     108   }
     109
     110   Symbol* lookup(int index, const char* name, int len, unsigned int hash);
     111
     112   SymbolTable()
     113     : RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>)) {}

     114
     115   SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
     116     : RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>), t,
     117                 number_of_entries) {}

     118
     119   // Arena for permanent symbols (null class loader) that are never unloaded
     120   static Arena*  _arena;
     121   static Arena* arena() { return _arena; }  // called for statistics
     122
     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:
     130   enum {
     131     symbol_alloc_batch_size = 8,
     132     // Pick initial size based on java -version size measurements
     133     symbol_alloc_arena_size = 360*K
     134   };
     135
     136   // The symbol table
     137   static SymbolTable* the_table() { return _the_table; }
     214   static Symbol* lookup(int index, const char* name, int len, TRAPS);
     215
     216   // Needed for preloading classes in signatures when compiling.
     217   // Returns the symbol is already present in symbol table, otherwise
     218   // NULL.  NO ALLOCATION IS GUARANTEED!
     219   static Symbol* probe(const char* name, int len) {
     220     unsigned int ignore_hash;
     221     return lookup_only(name, len, ignore_hash);
     222   }
     223   static Symbol* probe_unicode(const jchar* name, int len) {
     224     unsigned int ignore_hash;
     225     return lookup_only_unicode(name, len, ignore_hash);
     226   }
     227
     228   // Histogram
     229   static void print_histogram()     PRODUCT_RETURN;
     230   static void print()     PRODUCT_RETURN;
     231
     232   // Debugging
     233   static void verify();
     234   static void dump(outputStream* st);
     235
     236   // Sharing
     237   static void copy_buckets(char** top, char*end) {
     238     the_table()->Hashtable<Symbol*, mtSymbol>::copy_buckets(top, end);
     239   }
     240   static void copy_table(char** top, char*end) {
     241     the_table()->Hashtable<Symbol*, mtSymbol>::copy_table(top, end);
     242   }
     243   static void reverse(void* boundary = NULL) {
     244     the_table()->Hashtable<Symbol*, mtSymbol>::reverse(boundary);
     245   }
     246
     247   // Rehash the symbol table if it gets out of balance
     248   static void rehash_table();
     249   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 };
     254
     262   // Set if one bucket is out of balance due to hash algorithm deficiency
     263   static bool _needs_rehashing;
     264
     265   // Claimed high water mark for parallel chunked scanning
     266   static volatile int _parallel_claimed_idx;
     267
     268   static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
     269   oop basic_add(int index, Handle string_or_null, jchar* name, int len,
     270                 unsigned int hashValue, TRAPS);
     271
     272   oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
     273
     274   // Apply the give oop closure to the entries to the buckets
     275   // in the range [start_idx, end_idx).
     276   static void buckets_oops_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
     281   StringTable() : RehashableHashtable<oop, mtSymbol>((int)StringTableSize,
     282                               sizeof (HashtableEntry<oop, mtSymbol>)) {}

     283
     284   StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
     285     : RehashableHashtable<oop, mtSymbol>((int)StringTableSize, sizeof (HashtableEntry<oop, mtSymbol>), t,
     286                      number_of_entries) {}

     287 public:
     288   // The string table
     289   static StringTable* the_table() { return _the_table; }
     290
     291   // Size of one bucket in the string table.  Used when checking for rollover.
     292   static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
     293
     294   static void create_table() {
     295     assert(_the_table == NULL, "One string table allowed.");
     296     _the_table = new StringTable();
     297   }
     298
     299   // GC support
     300   //   Delete pointers to otherwise-unreachable objects.
     301   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) {
     324
     325   // Hashing algorithm, used as the hash value used by the
     326   //     StringTable for bucket selection and comparison (stored in the
     327   //     HashtableEntry structures).  This is used in the String.intern() method.
     328   static unsigned int hash_string(const jchar* s, int len);
     329
     330   // Internal test.
     331   static void test_alt_hash() PRODUCT_RETURN;
     332
     333   // Probing
     334   static oop lookup(Symbol* symbol);
     335   static oop lookup(jchar* chars, int length);
     336
     337   // Interning
     338   static oop intern(Symbol* symbol, TRAPS);
     339   static oop intern(oop string, TRAPS);
     340   static oop intern(const char *utf8_string, TRAPS);
     341
     342   // Debugging
     343   static void verify();
     344   static void dump(outputStream* st);
     345
     346   enum VerifyMesgModes {
     347     _verify_quietly    = 0,
     348     _verify_with_mesgs = 1
     349   };
     350
     351   enum VerifyRetTypes {
     352     _verify_pass          = 0,
     353     _verify_fail_continue = 1,
     354     _verify_fail_done     = 2
     355   };
     356
     357   static VerifyRetTypes compare_entries(int bkt1, int e_cnt1,
     358                                         HashtableEntry<oop, mtSymbol>* e_ptr1,
     359                                         int bkt2, int e_cnt2,
     360                                         HashtableEntry<oop, mtSymbol>* e_ptr2);
     361   static VerifyRetTypes verify_entry(int bkt, int e_cnt,
     362                                      HashtableEntry<oop, mtSymbol>* e_ptr,
     363                                      VerifyMesgModes mesg_mode);
     364   static int verify_and_compare_entries();
      93
      94   // Adding elements
      95   Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue,
      96                     bool c_heap, TRAPS);
      97   bool basic_add(ClassLoaderData* loader_data,
      98                  constantPoolHandle cp, int names_count,
      99                  const char** names, int* lengths, int* cp_indices,
     100                  unsigned int* hashValues, TRAPS);
     101
     102   static void new_symbols(ClassLoaderData* loader_data,
     103                           constantPoolHandle cp, int names_count,
     104                           const char** name, int* lengths,
     105                           int* cp_indices, unsigned int* hashValues,
     106                           TRAPS) {
     107     add(loader_data, cp, names_count, name, lengths, cp_indices, hashValues, THREAD);
     108   }
     109
     110   Symbol* lookup(int index, const char* name, int len, unsigned int hash);
     111
     112   SymbolTable()
     113     : RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>))
     114     {
     115 #ifdef PRINT_HASHTABLES_CREATION
     116       fprintf(stderr, "SymbolTable1 %p with size %d\n", this, (int)SymbolTableSize);
     117 #endif
     118     }
     119
     120   SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
     121     : RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>), t,
     122                 number_of_entries)
     123   {
     124 #ifdef PRINT_HASHTABLES_CREATION
     125     fprintf(stderr, "SymbolTable2 %p with size %d\n", this, (int)SymbolTableSize);
     126 #endif
     127   }
     128
     129   // Arena for permanent symbols (null class loader) that are never unloaded
     130   static Arena*  _arena;
     131   static Arena* arena() { return _arena; }  // called for statistics
     132
     133   static void initialize_symbols(int arena_alloc_size = 0);
     134
     135   static volatile int _parallel_claimed_idx;
     136
     137   // Release any dead symbols
     138   static void buckets_unlink(int start_idx, int end_idx, int* processed, int* removed, size_t* memory_total);
     139 public:
     140   enum {
     141     symbol_alloc_batch_size = 8,
     142     // Pick initial size based on java -version size measurements
     143     symbol_alloc_arena_size = 360*K
     144   };
     145
     146   // The symbol table
     147   static SymbolTable* the_table() { return _the_table; }
     224   static Symbol* lookup(int index, const char* name, int len, TRAPS);
     225
     226   // Needed for preloading classes in signatures when compiling.
     227   // Returns the symbol is already present in symbol table, otherwise
     228   // NULL.  NO ALLOCATION IS GUARANTEED!
     229   static Symbol* probe(const char* name, int len) {
     230     unsigned int ignore_hash;
     231     return lookup_only(name, len, ignore_hash);
     232   }
     233   static Symbol* probe_unicode(const jchar* name, int len) {
     234     unsigned int ignore_hash;
     235     return lookup_only_unicode(name, len, ignore_hash);
     236   }
     237
     238   // Histogram
     239   static void print_histogram()     PRODUCT_RETURN;
     240   static void print()     PRODUCT_RETURN;
     241
     242   // Debugging
     243   static void verify();

     244
     245   // Sharing
     246   static void copy_buckets(char** top, char*end) {
     247     the_table()->Hashtable<Symbol*, mtSymbol>::copy_buckets(top, end);
     248   }
     249   static void copy_table(char** top, char*end) {
     250     the_table()->Hashtable<Symbol*, mtSymbol>::copy_table(top, end);
     251   }
     252   static void reverse(void* boundary = NULL) {
     253     the_table()->Hashtable<Symbol*, mtSymbol>::reverse(boundary);
     254   }
     255
     256   // Rehash the symbol table if it gets out of balance
     257   static void rehash_table();
     258   static bool needs_rehashing()         { return _needs_rehashing; }
     259   // Parallel chunked scanning
     260   static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; }
     261   static int parallel_claimed_index()        { return _parallel_claimed_idx; }
     262 };
     263
     271   // Set if one bucket is out of balance due to hash algorithm deficiency
     272   static bool _needs_rehashing;
     273
     274   // Claimed high water mark for parallel chunked scanning
     275   static volatile int _parallel_claimed_idx;
     276
     277   static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
     278   oop basic_add(int index, Handle string_or_null, jchar* name, int len,
     279                 unsigned int hashValue, TRAPS);
     280
     281   oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
     282
     283   // Apply the give oop closure to the entries to the buckets
     284   // in the range [start_idx, end_idx).
     285   static void buckets_oops_do(OopClosure* f, int start_idx, int end_idx);
     286   // Unlink or apply the give oop closure to the entries to the buckets
     287   // in the range [start_idx, end_idx).
     288   static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed);
     289
     290   StringTable() : RehashableHashtable<oop, mtSymbol>((int)StringTableSize,
     291                               sizeof (HashtableEntry<oop, mtSymbol>))
     292   {
     293 #ifdef PRINT_HASHTABLES_CREATION
     294     fprintf(stderr, "StringTable1 %p with size %d\n", this, (int)StringTableSize);
     295 #endif
     296   }
     297
     298   StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
     299     : RehashableHashtable<oop, mtSymbol>((int)StringTableSize, sizeof (HashtableEntry<oop, mtSymbol>), t,
     300                      number_of_entries)
     301   {
     302 #ifdef PRINT_HASHTABLES_CREATION
     303   fprintf(stderr, "StringTable2 %p with size %d\n", this, (int)StringTableSize);
     304 #endif
     305   }
     306
     307 public:
     308   // The string table
     309   static StringTable* the_table() { return _the_table; }
     310
     311   // Size of one bucket in the string table.  Used when checking for rollover.
     312   static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
     313
     314   static void create_table() {
     315     assert(_the_table == NULL, "One string table allowed.");
     316     _the_table = new StringTable();
     317   }
     318
     319   // GC support
     320   //   Delete pointers to otherwise-unreachable objects.
     321   static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f) {
     322     int processed = 0;
     323     int removed = 0;
     324     unlink_or_oops_do(cl, f, &processed, &removed);
     325   }
     326   static void unlink(BoolObjectClosure* cl) {
     344
     345   // Hashing algorithm, used as the hash value used by the
     346   //     StringTable for bucket selection and comparison (stored in the
     347   //     HashtableEntry structures).  This is used in the String.intern() method.
     348   static unsigned int hash_string(const jchar* s, int len);
     349
     350   // Internal test.
     351   static void test_alt_hash() PRODUCT_RETURN;
     352
     353   // Probing
     354   static oop lookup(Symbol* symbol);
     355   static oop lookup(jchar* chars, int length);
     356
     357   // Interning
     358   static oop intern(Symbol* symbol, TRAPS);
     359   static oop intern(oop string, TRAPS);
     360   static oop intern(const char *utf8_string, TRAPS);
     361
     362   // Debugging
     363   static void verify();

     364
     365   enum VerifyMesgModes {
     366     _verify_quietly    = 0,
     367     _verify_with_mesgs = 1
     368   };
     369
     370   enum VerifyRetTypes {
     371     _verify_pass          = 0,
     372     _verify_fail_continue = 1,
     373     _verify_fail_done     = 2
     374   };
     375
     376   static VerifyRetTypes compare_entries(int bkt1, int e_cnt1,
     377                                         HashtableEntry<oop, mtSymbol>* e_ptr1,
     378                                         int bkt2, int e_cnt2,
     379                                         HashtableEntry<oop, mtSymbol>* e_ptr2);
     380   static VerifyRetTypes verify_entry(int bkt, int e_cnt,
     381                                      HashtableEntry<oop, mtSymbol>* e_ptr,
     382                                      VerifyMesgModes mesg_mode);
     383   static int verify_and_compare_entries();

src/share/vm/classfile/symbolTable.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File