37 // Initialize a table. 38 39 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size) { 40 // Called on startup, no locking needed 41 initialize(table_size, entry_size, 0); 42 _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC); 43 for (int index = 0; index < _table_size; index++) { 44 _buckets[index].clear(); 45 } 46 } 47 48 49 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size, 50 HashtableBucket<F>* buckets, 51 int number_of_entries) { 52 // Called on startup, no locking needed 53 initialize(table_size, entry_size, number_of_entries); 54 _buckets = buckets; 55 } 56 57 58 template <MEMFLAGS F> inline void BasicHashtable<F>::initialize(int table_size, int entry_size, 59 int number_of_entries) { 60 // Called on startup, no locking needed 61 _table_size = table_size; 62 _entry_size = entry_size; 63 _free_list = NULL; 64 _first_free_entry = NULL; 65 _end_block = NULL; 66 _number_of_entries = number_of_entries; 67 } 68 69 70 // The following method is MT-safe and may be used with caution. 71 template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) const { 72 return _buckets[i].get_entry(); 73 } 74 75 76 template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) { 77 // Warning: Preserve store ordering. The PackageEntryTable, ModuleEntryTable and 78 // SystemDictionary are read without locks. The new entry must be 79 // complete before other threads can be allowed to see it 80 // via a store to _buckets[index]. 81 OrderAccess::release_store(&_entry, l); 82 } 83 84 85 template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const { 86 // Warning: Preserve load ordering. The PackageEntryTable, ModuleEntryTable and | 37 // Initialize a table. 38 39 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size) { 40 // Called on startup, no locking needed 41 initialize(table_size, entry_size, 0); 42 _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC); 43 for (int index = 0; index < _table_size; index++) { 44 _buckets[index].clear(); 45 } 46 } 47 48 49 template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size, 50 HashtableBucket<F>* buckets, 51 int number_of_entries) { 52 // Called on startup, no locking needed 53 initialize(table_size, entry_size, number_of_entries); 54 _buckets = buckets; 55 } 56 57 template <MEMFLAGS F> inline BasicHashtable<F>::~BasicHashtable() { 58 for (int i = 0; i < _entry_blocks->length(); i++) { 59 FREE_C_HEAP_ARRAY(char, _entry_blocks->at(i)); 60 } 61 delete _entry_blocks; 62 free_buckets(); 63 } 64 65 template <MEMFLAGS F> inline void BasicHashtable<F>::initialize(int table_size, int entry_size, 66 int number_of_entries) { 67 // Called on startup, no locking needed 68 _table_size = table_size; 69 _entry_size = entry_size; 70 _free_list = NULL; 71 _first_free_entry = NULL; 72 _end_block = NULL; 73 _number_of_entries = number_of_entries; 74 _entry_blocks = new(ResourceObj::C_HEAP, F) GrowableArray<char*>(4, true, F); 75 } 76 77 78 // The following method is MT-safe and may be used with caution. 79 template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) const { 80 return _buckets[i].get_entry(); 81 } 82 83 84 template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) { 85 // Warning: Preserve store ordering. The PackageEntryTable, ModuleEntryTable and 86 // SystemDictionary are read without locks. The new entry must be 87 // complete before other threads can be allowed to see it 88 // via a store to _buckets[index]. 89 OrderAccess::release_store(&_entry, l); 90 } 91 92 93 template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const { 94 // Warning: Preserve load ordering. The PackageEntryTable, ModuleEntryTable and |