1.1 --- a/src/share/vm/gc_implementation/g1/sparsePRT.hpp Thu Jun 11 12:40:00 2009 -0700 1.2 +++ b/src/share/vm/gc_implementation/g1/sparsePRT.hpp Thu Jun 11 17:19:33 2009 -0700 1.3 @@ -35,32 +35,32 @@ 1.4 1.5 class SparsePRTEntry: public CHeapObj { 1.6 public: 1.7 + 1.8 enum SomePublicConstants { 1.9 - CardsPerEntry = (short)4, 1.10 - NullEntry = (short)-1, 1.11 - DeletedEntry = (short)-2 1.12 + CardsPerEntry = 4, 1.13 + NullEntry = -1 1.14 }; 1.15 1.16 private: 1.17 - short _region_ind; 1.18 - short _next_index; 1.19 - short _cards[CardsPerEntry]; 1.20 + RegionIdx_t _region_ind; 1.21 + int _next_index; 1.22 + CardIdx_t _cards[CardsPerEntry]; 1.23 1.24 public: 1.25 1.26 // Set the region_ind to the given value, and delete all cards. 1.27 - inline void init(short region_ind); 1.28 + inline void init(RegionIdx_t region_ind); 1.29 1.30 - short r_ind() const { return _region_ind; } 1.31 + RegionIdx_t r_ind() const { return _region_ind; } 1.32 bool valid_entry() const { return r_ind() >= 0; } 1.33 - void set_r_ind(short rind) { _region_ind = rind; } 1.34 + void set_r_ind(RegionIdx_t rind) { _region_ind = rind; } 1.35 1.36 - short next_index() const { return _next_index; } 1.37 - short* next_index_addr() { return &_next_index; } 1.38 - void set_next_index(short ni) { _next_index = ni; } 1.39 + int next_index() const { return _next_index; } 1.40 + int* next_index_addr() { return &_next_index; } 1.41 + void set_next_index(int ni) { _next_index = ni; } 1.42 1.43 // Returns "true" iff the entry contains the given card index. 1.44 - inline bool contains_card(short card_index) const; 1.45 + inline bool contains_card(CardIdx_t card_index) const; 1.46 1.47 // Returns the number of non-NULL card entries. 1.48 inline int num_valid_cards() const; 1.49 @@ -73,14 +73,14 @@ 1.50 found, 1.51 added 1.52 }; 1.53 - inline AddCardResult add_card(short card_index); 1.54 + inline AddCardResult add_card(CardIdx_t card_index); 1.55 1.56 // Copy the current entry's cards into "cards". 1.57 - inline void copy_cards(short* cards) const; 1.58 + inline void copy_cards(CardIdx_t* cards) const; 1.59 // Copy the current entry's cards into the "_card" array of "e." 1.60 inline void copy_cards(SparsePRTEntry* e) const; 1.61 1.62 - inline short card(int i) const { return _cards[i]; } 1.63 + inline CardIdx_t card(int i) const { return _cards[i]; } 1.64 }; 1.65 1.66 1.67 @@ -98,9 +98,9 @@ 1.68 size_t _occupied_cards; 1.69 1.70 SparsePRTEntry* _entries; 1.71 - short* _buckets; 1.72 - short _free_region; 1.73 - short _free_list; 1.74 + int* _buckets; 1.75 + int _free_region; 1.76 + int _free_list; 1.77 1.78 static RSHashTable* _head_deleted_list; 1.79 RSHashTable* _next_deleted; 1.80 @@ -113,20 +113,20 @@ 1.81 // operations, and that the the table be less than completely full. If 1.82 // an entry for "region_ind" is already in the table, finds it and 1.83 // returns its address; otherwise returns "NULL." 1.84 - SparsePRTEntry* entry_for_region_ind(short region_ind) const; 1.85 + SparsePRTEntry* entry_for_region_ind(RegionIdx_t region_ind) const; 1.86 1.87 // Requires that the caller hold a lock preventing parallel modifying 1.88 // operations, and that the the table be less than completely full. If 1.89 // an entry for "region_ind" is already in the table, finds it and 1.90 // returns its address; otherwise allocates, initializes, inserts and 1.91 // returns a new entry for "region_ind". 1.92 - SparsePRTEntry* entry_for_region_ind_create(short region_ind); 1.93 + SparsePRTEntry* entry_for_region_ind_create(RegionIdx_t region_ind); 1.94 1.95 // Returns the index of the next free entry in "_entries". 1.96 - short alloc_entry(); 1.97 + int alloc_entry(); 1.98 // Declares the entry "fi" to be free. (It must have already been 1.99 // deleted from any bucket lists. 1.100 - void free_entry(short fi); 1.101 + void free_entry(int fi); 1.102 1.103 public: 1.104 RSHashTable(size_t capacity); 1.105 @@ -138,12 +138,12 @@ 1.106 // Otherwise, returns "false" to indicate that the addition would 1.107 // overflow the entry for the region. The caller must transfer these 1.108 // entries to a larger-capacity representation. 1.109 - bool add_card(short region_id, short card_index); 1.110 + bool add_card(RegionIdx_t region_id, CardIdx_t card_index); 1.111 1.112 - bool get_cards(short region_id, short* cards); 1.113 - bool delete_entry(short region_id); 1.114 + bool get_cards(RegionIdx_t region_id, CardIdx_t* cards); 1.115 + bool delete_entry(RegionIdx_t region_id); 1.116 1.117 - bool contains_card(short region_id, short card_index) const; 1.118 + bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const; 1.119 1.120 void add_entry(SparsePRTEntry* e); 1.121 1.122 @@ -162,51 +162,49 @@ 1.123 1.124 static void add_to_deleted_list(RSHashTable* rsht); 1.125 static RSHashTable* get_from_deleted_list(); 1.126 - 1.127 - 1.128 }; 1.129 1.130 - // ValueObj because will be embedded in HRRS iterator. 1.131 +// ValueObj because will be embedded in HRRS iterator. 1.132 class RSHashTableIter VALUE_OBJ_CLASS_SPEC { 1.133 - short _tbl_ind; 1.134 - short _bl_ind; 1.135 - short _card_ind; 1.136 - RSHashTable* _rsht; 1.137 - size_t _heap_bot_card_ind; 1.138 + int _tbl_ind; // [-1, 0.._rsht->_capacity) 1.139 + int _bl_ind; // [-1, 0.._rsht->_capacity) 1.140 + short _card_ind; // [0..CardsPerEntry) 1.141 + RSHashTable* _rsht; 1.142 + size_t _heap_bot_card_ind; 1.143 1.144 - enum SomePrivateConstants { 1.145 - CardsPerRegion = HeapRegion::GrainBytes >> CardTableModRefBS::card_shift 1.146 - }; 1.147 + enum SomePrivateConstants { 1.148 + CardsPerRegion = HeapRegion::GrainBytes >> CardTableModRefBS::card_shift 1.149 + }; 1.150 1.151 - // If the bucket list pointed to by _bl_ind contains a card, sets 1.152 - // _bl_ind to the index of that entry, and returns the card. 1.153 - // Otherwise, returns SparseEntry::NullEnty. 1.154 - short find_first_card_in_list(); 1.155 - // Computes the proper card index for the card whose offset in the 1.156 - // current region (as indicated by _bl_ind) is "ci". 1.157 - // This is subject to errors when there is iteration concurrent with 1.158 - // modification, but these errors should be benign. 1.159 - size_t compute_card_ind(short ci); 1.160 + // If the bucket list pointed to by _bl_ind contains a card, sets 1.161 + // _bl_ind to the index of that entry, and returns the card. 1.162 + // Otherwise, returns SparseEntry::NullEntry. 1.163 + CardIdx_t find_first_card_in_list(); 1.164 1.165 - public: 1.166 - RSHashTableIter(size_t heap_bot_card_ind) : 1.167 - _tbl_ind(RSHashTable::NullEntry), 1.168 - _bl_ind(RSHashTable::NullEntry), 1.169 - _card_ind((SparsePRTEntry::CardsPerEntry-1)), 1.170 - _rsht(NULL), 1.171 - _heap_bot_card_ind(heap_bot_card_ind) 1.172 - {} 1.173 + // Computes the proper card index for the card whose offset in the 1.174 + // current region (as indicated by _bl_ind) is "ci". 1.175 + // This is subject to errors when there is iteration concurrent with 1.176 + // modification, but these errors should be benign. 1.177 + size_t compute_card_ind(CardIdx_t ci); 1.178 1.179 - void init(RSHashTable* rsht) { 1.180 - _rsht = rsht; 1.181 - _tbl_ind = -1; // So that first increment gets to 0. 1.182 - _bl_ind = RSHashTable::NullEntry; 1.183 - _card_ind = (SparsePRTEntry::CardsPerEntry-1); 1.184 - } 1.185 +public: 1.186 + RSHashTableIter(size_t heap_bot_card_ind) : 1.187 + _tbl_ind(RSHashTable::NullEntry), 1.188 + _bl_ind(RSHashTable::NullEntry), 1.189 + _card_ind((SparsePRTEntry::CardsPerEntry-1)), 1.190 + _rsht(NULL), 1.191 + _heap_bot_card_ind(heap_bot_card_ind) 1.192 + {} 1.193 1.194 - bool has_next(size_t& card_index); 1.195 + void init(RSHashTable* rsht) { 1.196 + _rsht = rsht; 1.197 + _tbl_ind = -1; // So that first increment gets to 0. 1.198 + _bl_ind = RSHashTable::NullEntry; 1.199 + _card_ind = (SparsePRTEntry::CardsPerEntry-1); 1.200 + } 1.201 1.202 - }; 1.203 + bool has_next(size_t& card_index); 1.204 +}; 1.205 1.206 // Concurrent accesss to a SparsePRT must be serialized by some external 1.207 // mutex. 1.208 @@ -238,7 +236,6 @@ 1.209 SparsePRT* next_expanded() { return _next_expanded; } 1.210 void set_next_expanded(SparsePRT* nxt) { _next_expanded = nxt; } 1.211 1.212 - 1.213 static SparsePRT* _head_expanded_list; 1.214 1.215 public: 1.216 @@ -255,16 +252,16 @@ 1.217 // Otherwise, returns "false" to indicate that the addition would 1.218 // overflow the entry for the region. The caller must transfer these 1.219 // entries to a larger-capacity representation. 1.220 - bool add_card(short region_id, short card_index); 1.221 + bool add_card(RegionIdx_t region_id, CardIdx_t card_index); 1.222 1.223 // If the table hold an entry for "region_ind", Copies its 1.224 // cards into "cards", which must be an array of length at least 1.225 // "CardsPerEntry", and returns "true"; otherwise, returns "false". 1.226 - bool get_cards(short region_ind, short* cards); 1.227 + bool get_cards(RegionIdx_t region_ind, CardIdx_t* cards); 1.228 1.229 // If there is an entry for "region_ind", removes it and return "true"; 1.230 // otherwise returns "false." 1.231 - bool delete_entry(short region_ind); 1.232 + bool delete_entry(RegionIdx_t region_ind); 1.233 1.234 // Clear the table, and reinitialize to initial capacity. 1.235 void clear(); 1.236 @@ -276,13 +273,12 @@ 1.237 static void cleanup_all(); 1.238 RSHashTable* cur() const { return _cur; } 1.239 1.240 - 1.241 void init_iterator(SparsePRTIter* sprt_iter); 1.242 1.243 static void add_to_expanded_list(SparsePRT* sprt); 1.244 static SparsePRT* get_from_expanded_list(); 1.245 1.246 - bool contains_card(short region_id, short card_index) const { 1.247 + bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const { 1.248 return _next->contains_card(region_id, card_index); 1.249 } 1.250