equal
deleted
inserted
replaced
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 |
127 public: |
135 public: |
128 // Accessing |
136 // Accessing |
129 void clear() { _entry = NULL; } |
137 void clear() { _entry = NULL; DEBUG_ONLY(_hits = 0); } |
130 |
138 |
131 // The following methods use order access methods to avoid race |
139 // The following methods use order access methods to avoid race |
132 // conditions in multiprocessor systems. |
140 // conditions in multiprocessor systems. |
133 BasicHashtableEntry<F>* get_entry() const; |
141 BasicHashtableEntry<F>* get_entry() const; |
134 void set_entry(BasicHashtableEntry<F>* l); |
142 void set_entry(BasicHashtableEntry<F>* l); |
135 |
143 |
136 // The following method is not MT-safe and must be done under lock. |
144 // The following method is not MT-safe and must be done under lock. |
137 BasicHashtableEntry<F>** entry_addr() { return &_entry; } |
145 BasicHashtableEntry<F>** entry_addr() { return &_entry; } |
|
146 |
138 }; |
147 }; |
139 |
148 |
140 |
149 |
141 template <MEMFLAGS F> class BasicHashtable : public CHeapObj<F> { |
150 template <MEMFLAGS F> class BasicHashtable : public CHeapObj<F> { |
142 friend class VMStructs; |
151 friend class VMStructs; |
171 int _number_of_entries; |
180 int _number_of_entries; |
172 |
181 |
173 protected: |
182 protected: |
174 |
183 |
175 #ifdef ASSERT |
184 #ifdef ASSERT |
|
185 bool _lookup_warning; |
176 mutable int _lookup_count; |
186 mutable int _lookup_count; |
177 mutable int _lookup_length; |
187 mutable int _lookup_length; |
178 void verify_lookup_length(double load); |
188 bool verify_lookup_length(double load); |
179 #endif |
189 #endif |
180 |
190 |
181 void initialize(int table_size, int entry_size, int number_of_entries); |
191 void initialize(int table_size, int entry_size, int number_of_entries); |
182 |
192 |
183 // Accessor |
193 // Accessor |
224 void free_entry(BasicHashtableEntry<F>* entry); |
234 void free_entry(BasicHashtableEntry<F>* entry); |
225 |
235 |
226 int number_of_entries() { return _number_of_entries; } |
236 int number_of_entries() { return _number_of_entries; } |
227 |
237 |
228 void verify() PRODUCT_RETURN; |
238 void verify() PRODUCT_RETURN; |
|
239 |
|
240 #ifdef ASSERT |
|
241 void bucket_count_hit(int i) const { |
|
242 _buckets[i].count_hit(); |
|
243 } |
|
244 unsigned bucket_hits(int i) const { |
|
245 return _buckets[i].hits(); |
|
246 } |
|
247 #endif |
229 }; |
248 }; |
230 |
249 |
231 |
250 |
232 template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> { |
251 template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> { |
233 friend class VMStructs; |
252 friend class VMStructs; |