26
26
#define SHARE_GC_G1_G1CARDSET_HPP
27
27
28
28
#include " memory/allocation.hpp"
29
- #include " memory/padded.hpp"
30
- #include " oops/oopsHierarchy.hpp"
31
29
#include " utilities/concurrentHashTable.hpp"
32
- #include " utilities/lockFreeStack.hpp"
33
30
34
31
class G1CardSetAllocOptions ;
35
32
class G1CardSetHashTable ;
@@ -147,10 +144,10 @@ class G1CardSetConfiguration {
147
144
class G1CardSetCoarsenStats {
148
145
public:
149
146
// Number of entries in the statistics tables: since we index with the source
150
- // cardset of the coarsening, this is the total number of combinations of
151
- // card sets - 1.
147
+ // container of the coarsening, this is the total number of combinations of
148
+ // card set containers - 1.
152
149
static constexpr size_t NumCoarsenCategories = 7 ;
153
- // Coarsening statistics for the possible CardSetPtr in the Howl card set
150
+ // Coarsening statistics for the possible ContainerPtr in the Howl card set
154
151
// start from this offset.
155
152
static constexpr size_t CoarsenHowlOffset = 4 ;
156
153
@@ -173,14 +170,14 @@ class G1CardSetCoarsenStats {
173
170
void print_on (outputStream* out);
174
171
};
175
172
176
- // Sparse set of card indexes comprising a remembered set on the Java heap. Card
173
+ // Set of card indexes comprising a remembered set on the Java heap. Card
177
174
// size is assumed to be card table card size.
178
175
//
179
176
// Technically it is implemented using a ConcurrentHashTable that stores a card
180
177
// set container for every region containing at least one card.
181
178
//
182
179
// There are in total five different containers, encoded in the ConcurrentHashTable
183
- // node as CardSetPtr . A CardSetPtr may cover the whole region or just a part of
180
+ // node as ContainerPtr . A ContainerPtr may cover the whole region or just a part of
184
181
// it.
185
182
// See its description below for more information.
186
183
class G1CardSet : public CHeapObj <mtGCCardSet> {
@@ -194,46 +191,46 @@ class G1CardSet : public CHeapObj<mtGCCardSet> {
194
191
static G1CardSetCoarsenStats _coarsen_stats; // Coarsening statistics since VM start.
195
192
static G1CardSetCoarsenStats _last_coarsen_stats; // Coarsening statistics at last GC.
196
193
public:
197
- // Two lower bits are used to encode the card storage types
198
- static const uintptr_t CardSetPtrHeaderSize = 2 ;
194
+ // Two lower bits are used to encode the card set container types
195
+ static const uintptr_t ContainerPtrHeaderSize = 2 ;
199
196
200
- // CardSetPtr represents the card storage type of a given covered area. It encodes
201
- // a type in the LSBs, in addition to having a few significant values.
197
+ // ContainerPtr represents the card set container type of a given covered area.
198
+ // It encodes a type in the LSBs, in addition to having a few significant values.
202
199
//
203
200
// Possible encodings:
204
201
//
205
202
// 0...00000 free (Empty, should never happen)
206
- // 1...11111 full All card indexes in the whole area this CardSetPtr covers are part of this container.
207
- // X...XXX00 inline-ptr-cards A handful of card indexes covered by this CardSetPtr are encoded within the CardSetPtr .
203
+ // 1...11111 full All card indexes in the whole area this ContainerPtr covers are part of this container.
204
+ // X...XXX00 inline-ptr-cards A handful of card indexes covered by this ContainerPtr are encoded within the ContainerPtr .
208
205
// X...XXX01 array of cards The container is a contiguous array of card indexes.
209
206
// X...XXX10 bitmap The container uses a bitmap to determine whether a given index is part of this set.
210
- // X...XXX11 howl This is a card set container containing an array of CardSetPtr , with each CardSetPtr
207
+ // X...XXX11 howl This is a card set container containing an array of ContainerPtr , with each ContainerPtr
211
208
// limited to a sub-range of the original range. Currently only one level of this
212
209
// container is supported.
213
- typedef void * CardSetPtr ;
210
+ using ContainerPtr = void *;
214
211
// Coarsening happens in the order below:
215
- // CardSetInlinePtr -> CardSetArrayOfCards -> CardSetHowl -> Full
216
- // Corsening of containers inside the CardSetHowl happens in the order:
217
- // CardSetInlinePtr -> CardSetArrayOfCards -> CardSetBitMap -> Full
218
- static const uintptr_t CardSetInlinePtr = 0x0 ;
219
- static const uintptr_t CardSetArrayOfCards = 0x1 ;
220
- static const uintptr_t CardSetBitMap = 0x2 ;
221
- static const uintptr_t CardSetHowl = 0x3 ;
212
+ // ContainerInlinePtr -> ContainerArrayOfCards -> ContainerHowl -> Full
213
+ // Corsening of containers inside the ContainerHowl happens in the order:
214
+ // ContainerInlinePtr -> ContainerArrayOfCards -> ContainerBitMap -> Full
215
+ static const uintptr_t ContainerInlinePtr = 0x0 ;
216
+ static const uintptr_t ContainerArrayOfCards = 0x1 ;
217
+ static const uintptr_t ContainerBitMap = 0x2 ;
218
+ static const uintptr_t ContainerHowl = 0x3 ;
222
219
223
220
// The special sentinel values
224
- static constexpr CardSetPtr FreeCardSet = nullptr ;
225
- // Unfortunately we can't make (G1CardSet::CardSetPtr )-1 constexpr because
221
+ static constexpr ContainerPtr FreeCardSet = nullptr ;
222
+ // Unfortunately we can't make (G1CardSet::ContainerPtr )-1 constexpr because
226
223
// reinterpret_casts are forbidden in constexprs. Use a regular static instead.
227
- static CardSetPtr FullCardSet;
224
+ static ContainerPtr FullCardSet;
228
225
229
- static const uintptr_t CardSetPtrTypeMask = ((uintptr_t )1 << CardSetPtrHeaderSize ) - 1 ;
226
+ static const uintptr_t ContainerPtrTypeMask = ((uintptr_t )1 << ContainerPtrHeaderSize ) - 1 ;
230
227
231
- static CardSetPtr strip_card_set_type (CardSetPtr ptr) { return (CardSetPtr )((uintptr_t )ptr & ~CardSetPtrTypeMask ); }
228
+ static ContainerPtr strip_container_type (ContainerPtr ptr) { return (ContainerPtr )((uintptr_t )ptr & ~ContainerPtrTypeMask ); }
232
229
233
- static uint card_set_type (CardSetPtr ptr) { return (uintptr_t )ptr & CardSetPtrTypeMask ; }
230
+ static uint container_type (ContainerPtr ptr) { return (uintptr_t )ptr & ContainerPtrTypeMask ; }
234
231
235
232
template <class T >
236
- static T* card_set_ptr (CardSetPtr ptr);
233
+ static T* container_ptr (ContainerPtr ptr);
237
234
238
235
private:
239
236
G1CardSetMemoryManager* _mm;
@@ -245,42 +242,42 @@ class G1CardSet : public CHeapObj<mtGCCardSet> {
245
242
// be (slightly) more cards in the card set than this value in reality.
246
243
size_t _num_occupied;
247
244
248
- CardSetPtr make_card_set_ptr (void * value, uintptr_t type);
245
+ ContainerPtr make_container_ptr (void * value, uintptr_t type);
249
246
250
- CardSetPtr acquire_card_set (CardSetPtr volatile * card_set_addr );
251
- // Returns true if the card set should be released
252
- bool release_card_set (CardSetPtr card_set );
247
+ ContainerPtr acquire_container (ContainerPtr volatile * container_addr );
248
+ // Returns true if the card set container should be released
249
+ bool release_container (ContainerPtr container );
253
250
// Release card set and free if needed.
254
- void release_and_maybe_free_card_set (CardSetPtr card_set );
251
+ void release_and_maybe_free_container (ContainerPtr container );
255
252
// Release card set and free (and it must be freeable).
256
- void release_and_must_free_card_set (CardSetPtr card_set );
253
+ void release_and_must_free_container (ContainerPtr container );
257
254
258
- // Coarsens the CardSet cur_card_set to the next level; tries to replace the
259
- // previous CardSet with a new one which includes the given card_in_region.
260
- // coarsen_card_set does not transfer cards from cur_card_set
261
- // to the new card_set . Transfer is achieved by transfer_cards.
262
- // Returns true if this was the thread that coarsened the CardSet (and added the card).
263
- bool coarsen_card_set (CardSetPtr volatile * card_set_addr ,
264
- CardSetPtr cur_card_set ,
265
- uint card_in_region, bool within_howl = false );
255
+ // Coarsens the card set container cur_container to the next level; tries to replace the
256
+ // previous ContainerPtr with a new one which includes the given card_in_region.
257
+ // coarsen_container does not transfer cards from cur_container
258
+ // to the new container . Transfer is achieved by transfer_cards.
259
+ // Returns true if this was the thread that coarsened the container (and added the card).
260
+ bool coarsen_container (ContainerPtr volatile * container_addr ,
261
+ ContainerPtr cur_container ,
262
+ uint card_in_region, bool within_howl = false );
266
263
267
- CardSetPtr create_coarsened_array_of_cards (uint card_in_region, bool within_howl);
264
+ ContainerPtr create_coarsened_array_of_cards (uint card_in_region, bool within_howl);
268
265
269
266
// Transfer entries from source_card_set to a recently installed coarser storage type
270
- // We only need to transfer anything finer than CardSetBitMap . "Full" contains
267
+ // We only need to transfer anything finer than ContainerBitMap . "Full" contains
271
268
// all elements anyway.
272
- void transfer_cards (G1CardSetHashTableValue* table_entry, CardSetPtr source_card_set , uint card_region);
273
- void transfer_cards_in_howl (CardSetPtr parent_card_set, CardSetPtr source_card_set , uint card_region);
269
+ void transfer_cards (G1CardSetHashTableValue* table_entry, ContainerPtr source_container , uint card_region);
270
+ void transfer_cards_in_howl (ContainerPtr parent_container, ContainerPtr source_container , uint card_region);
274
271
275
- G1AddCardResult add_to_card_set (CardSetPtr volatile * card_set_addr, CardSetPtr card_set , uint card_region, uint card, bool increment_total = true );
272
+ G1AddCardResult add_to_container (ContainerPtr volatile * container_addr, ContainerPtr container , uint card_region, uint card, bool increment_total = true );
276
273
277
- G1AddCardResult add_to_inline_ptr (CardSetPtr volatile * card_set_addr, CardSetPtr card_set , uint card_in_region);
278
- G1AddCardResult add_to_array (CardSetPtr card_set , uint card_in_region);
279
- G1AddCardResult add_to_bitmap (CardSetPtr card_set , uint card_in_region);
280
- G1AddCardResult add_to_howl (CardSetPtr parent_card_set , uint card_region, uint card_in_region, bool increment_total = true );
274
+ G1AddCardResult add_to_inline_ptr (ContainerPtr volatile * container_addr, ContainerPtr container , uint card_in_region);
275
+ G1AddCardResult add_to_array (ContainerPtr container , uint card_in_region);
276
+ G1AddCardResult add_to_bitmap (ContainerPtr container , uint card_in_region);
277
+ G1AddCardResult add_to_howl (ContainerPtr parent_container , uint card_region, uint card_in_region, bool increment_total = true );
281
278
282
- G1CardSetHashTableValue* get_or_add_card_set (uint card_region, bool * should_grow_table);
283
- G1CardSetHashTableValue* get_card_set (uint card_region);
279
+ G1CardSetHashTableValue* get_or_add_container (uint card_region, bool * should_grow_table);
280
+ G1CardSetHashTableValue* get_container (uint card_region);
284
281
285
282
// Iterate over cards of a card set container during transfer of the cards from
286
283
// one container to another. Executes
@@ -289,11 +286,11 @@ class G1CardSet : public CHeapObj<mtGCCardSet> {
289
286
//
290
287
// on the given class.
291
288
template <class CardVisitor >
292
- void iterate_cards_during_transfer (CardSetPtr const card_set , CardVisitor& vl);
289
+ void iterate_cards_during_transfer (ContainerPtr const container , CardVisitor& vl);
293
290
294
- uint card_set_type_to_mem_object_type (uintptr_t type) const ;
291
+ uint container_type_to_mem_object_type (uintptr_t type) const ;
295
292
uint8_t * allocate_mem_object (uintptr_t type);
296
- void free_mem_object (CardSetPtr card_set );
293
+ void free_mem_object (ContainerPtr container );
297
294
298
295
public:
299
296
G1CardSetConfiguration* config () const { return _config; }
@@ -302,8 +299,8 @@ class G1CardSet : public CHeapObj<mtGCCardSet> {
302
299
G1CardSet (G1CardSetConfiguration* config, G1CardSetMemoryManager* mm);
303
300
virtual ~G1CardSet ();
304
301
305
- // Adds the given card to this set, returning an appropriate result. If added,
306
- // updates the total count.
302
+ // Adds the given card to this set, returning an appropriate result.
303
+ // If incremental_count is true and the card has been added, updates the total count.
307
304
G1AddCardResult add_card (uint card_region, uint card_in_region, bool increment_total = true );
308
305
309
306
bool contains_card (uint card_region, uint card_in_region);
@@ -351,14 +348,14 @@ class G1CardSet : public CHeapObj<mtGCCardSet> {
351
348
// start_iterate().
352
349
//
353
350
template <class CardOrRangeVisitor >
354
- void iterate_cards_or_ranges_in_container (CardSetPtr const card_set , CardOrRangeVisitor& cl);
351
+ void iterate_cards_or_ranges_in_container (ContainerPtr const container , CardOrRangeVisitor& cl);
355
352
356
- class CardSetPtrClosure {
353
+ class ContainerPtrClosure {
357
354
public:
358
- virtual void do_cardsetptr (uint region_idx, size_t num_occupied, CardSetPtr card_set ) = 0;
355
+ virtual void do_containerptr (uint region_idx, size_t num_occupied, ContainerPtr container ) = 0;
359
356
};
360
357
361
- void iterate_containers (CardSetPtrClosure * cl, bool safepoint = false );
358
+ void iterate_containers (ContainerPtrClosure * cl, bool safepoint = false );
362
359
363
360
class CardClosure {
364
361
public:
@@ -370,13 +367,13 @@ class G1CardSet : public CHeapObj<mtGCCardSet> {
370
367
371
368
class G1CardSetHashTableValue {
372
369
public:
373
- using CardSetPtr = G1CardSet::CardSetPtr ;
370
+ using ContainerPtr = G1CardSet::ContainerPtr ;
374
371
375
372
const uint _region_idx;
376
373
uint volatile _num_occupied;
377
- CardSetPtr volatile _card_set ;
374
+ ContainerPtr volatile _container ;
378
375
379
- G1CardSetHashTableValue (uint region_idx, CardSetPtr card_set ) : _region_idx(region_idx), _num_occupied(0 ), _card_set(card_set ) { }
376
+ G1CardSetHashTableValue (uint region_idx, ContainerPtr container ) : _region_idx(region_idx), _num_occupied(0 ), _container(container ) { }
380
377
};
381
378
382
379
class G1CardSetHashTableConfig : public StackObj {
@@ -391,6 +388,6 @@ class G1CardSetHashTableConfig : public StackObj {
391
388
static void free_node (void * context, void * memory, Value const & value);
392
389
};
393
390
394
- typedef ConcurrentHashTable<G1CardSetHashTableConfig, mtGCCardSet> CardSetHash ;
391
+ using CardSetHash = ConcurrentHashTable<G1CardSetHashTableConfig, mtGCCardSet>;
395
392
396
393
#endif // SHARE_GC_G1_G1CARDSET_HPP
0 commit comments