annotate src/share/vm/gc_implementation/g1/sparsePRT.hpp @ 2173:97ba643ea3ed

7014261: G1: RSet-related failures Summary: A race between the concurrent cleanup thread and the VM thread while it is processing the "expanded sparse table list" causes both threads to try to free the same sparse table entry and either causes one of the threads to fail or leaves the entry in an inconsistent state. The solution is purge all entries on the expanded list that correspond go regions that are being cleaned up. Reviewed-by: brutisso, johnc
author tonyp
date Tue, 25 Jan 2011 17:58:19 -0500
parents f95d63e2154a
children d2a62e0f25eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1261
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1261
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1261
diff changeset
21 * questions.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_SPARSEPRT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_SPARSEPRT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
28 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
29 #include "gc_implementation/g1/heapRegion.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
30 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
31 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
32 #include "runtime/mutex.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
33 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
34
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35 // Sparse remembered set for a heap region (the "owning" region). Maps
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36 // indices of other regions to short sequences of cards in the other region
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 // that might contain pointers into the owner region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
38
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
39 // These tables only expand while they are accessed in parallel --
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 // deletions may be done in single-threaded code. This allows us to allow
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
41 // unsynchronized reads/iterations, as long as expansions caused by
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 // insertions only enqueue old versions for deletions, but do not delete
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43 // old versions synchronously.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44
549
fe3d7c11b4b7 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 342
diff changeset
45 class SparsePRTEntry: public CHeapObj {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
46 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
47 enum SomePublicConstants {
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
48 NullEntry = -1,
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
49 UnrollFactor = 4
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51 private:
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
52 RegionIdx_t _region_ind;
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
53 int _next_index;
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
54 CardIdx_t _cards[1];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
55 // WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length.
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
56 // It should always be the last data member.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
57 public:
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
58 // Returns the size of the entry, used for entry allocation.
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
59 static size_t size() { return sizeof(SparsePRTEntry) + sizeof(CardIdx_t) * (cards_num() - 1); }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
60 // Returns the size of the card array.
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
61 static int cards_num() {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
62 // The number of cards should be a multiple of 4, because that's our current
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
63 // unrolling factor.
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
64 static const int s = MAX2<int>(G1RSetSparseRegionEntries & ~(UnrollFactor - 1), UnrollFactor);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
65 return s;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
66 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
67
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
68 // Set the region_ind to the given value, and delete all cards.
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
69 inline void init(RegionIdx_t region_ind);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
70
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
71 RegionIdx_t r_ind() const { return _region_ind; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
72 bool valid_entry() const { return r_ind() >= 0; }
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
73 void set_r_ind(RegionIdx_t rind) { _region_ind = rind; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
75 int next_index() const { return _next_index; }
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
76 int* next_index_addr() { return &_next_index; }
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
77 void set_next_index(int ni) { _next_index = ni; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79 // Returns "true" iff the entry contains the given card index.
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
80 inline bool contains_card(CardIdx_t card_index) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
81
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
82 // Returns the number of non-NULL card entries.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 inline int num_valid_cards() const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
85 // Requires that the entry not contain the given card index. If there is
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
86 // space available, add the given card index to the entry and return
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
87 // "true"; otherwise, return "false" to indicate that the entry is full.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
88 enum AddCardResult {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
89 overflow,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
90 found,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91 added
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
92 };
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
93 inline AddCardResult add_card(CardIdx_t card_index);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
95 // Copy the current entry's cards into "cards".
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
96 inline void copy_cards(CardIdx_t* cards) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
97 // Copy the current entry's cards into the "_card" array of "e."
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
98 inline void copy_cards(SparsePRTEntry* e) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
99
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
100 inline CardIdx_t card(int i) const { return _cards[i]; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
101 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
103
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
104 class RSHashTable : public CHeapObj {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
105
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
106 friend class RSHashTableIter;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
107
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
108 enum SomePrivateConstants {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
109 NullEntry = -1
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
110 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
111
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
112 size_t _capacity;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
113 size_t _capacity_mask;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
114 size_t _occupied_entries;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
115 size_t _occupied_cards;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
116
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
117 SparsePRTEntry* _entries;
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
118 int* _buckets;
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
119 int _free_region;
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
120 int _free_list;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
122 // Requires that the caller hold a lock preventing parallel modifying
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123 // operations, and that the the table be less than completely full. If
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
124 // an entry for "region_ind" is already in the table, finds it and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
125 // returns its address; otherwise returns "NULL."
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
126 SparsePRTEntry* entry_for_region_ind(RegionIdx_t region_ind) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
127
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
128 // Requires that the caller hold a lock preventing parallel modifying
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
129 // operations, and that the the table be less than completely full. If
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
130 // an entry for "region_ind" is already in the table, finds it and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 // returns its address; otherwise allocates, initializes, inserts and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
132 // returns a new entry for "region_ind".
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
133 SparsePRTEntry* entry_for_region_ind_create(RegionIdx_t region_ind);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
134
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 // Returns the index of the next free entry in "_entries".
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
136 int alloc_entry();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137 // Declares the entry "fi" to be free. (It must have already been
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 // deleted from any bucket lists.
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
139 void free_entry(int fi);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 RSHashTable(size_t capacity);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143 ~RSHashTable();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145 // Attempts to ensure that the given card_index in the given region is in
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146 // the sparse table. If successful (because the card was already
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
147 // present, or because it was successfullly added) returns "true".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
148 // Otherwise, returns "false" to indicate that the addition would
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
149 // overflow the entry for the region. The caller must transfer these
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150 // entries to a larger-capacity representation.
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
151 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
153 bool get_cards(RegionIdx_t region_id, CardIdx_t* cards);
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
154
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
155 bool delete_entry(RegionIdx_t region_id);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
156
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
157 bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
158
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
159 void add_entry(SparsePRTEntry* e);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
161 SparsePRTEntry* get_entry(RegionIdx_t region_id);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
162
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163 void clear();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
164
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165 size_t capacity() const { return _capacity; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
166 size_t capacity_mask() const { return _capacity_mask; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167 size_t occupied_entries() const { return _occupied_entries; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
168 size_t occupied_cards() const { return _occupied_cards; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 size_t mem_size() const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
171 SparsePRTEntry* entry(int i) const { return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i); }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
173 void print();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
176 // ValueObj because will be embedded in HRRS iterator.
549
fe3d7c11b4b7 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 342
diff changeset
177 class RSHashTableIter VALUE_OBJ_CLASS_SPEC {
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
178 int _tbl_ind; // [-1, 0.._rsht->_capacity)
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
179 int _bl_ind; // [-1, 0.._rsht->_capacity)
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
180 short _card_ind; // [0..SparsePRTEntry::cards_num())
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
181 RSHashTable* _rsht;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
183 // If the bucket list pointed to by _bl_ind contains a card, sets
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
184 // _bl_ind to the index of that entry, and returns the card.
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
185 // Otherwise, returns SparseEntry::NullEntry.
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
186 CardIdx_t find_first_card_in_list();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
188 // Computes the proper card index for the card whose offset in the
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
189 // current region (as indicated by _bl_ind) is "ci".
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
190 // This is subject to errors when there is iteration concurrent with
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
191 // modification, but these errors should be benign.
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
192 size_t compute_card_ind(CardIdx_t ci);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
194 public:
1884
9f4848ebbabd 6992189: G1: inconsistent base used in sparse rem set iterator
tonyp
parents: 1552
diff changeset
195 RSHashTableIter() :
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
196 _tbl_ind(RSHashTable::NullEntry),
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
197 _bl_ind(RSHashTable::NullEntry),
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
198 _card_ind((SparsePRTEntry::cards_num() - 1)),
1884
9f4848ebbabd 6992189: G1: inconsistent base used in sparse rem set iterator
tonyp
parents: 1552
diff changeset
199 _rsht(NULL) {}
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
201 void init(RSHashTable* rsht) {
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
202 _rsht = rsht;
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
203 _tbl_ind = -1; // So that first increment gets to 0.
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
204 _bl_ind = RSHashTable::NullEntry;
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
205 _card_ind = (SparsePRTEntry::cards_num() - 1);
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
206 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
207
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
208 bool has_next(size_t& card_index);
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
209 };
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
210
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
211 // Concurrent accesss to a SparsePRT must be serialized by some external
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
212 // mutex.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
213
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
214 class SparsePRTIter;
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
215 class SparsePRTCleanupTask;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
216
549
fe3d7c11b4b7 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 342
diff changeset
217 class SparsePRT VALUE_OBJ_CLASS_SPEC {
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
218 friend class SparsePRTCleanupTask;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
219
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
220 // Iterations are done on the _cur hash table, since they only need to
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
221 // see entries visible at the start of a collection pause.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
222 // All other operations are done using the _next hash table.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
223 RSHashTable* _cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 RSHashTable* _next;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
225
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
226 HeapRegion* _hr;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
227
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
228 enum SomeAdditionalPrivateConstants {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
229 InitialCapacity = 16
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
230 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
231
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
232 void expand();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234 bool _expanded;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
236 bool expanded() { return _expanded; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237 void set_expanded(bool b) { _expanded = b; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
238
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
239 SparsePRT* _next_expanded;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241 SparsePRT* next_expanded() { return _next_expanded; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 void set_next_expanded(SparsePRT* nxt) { _next_expanded = nxt; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
243
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
244 bool should_be_on_expanded_list();
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
245
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
246 static SparsePRT* _head_expanded_list;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
247
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
248 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
249 SparsePRT(HeapRegion* hr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
250
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
251 ~SparsePRT();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
252
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
253 size_t occupied() const { return _next->occupied_cards(); }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
254 size_t mem_size() const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
255
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
256 // Attempts to ensure that the given card_index in the given region is in
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
257 // the sparse table. If successful (because the card was already
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
258 // present, or because it was successfullly added) returns "true".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
259 // Otherwise, returns "false" to indicate that the addition would
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
260 // overflow the entry for the region. The caller must transfer these
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
261 // entries to a larger-capacity representation.
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
262 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
263
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
264 // If the table hold an entry for "region_ind", Copies its
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
265 // cards into "cards", which must be an array of length at least
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
266 // "SparePRTEntry::cards_num()", and returns "true"; otherwise,
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
267 // returns "false".
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
268 bool get_cards(RegionIdx_t region_ind, CardIdx_t* cards);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
269
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
270 // Return the pointer to the entry associated with the given region.
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
271 SparsePRTEntry* get_entry(RegionIdx_t region_ind);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
272
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
273 // If there is an entry for "region_ind", removes it and return "true";
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
274 // otherwise returns "false."
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
275 bool delete_entry(RegionIdx_t region_ind);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
276
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
277 // Clear the table, and reinitialize to initial capacity.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
278 void clear();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
279
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
280 // Ensure that "_cur" and "_next" point to the same table.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
281 void cleanup();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
282
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
283 // Clean up all tables on the expanded list. Called single threaded.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
284 static void cleanup_all();
617
0db4adb6e914 6810698: G1: two small bugs in the sparse remembered sets
tonyp
parents: 549
diff changeset
285 RSHashTable* cur() const { return _cur; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
286
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
287 void init_iterator(SparsePRTIter* sprt_iter);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
288
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
289 static void add_to_expanded_list(SparsePRT* sprt);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
290 static SparsePRT* get_from_expanded_list();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
291
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
292 // The purpose of these three methods is to help the GC workers
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
293 // during the cleanup pause to recreate the expanded list, purging
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
294 // any tables from it that belong to regions that are freed during
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
295 // cleanup (if we don't purge those tables, there is a race that
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
296 // causes various crashes; see CR 7014261).
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
297 //
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
298 // We chose to recreate the expanded list, instead of purging
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
299 // entries from it by iterating over it, to avoid this serial phase
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
300 // at the end of the cleanup pause.
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
301 //
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
302 // The three methods below work as follows:
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
303 // * reset_for_cleanup_tasks() : Nulls the expanded list head at the
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
304 // start of the cleanup pause.
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
305 // * do_cleanup_work() : Called by the cleanup workers for every
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
306 // region that is not free / is being freed by the cleanup
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
307 // pause. It creates a list of expanded tables whose head / tail
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
308 // are on the thread-local SparsePRTCleanupTask object.
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
309 // * finish_cleanup_task() : Called by the cleanup workers after
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
310 // they complete their cleanup task. It adds the local list into
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
311 // the global expanded list. It assumes that the
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
312 // ParGCRareEvent_lock is being held to ensure MT-safety.
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
313 static void reset_for_cleanup_tasks();
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
314 void do_cleanup_work(SparsePRTCleanupTask* sprt_cleanup_task);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
315 static void finish_cleanup_task(SparsePRTCleanupTask* sprt_cleanup_task);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
316
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 628
diff changeset
317 bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
318 return _next->contains_card(region_id, card_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
319 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
320 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
321
1884
9f4848ebbabd 6992189: G1: inconsistent base used in sparse rem set iterator
tonyp
parents: 1552
diff changeset
322 class SparsePRTIter: public RSHashTableIter {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
323 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
324 void init(const SparsePRT* sprt) {
617
0db4adb6e914 6810698: G1: two small bugs in the sparse remembered sets
tonyp
parents: 549
diff changeset
325 RSHashTableIter::init(sprt->cur());
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
326 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
327 bool has_next(size_t& card_index) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
328 return RSHashTableIter::has_next(card_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
329 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
330 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
331
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
332 // This allows each worker during a cleanup pause to create a
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
333 // thread-local list of sparse tables that have been expanded and need
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
334 // to be processed at the beginning of the next GC pause. This lists
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
335 // are concatenated into the single expanded list at the end of the
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
336 // cleanup pause.
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
337 class SparsePRTCleanupTask VALUE_OBJ_CLASS_SPEC {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
338 private:
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
339 SparsePRT* _head;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
340 SparsePRT* _tail;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
341
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
342 public:
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
343 SparsePRTCleanupTask() : _head(NULL), _tail(NULL) { }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
344
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
345 void add(SparsePRT* sprt);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
346 SparsePRT* head() { return _head; }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
347 SparsePRT* tail() { return _tail; }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
348 };
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
349
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
350 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SPARSEPRT_HPP