< prev index next >

src/hotspot/share/classfile/compactHashtable.hpp

Print this page

287   template <class ITER>
288   inline void iterate(ITER* iter) const {
289     for (u4 i = 0; i < _bucket_count; i++) {
290       u4 bucket_info = _buckets[i];
291       u4 bucket_offset = BUCKET_OFFSET(bucket_info);
292       int bucket_type = BUCKET_TYPE(bucket_info);
293       u4* entry = _entries + bucket_offset;
294 
295       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
296         iter->do_value(decode(entry[0]));
297       } else {
298         u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
299         while (entry < entry_max) {
300           iter->do_value(decode(entry[1]));
301           entry += 2;
302         }
303       }
304     }
305   }
306 




















307   void print_table_statistics(outputStream* st, const char* name) {
308     st->print_cr("%s statistics:", name);
309     int total_entries = 0;
310     int max_bucket = 0;
311     for (u4 i = 0; i < _bucket_count; i++) {
312       u4 bucket_info = _buckets[i];
313       int bucket_type = BUCKET_TYPE(bucket_info);
314       int bucket_size;
315 
316       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
317         bucket_size = 1;
318       } else {
319         bucket_size = (BUCKET_OFFSET(_buckets[i + 1]) - BUCKET_OFFSET(bucket_info)) / 2;
320       }
321       total_entries += bucket_size;
322       if (max_bucket < bucket_size) {
323         max_bucket = bucket_size;
324       }
325     }
326     st->print_cr("Number of buckets       : %9d", _bucket_count);

287   template <class ITER>
288   inline void iterate(ITER* iter) const {
289     for (u4 i = 0; i < _bucket_count; i++) {
290       u4 bucket_info = _buckets[i];
291       u4 bucket_offset = BUCKET_OFFSET(bucket_info);
292       int bucket_type = BUCKET_TYPE(bucket_info);
293       u4* entry = _entries + bucket_offset;
294 
295       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
296         iter->do_value(decode(entry[0]));
297       } else {
298         u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
299         while (entry < entry_max) {
300           iter->do_value(decode(entry[1]));
301           entry += 2;
302         }
303       }
304     }
305   }
306 
307   template<typename Function>
308   inline void iterate(Function function) const { // lambda enabled API
309     for (u4 i = 0; i < _bucket_count; i++) {
310       u4 bucket_info = _buckets[i];
311       u4 bucket_offset = BUCKET_OFFSET(bucket_info);
312       int bucket_type = BUCKET_TYPE(bucket_info);
313       u4* entry = _entries + bucket_offset;
314 
315       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
316         function(decode(entry[0]));
317       } else {
318         u4* entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
319         while (entry < entry_max) {
320           function(decode(entry[1]));
321           entry += 2;
322         }
323       }
324     }
325   }
326 
327   void print_table_statistics(outputStream* st, const char* name) {
328     st->print_cr("%s statistics:", name);
329     int total_entries = 0;
330     int max_bucket = 0;
331     for (u4 i = 0; i < _bucket_count; i++) {
332       u4 bucket_info = _buckets[i];
333       int bucket_type = BUCKET_TYPE(bucket_info);
334       int bucket_size;
335 
336       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
337         bucket_size = 1;
338       } else {
339         bucket_size = (BUCKET_OFFSET(_buckets[i + 1]) - BUCKET_OFFSET(bucket_info)) / 2;
340       }
341       total_entries += bucket_size;
342       if (max_bucket < bucket_size) {
343         max_bucket = bucket_size;
344       }
345     }
346     st->print_cr("Number of buckets       : %9d", _bucket_count);
< prev index next >