author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 55510 | 3e31a8beaae4 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52716
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4902
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4902
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4902
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52716
diff
changeset
|
25 |
#ifndef SHARE_GC_G1_SPARSEPRT_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52716
diff
changeset
|
26 |
#define SHARE_GC_G1_SPARSEPRT_HPP |
7397 | 27 |
|
30764 | 28 |
#include "gc/g1/g1CollectedHeap.hpp" |
29 |
#include "gc/g1/heapRegion.hpp" |
|
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49392
diff
changeset
|
30 |
#include "gc/shared/cardTableBarrierSet.hpp" |
7397 | 31 |
#include "memory/allocation.hpp" |
32 |
#include "runtime/mutex.hpp" |
|
46625 | 33 |
#include "utilities/align.hpp" |
7397 | 34 |
#include "utilities/globalDefinitions.hpp" |
35 |
||
1374 | 36 |
// Sparse remembered set for a heap region (the "owning" region). Maps |
37 |
// indices of other regions to short sequences of cards in the other region |
|
38 |
// that might contain pointers into the owner region. |
|
39 |
||
13195 | 40 |
class SparsePRTEntry: public CHeapObj<mtGC> { |
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
41 |
public: |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
42 |
// The type of a card entry. |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
43 |
typedef uint16_t card_elem_t; |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
44 |
|
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
45 |
private: |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
46 |
// We need to make sizeof(SparsePRTEntry) an even multiple of maximum member size, |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
47 |
// in order to force correct alignment that could otherwise cause SIGBUS errors |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
48 |
// when reading the member variables. This calculates the minimum number of card |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
49 |
// array elements required to get that alignment. |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
50 |
static const size_t card_array_alignment = sizeof(int) / sizeof(card_elem_t); |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
51 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
52 |
RegionIdx_t _region_ind; |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
53 |
int _next_index; |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
54 |
int _next_null; |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
55 |
// The actual cards stored in this array. |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
56 |
// WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length. |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
57 |
// It should always be the last data member. |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
58 |
card_elem_t _cards[card_array_alignment]; |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
59 |
|
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
60 |
// Copy the current entry's cards into "cards". |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
61 |
inline void copy_cards(card_elem_t* cards) const; |
1374 | 62 |
public: |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
63 |
// Returns the size of the entry, used for entry allocation. |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
64 |
static size_t size() { return sizeof(SparsePRTEntry) + sizeof(card_elem_t) * (cards_num() - card_array_alignment); } |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
65 |
// Returns the size of the card array. |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
66 |
static int cards_num() { |
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
67 |
return align_up((int)G1RSetSparseRegionEntries, (int)card_array_alignment); |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
68 |
} |
1374 | 69 |
|
70 |
// Set the region_ind to the given value, and delete all cards. |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
71 |
inline void init(RegionIdx_t region_ind); |
1374 | 72 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
73 |
RegionIdx_t r_ind() const { return _region_ind; } |
1374 | 74 |
bool valid_entry() const { return r_ind() >= 0; } |
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
75 |
void set_r_ind(RegionIdx_t rind) { _region_ind = rind; } |
1374 | 76 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
77 |
int next_index() const { return _next_index; } |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
78 |
int* next_index_addr() { return &_next_index; } |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
79 |
void set_next_index(int ni) { _next_index = ni; } |
1374 | 80 |
|
81 |
// Returns "true" iff the entry contains the given card index. |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
82 |
inline bool contains_card(CardIdx_t card_index) const; |
1374 | 83 |
|
84 |
// Returns the number of non-NULL card entries. |
|
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
85 |
inline int num_valid_cards() const { return _next_null; } |
1374 | 86 |
|
87 |
// Requires that the entry not contain the given card index. If there is |
|
88 |
// space available, add the given card index to the entry and return |
|
89 |
// "true"; otherwise, return "false" to indicate that the entry is full. |
|
90 |
enum AddCardResult { |
|
91 |
overflow, |
|
92 |
found, |
|
93 |
added |
|
94 |
}; |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
95 |
inline AddCardResult add_card(CardIdx_t card_index); |
1374 | 96 |
|
97 |
// Copy the current entry's cards into the "_card" array of "e." |
|
98 |
inline void copy_cards(SparsePRTEntry* e) const; |
|
99 |
||
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
100 |
card_elem_t* cards() { return _cards; } |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
101 |
|
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
102 |
inline CardIdx_t card(int i) const { |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
103 |
assert(i >= 0, "must be nonnegative"); |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
104 |
assert(i < cards_num(), "range checking"); |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
105 |
return (CardIdx_t)_cards[i]; |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
106 |
} |
1374 | 107 |
}; |
108 |
||
13195 | 109 |
class RSHashTable : public CHeapObj<mtGC> { |
1374 | 110 |
|
111 |
friend class RSHashTableIter; |
|
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
112 |
friend class RSHashTableBucketIter; |
1374 | 113 |
|
38269
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
114 |
// Inverse maximum hash table occupancy used. |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
115 |
static float TableOccupancyFactor; |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
116 |
|
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
117 |
size_t _num_entries; |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
118 |
|
1374 | 119 |
size_t _capacity; |
120 |
size_t _capacity_mask; |
|
121 |
size_t _occupied_entries; |
|
122 |
size_t _occupied_cards; |
|
123 |
||
124 |
SparsePRTEntry* _entries; |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
125 |
int* _buckets; |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
126 |
int _free_region; |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
127 |
int _free_list; |
1374 | 128 |
|
129 |
// Requires that the caller hold a lock preventing parallel modifying |
|
130 |
// operations, and that the the table be less than completely full. If |
|
131 |
// an entry for "region_ind" is already in the table, finds it and |
|
132 |
// returns its address; otherwise allocates, initializes, inserts and |
|
133 |
// returns a new entry for "region_ind". |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
134 |
SparsePRTEntry* entry_for_region_ind_create(RegionIdx_t region_ind); |
1374 | 135 |
|
136 |
// Returns the index of the next free entry in "_entries". |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
137 |
int alloc_entry(); |
1374 | 138 |
// Declares the entry "fi" to be free. (It must have already been |
139 |
// deleted from any bucket lists. |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
140 |
void free_entry(int fi); |
1374 | 141 |
|
142 |
public: |
|
143 |
RSHashTable(size_t capacity); |
|
144 |
~RSHashTable(); |
|
145 |
||
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
146 |
static const int NullEntry = -1; |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
147 |
|
38269
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
148 |
bool should_expand() const { return _occupied_entries == _num_entries; } |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
149 |
|
1374 | 150 |
// Attempts to ensure that the given card_index in the given region is in |
151 |
// the sparse table. If successful (because the card was already |
|
22551 | 152 |
// present, or because it was successfully added) returns "true". |
1374 | 153 |
// Otherwise, returns "false" to indicate that the addition would |
154 |
// overflow the entry for the region. The caller must transfer these |
|
155 |
// entries to a larger-capacity representation. |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
156 |
bool add_card(RegionIdx_t region_id, CardIdx_t card_index); |
1374 | 157 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
158 |
bool delete_entry(RegionIdx_t region_id); |
1374 | 159 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
160 |
bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const; |
1374 | 161 |
|
162 |
void add_entry(SparsePRTEntry* e); |
|
163 |
||
24464
901aa0dcba08
8042474: Clean up duplicated code in RSHashTable
brutisso
parents:
23543
diff
changeset
|
164 |
SparsePRTEntry* get_entry(RegionIdx_t region_id) const; |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
165 |
|
1374 | 166 |
void clear(); |
167 |
||
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
168 |
size_t capacity() const { return _capacity; } |
1374 | 169 |
size_t capacity_mask() const { return _capacity_mask; } |
170 |
size_t occupied_entries() const { return _occupied_entries; } |
|
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
171 |
size_t occupied_cards() const { return _occupied_cards; } |
1374 | 172 |
size_t mem_size() const; |
38269
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
173 |
// The number of SparsePRTEntry instances available. |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
174 |
size_t num_entries() const { return _num_entries; } |
1374 | 175 |
|
38269
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
176 |
SparsePRTEntry* entry(int i) const { |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
177 |
assert(i >= 0 && (size_t)i < _num_entries, "precondition"); |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
178 |
return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i); |
d18cab031e64
8155721: Sparse remset wastes half of entry memory
tschatzl
parents:
30764
diff
changeset
|
179 |
} |
1374 | 180 |
|
181 |
void print(); |
|
182 |
}; |
|
183 |
||
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
184 |
// This is embedded in HRRS iterator. |
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
185 |
class RSHashTableIter { |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
186 |
// Return value indicating "invalid/no card". |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
187 |
static const int NoCardFound = -1; |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
188 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
189 |
int _tbl_ind; // [-1, 0.._rsht->_capacity) |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
190 |
int _bl_ind; // [-1, 0.._rsht->_capacity) |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
191 |
short _card_ind; // [0..SparsePRTEntry::cards_num()) |
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
192 |
RSHashTable* _rsht; |
1374 | 193 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
194 |
// If the bucket list pointed to by _bl_ind contains a card, sets |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
195 |
// _bl_ind to the index of that entry, |
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38269
diff
changeset
|
196 |
// Returns the card found if there is, otherwise returns InvalidCard. |
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
197 |
CardIdx_t find_first_card_in_list(); |
1374 | 198 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
199 |
// Computes the proper card index for the card whose offset in the |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
200 |
// current region (as indicated by _bl_ind) is "ci". |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
201 |
// This is subject to errors when there is iteration concurrent with |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
202 |
// modification, but these errors should be benign. |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
203 |
size_t compute_card_ind(CardIdx_t ci); |
1374 | 204 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
205 |
public: |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13963
diff
changeset
|
206 |
RSHashTableIter(RSHashTable* rsht) : |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13963
diff
changeset
|
207 |
_tbl_ind(RSHashTable::NullEntry), // So that first increment gets to 0. |
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
208 |
_bl_ind(RSHashTable::NullEntry), |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
209 |
_card_ind((SparsePRTEntry::cards_num() - 1)), |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13963
diff
changeset
|
210 |
_rsht(rsht) {} |
1374 | 211 |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
212 |
bool has_next(size_t& card_index); |
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
213 |
}; |
1374 | 214 |
|
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
215 |
// This is embedded in HRRS iterator. |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
216 |
class RSHashTableBucketIter { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
217 |
int _tbl_ind; // [-1, 0.._rsht->_capacity) |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
218 |
int _bl_ind; // [-1, 0.._rsht->_capacity) |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
219 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
220 |
RSHashTable* _rsht; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
221 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
222 |
public: |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
223 |
RSHashTableBucketIter(RSHashTable* rsht) : |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
224 |
_tbl_ind(0), |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
225 |
_bl_ind(rsht->_buckets[_tbl_ind]), |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
226 |
_rsht(rsht) { } |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
227 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
228 |
bool has_next(SparsePRTEntry*& entry); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
229 |
}; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
230 |
|
22551 | 231 |
// Concurrent access to a SparsePRT must be serialized by some external mutex. |
1374 | 232 |
|
233 |
class SparsePRTIter; |
|
234 |
||
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
235 |
class SparsePRT { |
52716
877dd2b0f36c
8213996: Remove one of the SparsePRT entry tables
tschatzl
parents:
52347
diff
changeset
|
236 |
friend class SparsePRTIter; |
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
237 |
friend class SparsePRTBucketIter; |
8072 | 238 |
|
52716
877dd2b0f36c
8213996: Remove one of the SparsePRT entry tables
tschatzl
parents:
52347
diff
changeset
|
239 |
RSHashTable* _table; |
1374 | 240 |
|
55148
0dab93cb3b0c
8223162: Improve ergonomics for Sparse PRT entry sizing
tschatzl
parents:
53244
diff
changeset
|
241 |
static const size_t InitialCapacity = 8; |
1374 | 242 |
|
243 |
void expand(); |
|
244 |
||
245 |
public: |
|
52347
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
49455
diff
changeset
|
246 |
SparsePRT(); |
1374 | 247 |
~SparsePRT(); |
248 |
||
52716
877dd2b0f36c
8213996: Remove one of the SparsePRT entry tables
tschatzl
parents:
52347
diff
changeset
|
249 |
size_t occupied() const { return _table->occupied_cards(); } |
1374 | 250 |
size_t mem_size() const; |
251 |
||
252 |
// Attempts to ensure that the given card_index in the given region is in |
|
253 |
// the sparse table. If successful (because the card was already |
|
22551 | 254 |
// present, or because it was successfully added) returns "true". |
1374 | 255 |
// Otherwise, returns "false" to indicate that the addition would |
256 |
// overflow the entry for the region. The caller must transfer these |
|
257 |
// entries to a larger-capacity representation. |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
258 |
bool add_card(RegionIdx_t region_id, CardIdx_t card_index); |
1374 | 259 |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
260 |
// Return the pointer to the entry associated with the given region. |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
261 |
SparsePRTEntry* get_entry(RegionIdx_t region_ind); |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4100
diff
changeset
|
262 |
|
1374 | 263 |
// If there is an entry for "region_ind", removes it and return "true"; |
264 |
// otherwise returns "false." |
|
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
265 |
bool delete_entry(RegionIdx_t region_ind); |
1374 | 266 |
|
267 |
// Clear the table, and reinitialize to initial capacity. |
|
268 |
void clear(); |
|
269 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2154
diff
changeset
|
270 |
bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const { |
52716
877dd2b0f36c
8213996: Remove one of the SparsePRT entry tables
tschatzl
parents:
52347
diff
changeset
|
271 |
return _table->contains_card(region_id, card_index); |
1374 | 272 |
} |
273 |
}; |
|
274 |
||
6981
ecfe524b1fa7
6992189: G1: inconsistent base used in sparse rem set iterator
tonyp
parents:
5547
diff
changeset
|
275 |
class SparsePRTIter: public RSHashTableIter { |
1374 | 276 |
public: |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13963
diff
changeset
|
277 |
SparsePRTIter(const SparsePRT* sprt) : |
52716
877dd2b0f36c
8213996: Remove one of the SparsePRT entry tables
tschatzl
parents:
52347
diff
changeset
|
278 |
RSHashTableIter(sprt->_table) { } |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13963
diff
changeset
|
279 |
|
1374 | 280 |
bool has_next(size_t& card_index) { |
281 |
return RSHashTableIter::has_next(card_index); |
|
282 |
} |
|
283 |
}; |
|
7397 | 284 |
|
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
285 |
class SparsePRTBucketIter: public RSHashTableBucketIter { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
286 |
public: |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
287 |
SparsePRTBucketIter(const SparsePRT* sprt) : |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
288 |
RSHashTableBucketIter(sprt->_table) {} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
289 |
|
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
290 |
bool has_next(SparsePRTEntry*& entry) { |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
291 |
return RSHashTableBucketIter::has_next(entry); |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
292 |
} |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
293 |
}; |
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
55148
diff
changeset
|
294 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52716
diff
changeset
|
295 |
#endif // SHARE_GC_G1_SPARSEPRT_HPP |