103 if (_entries != NULL) { 104 FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries); 105 _entries = NULL; 106 } 107 if (_buckets != NULL) { 108 FREE_C_HEAP_ARRAY(int, _buckets); 109 _buckets = NULL; 110 } 111 } 112 113 void RSHashTable::clear() { 114 _occupied_entries = 0; 115 _occupied_cards = 0; 116 guarantee(_entries != NULL, "INV"); 117 guarantee(_buckets != NULL, "INV"); 118 119 guarantee(_capacity <= ((size_t)1 << (sizeof(int)*BitsPerByte-1)) - 1, 120 "_capacity too large"); 121 122 // This will put -1 == NullEntry in the key field of all entries. 123 memset(_entries, NullEntry, _num_entries * SparsePRTEntry::size()); 124 memset(_buckets, NullEntry, _capacity * sizeof(int)); 125 _free_list = NullEntry; 126 _free_region = 0; 127 } 128 129 bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) { 130 SparsePRTEntry* e = entry_for_region_ind_create(region_ind); 131 assert(e != NULL && e->r_ind() == region_ind, 132 "Postcondition of call above."); 133 SparsePRTEntry::AddCardResult res = e->add_card(card_index); 134 if (res == SparsePRTEntry::added) _occupied_cards++; 135 assert(e->num_valid_cards() > 0, "Postcondition"); 136 return res != SparsePRTEntry::overflow; 137 } 138 139 SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) const { 140 int ind = (int) (region_ind & capacity_mask()); 141 int cur_ind = _buckets[ind]; 142 SparsePRTEntry* cur; 143 while (cur_ind != NullEntry && 144 (cur = entry(cur_ind))->r_ind() != region_ind) { | 103 if (_entries != NULL) { 104 FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries); 105 _entries = NULL; 106 } 107 if (_buckets != NULL) { 108 FREE_C_HEAP_ARRAY(int, _buckets); 109 _buckets = NULL; 110 } 111 } 112 113 void RSHashTable::clear() { 114 _occupied_entries = 0; 115 _occupied_cards = 0; 116 guarantee(_entries != NULL, "INV"); 117 guarantee(_buckets != NULL, "INV"); 118 119 guarantee(_capacity <= ((size_t)1 << (sizeof(int)*BitsPerByte-1)) - 1, 120 "_capacity too large"); 121 122 // This will put -1 == NullEntry in the key field of all entries. 123 memset((void*)_entries, NullEntry, _num_entries * SparsePRTEntry::size()); 124 memset((void*)_buckets, NullEntry, _capacity * sizeof(int)); 125 _free_list = NullEntry; 126 _free_region = 0; 127 } 128 129 bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) { 130 SparsePRTEntry* e = entry_for_region_ind_create(region_ind); 131 assert(e != NULL && e->r_ind() == region_ind, 132 "Postcondition of call above."); 133 SparsePRTEntry::AddCardResult res = e->add_card(card_index); 134 if (res == SparsePRTEntry::added) _occupied_cards++; 135 assert(e->num_valid_cards() > 0, "Postcondition"); 136 return res != SparsePRTEntry::overflow; 137 } 138 139 SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) const { 140 int ind = (int) (region_ind & capacity_mask()); 141 int cur_ind = _buckets[ind]; 142 SparsePRTEntry* cur; 143 while (cur_ind != NullEntry && 144 (cur = entry(cur_ind))->r_ind() != region_ind) { |