131 // The following methods use order access methods to avoid race 132 // conditions in multiprocessor systems. 133 BasicHashtableEntry<F>* get_entry() const; 134 void set_entry(BasicHashtableEntry<F>* l); 135 136 // The following method is not MT-safe and must be done under lock. 137 BasicHashtableEntry<F>** entry_addr() { return &_entry; } 138 139 }; 140 141 142 template <MEMFLAGS F> class BasicHashtable : public CHeapObj<F> { 143 friend class VMStructs; 144 145 public: 146 BasicHashtable(int table_size, int entry_size); 147 BasicHashtable(int table_size, int entry_size, 148 HashtableBucket<F>* buckets, int number_of_entries); 149 150 // Sharing support. 151 void copy_buckets(char** top, char* end); 152 void copy_table(char** top, char* end); 153 154 // Bucket handling 155 int hash_to_index(unsigned int full_hash) const { 156 int h = full_hash % _table_size; 157 assert(h >= 0 && h < _table_size, "Illegal hash value"); 158 return h; 159 } 160 161 private: 162 // Instance variables 163 int _table_size; 164 HashtableBucket<F>* _buckets; 165 BasicHashtableEntry<F>* volatile _free_list; 166 char* _first_free_entry; 167 char* _end_block; 168 int _entry_size; 169 volatile int _number_of_entries; 170 171 protected: 172 | 131 // The following methods use order access methods to avoid race 132 // conditions in multiprocessor systems. 133 BasicHashtableEntry<F>* get_entry() const; 134 void set_entry(BasicHashtableEntry<F>* l); 135 136 // The following method is not MT-safe and must be done under lock. 137 BasicHashtableEntry<F>** entry_addr() { return &_entry; } 138 139 }; 140 141 142 template <MEMFLAGS F> class BasicHashtable : public CHeapObj<F> { 143 friend class VMStructs; 144 145 public: 146 BasicHashtable(int table_size, int entry_size); 147 BasicHashtable(int table_size, int entry_size, 148 HashtableBucket<F>* buckets, int number_of_entries); 149 150 // Sharing support. 151 size_t count_bytes_for_buckets(); 152 size_t count_bytes_for_table(); 153 void copy_buckets(char* top, char* end); 154 void copy_table(char* top, char* end); 155 156 // Bucket handling 157 int hash_to_index(unsigned int full_hash) const { 158 int h = full_hash % _table_size; 159 assert(h >= 0 && h < _table_size, "Illegal hash value"); 160 return h; 161 } 162 163 private: 164 // Instance variables 165 int _table_size; 166 HashtableBucket<F>* _buckets; 167 BasicHashtableEntry<F>* volatile _free_list; 168 char* _first_free_entry; 169 char* _end_block; 170 int _entry_size; 171 volatile int _number_of_entries; 172 173 protected: 174 |