src/share/vm/gc_implementation/g1/sparsePRT.hpp

Print this page
rev 6583 : 8047328: Change typedef CardIdx_t from int to uint16_t
Summary: Changed the typedef and made the necessary changes to code interacting with the SparsePRTEntry class.
Reviewed-by:
Contributed-by: andreas.sjoberg@oracle.com

*** 41,70 **** // unsynchronized reads/iterations, as long as expansions caused by // insertions only enqueue old versions for deletions, but do not delete // old versions synchronously. class SparsePRTEntry: public CHeapObj<mtGC> { - public: - enum SomePublicConstants { - NullEntry = -1, - UnrollFactor = 4 - }; private: RegionIdx_t _region_ind; int _next_index; ! CardIdx_t _cards[1]; // WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length. // It should always be the last data member. public: // Returns the size of the entry, used for entry allocation. ! static size_t size() { return sizeof(SparsePRTEntry) + sizeof(CardIdx_t) * (cards_num() - 1); } // Returns the size of the card array. static int cards_num() { ! // The number of cards should be a multiple of 4, because that's our current ! // unrolling factor. ! static const int s = MAX2<int>(G1RSetSparseRegionEntries & ~(UnrollFactor - 1), UnrollFactor); ! return s; } // Set the region_ind to the given value, and delete all cards. inline void init(RegionIdx_t region_ind); --- 41,67 ---- // unsynchronized reads/iterations, as long as expansions caused by // insertions only enqueue old versions for deletions, but do not delete // old versions synchronously. class SparsePRTEntry: public CHeapObj<mtGC> { private: RegionIdx_t _region_ind; int _next_index; ! int _next_null; ! CardIdx_t _cards[4]; // WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length. // It should always be the last data member. + // Note regarding the declared length of _cards: + // it is used to make sizeof(SparsePRTEntry) be an even multiple of 4, + // in order to force alignment that could otherwise cause SIGBUS errors when + // reading the int variables. public: // Returns the size of the entry, used for entry allocation. ! static size_t size() { return sizeof(SparsePRTEntry) + sizeof(CardIdx_t) * (cards_num() - 4); } // Returns the size of the card array. static int cards_num() { ! return G1RSetSparseRegionEntries; } // Set the region_ind to the given value, and delete all cards. inline void init(RegionIdx_t region_ind);
*** 78,88 **** // Returns "true" iff the entry contains the given card index. inline bool contains_card(CardIdx_t card_index) const; // Returns the number of non-NULL card entries. ! inline int num_valid_cards() const; // Requires that the entry not contain the given card index. If there is // space available, add the given card index to the entry and return // "true"; otherwise, return "false" to indicate that the entry is full. enum AddCardResult { --- 75,85 ---- // Returns "true" iff the entry contains the given card index. inline bool contains_card(CardIdx_t card_index) const; // Returns the number of non-NULL card entries. ! inline int num_valid_cards() const { return _next_null; } // Requires that the entry not contain the given card index. If there is // space available, add the given card index to the entry and return // "true"; otherwise, return "false" to indicate that the entry is full. enum AddCardResult {
*** 95,115 **** // Copy the current entry's cards into "cards". inline void copy_cards(CardIdx_t* cards) const; // Copy the current entry's cards into the "_card" array of "e." inline void copy_cards(SparsePRTEntry* e) const; ! inline CardIdx_t card(int i) const { return _cards[i]; } }; class RSHashTable : public CHeapObj<mtGC> { friend class RSHashTableIter; - enum SomePrivateConstants { - NullEntry = -1 - }; size_t _capacity; size_t _capacity_mask; size_t _occupied_entries; size_t _occupied_cards; --- 92,113 ---- // Copy the current entry's cards into "cards". inline void copy_cards(CardIdx_t* cards) const; // Copy the current entry's cards into the "_card" array of "e." inline void copy_cards(SparsePRTEntry* e) const; ! inline CardIdx_t card(int i) const { ! assert(i >= 0, "must be nonnegative"); ! assert(i < cards_num(), "range checking"); ! return _cards[i]; ! } }; class RSHashTable : public CHeapObj<mtGC> { friend class RSHashTableIter; size_t _capacity; size_t _capacity_mask; size_t _occupied_entries; size_t _occupied_cards;
*** 134,143 **** --- 132,145 ---- public: RSHashTable(size_t capacity); ~RSHashTable(); + enum SomePublicConstants { + NullEntry = -1 + }; + // Attempts to ensure that the given card_index in the given region is in // the sparse table. If successful (because the card was already // present, or because it was successfully added) returns "true". // Otherwise, returns "false" to indicate that the addition would // overflow the entry for the region. The caller must transfer these
*** 173,185 **** int _bl_ind; // [-1, 0.._rsht->_capacity) short _card_ind; // [0..SparsePRTEntry::cards_num()) RSHashTable* _rsht; // If the bucket list pointed to by _bl_ind contains a card, sets ! // _bl_ind to the index of that entry, and returns the card. ! // Otherwise, returns SparseEntry::NullEntry. ! CardIdx_t find_first_card_in_list(); // Computes the proper card index for the card whose offset in the // current region (as indicated by _bl_ind) is "ci". // This is subject to errors when there is iteration concurrent with // modification, but these errors should be benign. --- 175,188 ---- int _bl_ind; // [-1, 0.._rsht->_capacity) short _card_ind; // [0..SparsePRTEntry::cards_num()) RSHashTable* _rsht; // If the bucket list pointed to by _bl_ind contains a card, sets ! // _bl_ind to the index of that entry, ! // updates the card reference to contain the found card and returns true. ! // Otherwise, returns false. ! bool find_first_card_in_list(CardIdx_t & ); // Computes the proper card index for the card whose offset in the // current region (as indicated by _bl_ind) is "ci". // This is subject to errors when there is iteration concurrent with // modification, but these errors should be benign.