hotspot/src/share/vm/utilities/hashtable.hpp
changeset 46475 75902cea18af
parent 46435 3f6cac9867d4
child 46488 01c282163d38
equal deleted inserted replaced
46474:c872a196b75f 46475:75902cea18af
   122   friend class VMStructs;
   122   friend class VMStructs;
   123 private:
   123 private:
   124   // Instance variable
   124   // Instance variable
   125   BasicHashtableEntry<F>*       _entry;
   125   BasicHashtableEntry<F>*       _entry;
   126 
   126 
   127 #ifdef ASSERT
       
   128 private:
       
   129   unsigned _hits;
       
   130 public:
       
   131   unsigned hits()   { return _hits; }
       
   132   void count_hit()  { _hits++; }
       
   133 #endif
       
   134 
       
   135 public:
   127 public:
   136   // Accessing
   128   // Accessing
   137   void clear()                        { _entry = NULL; DEBUG_ONLY(_hits = 0); }
   129   void clear()                        { _entry = NULL; }
   138 
   130 
   139   // The following methods use order access methods to avoid race
   131   // The following methods use order access methods to avoid race
   140   // conditions in multiprocessor systems.
   132   // conditions in multiprocessor systems.
   141   BasicHashtableEntry<F>* get_entry() const;
   133   BasicHashtableEntry<F>* get_entry() const;
   142   void set_entry(BasicHashtableEntry<F>* l);
   134   void set_entry(BasicHashtableEntry<F>* l);
   177   int               _number_of_entries;
   169   int               _number_of_entries;
   178 
   170 
   179 protected:
   171 protected:
   180 
   172 
   181 #ifdef ASSERT
   173 #ifdef ASSERT
   182   bool              _lookup_warning;
   174   void verify_lookup_length(int max_bucket_count, const char *table_name);
   183   mutable int       _lookup_count;
       
   184   mutable int       _lookup_length;
       
   185   bool verify_lookup_length(double load, const char *table_name);
       
   186 #endif
   175 #endif
   187 
   176 
   188   void initialize(int table_size, int entry_size, int number_of_entries);
   177   void initialize(int table_size, int entry_size, int number_of_entries);
   189 
   178 
   190   // Accessor
   179   // Accessor
   230 
   219 
   231   void free_entry(BasicHashtableEntry<F>* entry);
   220   void free_entry(BasicHashtableEntry<F>* entry);
   232 
   221 
   233   int number_of_entries() { return _number_of_entries; }
   222   int number_of_entries() { return _number_of_entries; }
   234 
   223 
   235   void verify() PRODUCT_RETURN;
   224   template <class T> void verify_table(const char* table_name) PRODUCT_RETURN;
   236 
       
   237 #ifdef ASSERT
       
   238   void bucket_count_hit(int i) const {
       
   239     _buckets[i].count_hit();
       
   240   }
       
   241   unsigned bucket_hits(int i) const {
       
   242     return _buckets[i].hits();
       
   243   }
       
   244 #endif
       
   245 };
   225 };
   246 
   226 
   247 
   227 
   248 template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> {
   228 template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> {
   249   friend class VMStructs;
   229   friend class VMStructs;