< prev index next >

src/hotspot/share/gc/g1/sparsePRT.cpp

Print this page

 88 float RSHashTable::TableOccupancyFactor = 0.5f;
 89 
 90 RSHashTable::RSHashTable(size_t capacity) :
 91   _num_entries(0),
 92   _capacity(capacity),
 93   _capacity_mask(capacity-1),
 94   _occupied_entries(0),
 95   _occupied_cards(0),
 96   _entries(NULL),
 97   _buckets(NEW_C_HEAP_ARRAY(int, capacity, mtGC)),
 98   _free_region(0),
 99   _free_list(NullEntry)
100 {
101   _num_entries = (capacity * TableOccupancyFactor) + 1;
102   _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC);
103   clear();
104 }
105 
106 RSHashTable::~RSHashTable() {
107   FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries);
108   _entries = NULL;
109   FREE_C_HEAP_ARRAY(int, _buckets);
110   _buckets = NULL;
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);

 88 float RSHashTable::TableOccupancyFactor = 0.5f;
 89 
 90 RSHashTable::RSHashTable(size_t capacity) :
 91   _num_entries(0),
 92   _capacity(capacity),
 93   _capacity_mask(capacity-1),
 94   _occupied_entries(0),
 95   _occupied_cards(0),
 96   _entries(NULL),
 97   _buckets(NEW_C_HEAP_ARRAY(int, capacity, mtGC)),
 98   _free_region(0),
 99   _free_list(NullEntry)
100 {
101   _num_entries = (capacity * TableOccupancyFactor) + 1;
102   _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC);
103   clear();
104 }
105 
106 RSHashTable::~RSHashTable() {
107   FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries);

108   FREE_C_HEAP_ARRAY(int, _buckets);

109 }
110 
111 void RSHashTable::clear() {
112   _occupied_entries = 0;
113   _occupied_cards = 0;
114   guarantee(_entries != NULL, "INV");
115   guarantee(_buckets != NULL, "INV");
116 
117   guarantee(_capacity <= ((size_t)1 << (sizeof(int)*BitsPerByte-1)) - 1,
118                 "_capacity too large");
119 
120   // This will put -1 == NullEntry in the key field of all entries.
121   memset((void*)_entries, NullEntry, _num_entries * SparsePRTEntry::size());
122   memset((void*)_buckets, NullEntry, _capacity * sizeof(int));
123   _free_list = NullEntry;
124   _free_region = 0;
125 }
126 
127 bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) {
128   SparsePRTEntry* e = entry_for_region_ind_create(region_ind);
< prev index next >