41 initialize(table_size, entry_size, 0); |
41 initialize(table_size, entry_size, 0); |
42 _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC); |
42 _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC); |
43 for (int index = 0; index < _table_size; index++) { |
43 for (int index = 0; index < _table_size; index++) { |
44 _buckets[index].clear(); |
44 _buckets[index].clear(); |
45 } |
45 } |
|
46 _stats_rate = TableRateStatistics(); |
46 } |
47 } |
47 |
48 |
48 |
49 |
49 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size, |
50 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size, |
50 HashtableBucket<F>* buckets, |
51 HashtableBucket<F>* buckets, |
51 int number_of_entries) { |
52 int number_of_entries) { |
52 // Called on startup, no locking needed |
53 // Called on startup, no locking needed |
53 initialize(table_size, entry_size, number_of_entries); |
54 initialize(table_size, entry_size, number_of_entries); |
54 _buckets = buckets; |
55 _buckets = buckets; |
|
56 _stats_rate = TableRateStatistics(); |
55 } |
57 } |
56 |
58 |
57 template <MEMFLAGS F> inline BasicHashtable<F>::~BasicHashtable() { |
59 template <MEMFLAGS F> inline BasicHashtable<F>::~BasicHashtable() { |
58 for (int i = 0; i < _entry_blocks->length(); i++) { |
60 for (int i = 0; i < _entry_blocks->length(); i++) { |
59 FREE_C_HEAP_ARRAY(char, _entry_blocks->at(i)); |
61 FREE_C_HEAP_ARRAY(char, _entry_blocks->at(i)); |
99 } |
101 } |
100 |
102 |
101 |
103 |
102 template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) { |
104 template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) { |
103 _buckets[index].set_entry(entry); |
105 _buckets[index].set_entry(entry); |
|
106 if (entry != NULL) { |
|
107 JFR_ONLY(_stats_rate.add();) |
|
108 } else { |
|
109 JFR_ONLY(_stats_rate.remove();) |
|
110 } |
104 } |
111 } |
105 |
112 |
106 |
113 |
107 template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) { |
114 template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) { |
108 entry->set_next(bucket(index)); |
115 entry->set_next(bucket(index)); |
109 _buckets[index].set_entry(entry); |
116 _buckets[index].set_entry(entry); |
110 ++_number_of_entries; |
117 ++_number_of_entries; |
|
118 JFR_ONLY(_stats_rate.add();) |
111 } |
119 } |
112 |
120 |
113 template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) { |
121 template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) { |
114 entry->set_next(_free_list); |
122 entry->set_next(_free_list); |
115 _free_list = entry; |
123 _free_list = entry; |
116 --_number_of_entries; |
124 --_number_of_entries; |
|
125 JFR_ONLY(_stats_rate.remove();) |
117 } |
126 } |
118 |
127 |
119 #endif // SHARE_UTILITIES_HASHTABLE_INLINE_HPP |
128 #endif // SHARE_UTILITIES_HASHTABLE_INLINE_HPP |