< prev index next >

src/share/vm/utilities/hashtable.hpp

Print this page




 284 
 285   enum {
 286     rehash_count = 100,
 287     rehash_multiple = 60
 288   };
 289 
 290   // Check that the table is unbalanced
 291   bool check_rehash_table(int count);
 292 
 293  public:
 294   RehashableHashtable(int table_size, int entry_size)
 295     : Hashtable<T, F>(table_size, entry_size) { }
 296 
 297   RehashableHashtable(int table_size, int entry_size,
 298                    HashtableBucket<F>* buckets, int number_of_entries)
 299     : Hashtable<T, F>(table_size, entry_size, buckets, number_of_entries) { }
 300 
 301 
 302   // Function to move these elements into the new table.
 303   void move_to(RehashableHashtable<T, F>* new_table);
 304   static bool use_alternate_hashcode()  { return _seed != 0; }
 305   static juint seed()                    { return _seed; }
 306 
 307   static int literal_size(Symbol *symbol);
 308   static int literal_size(oop oop);
 309 
 310   // The following two are currently not used, but are needed anyway because some
 311   // C++ compilers (MacOS and Solaris) force the instantiation of
 312   // Hashtable<ConstantPool*, mtClass>::dump_table() even though we never call this function
 313   // in the VM code.
 314   static int literal_size(ConstantPool *cp) {Unimplemented(); return 0;}
 315   static int literal_size(Klass *k)         {Unimplemented(); return 0;}
 316 
 317   void dump_table(outputStream* st, const char *table_name);
 318 
 319  private:
 320   static juint _seed;
 321 };
 322 



 323 
 324 // Versions of hashtable where two handles are used to compute the index.
 325 
 326 template <class T, MEMFLAGS F> class TwoOopHashtable : public Hashtable<T, F> {
 327   friend class VMStructs;
 328 protected:
 329   TwoOopHashtable(int table_size, int entry_size)
 330     : Hashtable<T, F>(table_size, entry_size) {}
 331 
 332   TwoOopHashtable(int table_size, int entry_size, HashtableBucket<F>* t,
 333                   int number_of_entries)
 334     : Hashtable<T, F>(table_size, entry_size, t, number_of_entries) {}
 335 
 336 public:
 337   unsigned int compute_hash(const Symbol* name, const ClassLoaderData* loader_data) const {
 338     unsigned int name_hash = name->identity_hash();
 339     // loader is null with CDS
 340     assert(loader_data != NULL || UseSharedSpaces || DumpSharedSpaces,
 341            "only allowed with shared spaces");
 342     unsigned int loader_hash = loader_data == NULL ? 0 : loader_data->identity_hash();


 284 
 285   enum {
 286     rehash_count = 100,
 287     rehash_multiple = 60
 288   };
 289 
 290   // Check that the table is unbalanced
 291   bool check_rehash_table(int count);
 292 
 293  public:
 294   RehashableHashtable(int table_size, int entry_size)
 295     : Hashtable<T, F>(table_size, entry_size) { }
 296 
 297   RehashableHashtable(int table_size, int entry_size,
 298                    HashtableBucket<F>* buckets, int number_of_entries)
 299     : Hashtable<T, F>(table_size, entry_size, buckets, number_of_entries) { }
 300 
 301 
 302   // Function to move these elements into the new table.
 303   void move_to(RehashableHashtable<T, F>* new_table);
 304   static bool use_alternate_hashcode();
 305   static juint seed();
 306 
 307   static int literal_size(Symbol *symbol);
 308   static int literal_size(oop oop);
 309 
 310   // The following two are currently not used, but are needed anyway because some
 311   // C++ compilers (MacOS and Solaris) force the instantiation of
 312   // Hashtable<ConstantPool*, mtClass>::dump_table() even though we never call this function
 313   // in the VM code.
 314   static int literal_size(ConstantPool *cp) {Unimplemented(); return 0;}
 315   static int literal_size(Klass *k)         {Unimplemented(); return 0;}
 316 
 317   void dump_table(outputStream* st, const char *table_name);
 318 
 319  private:
 320   static juint _seed;
 321 };
 322 
 323 template <class T, MEMFLAGS F> juint RehashableHashtable<T, F>::_seed = 0;
 324 template <class T, MEMFLAGS F> juint RehashableHashtable<T, F>::seed() { return _seed; };
 325 template <class T, MEMFLAGS F> bool  RehashableHashtable<T, F>::use_alternate_hashcode() { return _seed != 0; };
 326 
 327 // Versions of hashtable where two handles are used to compute the index.
 328 
 329 template <class T, MEMFLAGS F> class TwoOopHashtable : public Hashtable<T, F> {
 330   friend class VMStructs;
 331 protected:
 332   TwoOopHashtable(int table_size, int entry_size)
 333     : Hashtable<T, F>(table_size, entry_size) {}
 334 
 335   TwoOopHashtable(int table_size, int entry_size, HashtableBucket<F>* t,
 336                   int number_of_entries)
 337     : Hashtable<T, F>(table_size, entry_size, t, number_of_entries) {}
 338 
 339 public:
 340   unsigned int compute_hash(const Symbol* name, const ClassLoaderData* loader_data) const {
 341     unsigned int name_hash = name->identity_hash();
 342     // loader is null with CDS
 343     assert(loader_data != NULL || UseSharedSpaces || DumpSharedSpaces,
 344            "only allowed with shared spaces");
 345     unsigned int loader_hash = loader_data == NULL ? 0 : loader_data->identity_hash();
< prev index next >