annotate src/share/vm/gc_implementation/g1/sparsePRT.cpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children 7848fc12602b
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 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 2001, 2013, 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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
26 #include "gc_implementation/g1/heapRegion.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
27 #include "gc_implementation/g1/heapRegionRemSet.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
28 #include "gc_implementation/g1/sparsePRT.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
29 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
30 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
31 #include "memory/space.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
32 #include "runtime/mutexLocker.hpp"
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34 #define SPARSE_PRT_VERBOSE 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
36 #define UNROLL_CARD_LOOPS 1
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
38 void SparsePRTEntry::init(RegionIdx_t region_ind) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
39 _region_ind = region_ind;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 _next_index = NullEntry;
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
41
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 #if UNROLL_CARD_LOOPS
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
43 assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
44 for (int i = 0; i < cards_num(); i += UnrollFactor) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
45 _cards[i] = NullEntry;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
46 _cards[i + 1] = NullEntry;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
47 _cards[i + 2] = NullEntry;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
48 _cards[i + 3] = NullEntry;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
49 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50 #else
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
51 for (int i = 0; i < cards_num(); i++)
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
52 _cards[i] = NullEntry;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
54 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
55
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
56 bool SparsePRTEntry::contains_card(CardIdx_t card_index) const {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
57 #if UNROLL_CARD_LOOPS
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
58 assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
59 for (int i = 0; i < cards_num(); i += UnrollFactor) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
60 if (_cards[i] == card_index ||
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
61 _cards[i + 1] == card_index ||
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
62 _cards[i + 2] == card_index ||
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
63 _cards[i + 3] == card_index) return true;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
64 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
65 #else
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
66 for (int i = 0; i < cards_num(); i++) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
67 if (_cards[i] == card_index) return true;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
68 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
69 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
70 // Otherwise, we're full.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
71 return false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
72 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
73
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 int SparsePRTEntry::num_valid_cards() const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 int sum = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
76 #if UNROLL_CARD_LOOPS
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
77 assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
78 for (int i = 0; i < cards_num(); i += UnrollFactor) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
79 sum += (_cards[i] != NullEntry);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
80 sum += (_cards[i + 1] != NullEntry);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
81 sum += (_cards[i + 2] != NullEntry);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
82 sum += (_cards[i + 3] != NullEntry);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
83 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84 #else
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
85 for (int i = 0; i < cards_num(); i++) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
86 sum += (_cards[i] != NullEntry);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
87 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
88 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
89 // Otherwise, we're full.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
90 return sum;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91 }
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: 617
diff changeset
93 SparsePRTEntry::AddCardResult SparsePRTEntry::add_card(CardIdx_t card_index) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94 #if UNROLL_CARD_LOOPS
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
95 assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
96 CardIdx_t c;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
97 for (int i = 0; i < cards_num(); i += UnrollFactor) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
98 c = _cards[i];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
99 if (c == card_index) return found;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
100 if (c == NullEntry) { _cards[i] = card_index; return added; }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
101 c = _cards[i + 1];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
102 if (c == card_index) return found;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
103 if (c == NullEntry) { _cards[i + 1] = card_index; return added; }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
104 c = _cards[i + 2];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
105 if (c == card_index) return found;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
106 if (c == NullEntry) { _cards[i + 2] = card_index; return added; }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
107 c = _cards[i + 3];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
108 if (c == card_index) return found;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
109 if (c == NullEntry) { _cards[i + 3] = card_index; return added; }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
110 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
111 #else
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
112 for (int i = 0; i < cards_num(); i++) {
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
113 CardIdx_t c = _cards[i];
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
114 if (c == card_index) return found;
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
115 if (c == NullEntry) { _cards[i] = card_index; return added; }
342
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 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
118 // Otherwise, we're full.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
119 return overflow;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
120 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
122 void SparsePRTEntry::copy_cards(CardIdx_t* cards) const {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123 #if UNROLL_CARD_LOOPS
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
124 assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
125 for (int i = 0; i < cards_num(); i += UnrollFactor) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
126 cards[i] = _cards[i];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
127 cards[i + 1] = _cards[i + 1];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
128 cards[i + 2] = _cards[i + 2];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
129 cards[i + 3] = _cards[i + 3];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
130 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 #else
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
132 for (int i = 0; i < cards_num(); i++) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
133 cards[i] = _cards[i];
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 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 void SparsePRTEntry::copy_cards(SparsePRTEntry* e) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
139 copy_cards(&e->_cards[0]);
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
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 // ----------------------------------------------------------------------
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144 RSHashTable::RSHashTable(size_t capacity) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145 _capacity(capacity), _capacity_mask(capacity-1),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146 _occupied_entries(0), _occupied_cards(0),
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6010
diff changeset
147 _entries((SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, SparsePRTEntry::size() * capacity, mtGC)),
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6010
diff changeset
148 _buckets(NEW_C_HEAP_ARRAY(int, capacity, mtGC)),
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
149 _free_list(NullEntry), _free_region(0)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
151 clear();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
153
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
154 RSHashTable::~RSHashTable() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
155 if (_entries != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6010
diff changeset
156 FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries, mtGC);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
157 _entries = NULL;
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 if (_buckets != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 6010
diff changeset
160 FREE_C_HEAP_ARRAY(int, _buckets, mtGC);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161 _buckets = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
162 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163 }
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 void RSHashTable::clear() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
166 _occupied_entries = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167 _occupied_cards = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
168 guarantee(_entries != NULL, "INV");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 guarantee(_buckets != NULL, "INV");
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
170
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
171 guarantee(_capacity <= ((size_t)1 << (sizeof(int)*BitsPerByte-1)) - 1,
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
172 "_capacity too large");
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
173
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174 // This will put -1 == NullEntry in the key field of all entries.
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
175 memset(_entries, NullEntry, _capacity * SparsePRTEntry::size());
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
176 memset(_buckets, NullEntry, _capacity * sizeof(int));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
177 _free_list = NullEntry;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
178 _free_region = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
181 bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 SparsePRTEntry* e = entry_for_region_ind_create(region_ind);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183 assert(e != NULL && e->r_ind() == region_ind,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 "Postcondition of call above.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 SparsePRTEntry::AddCardResult res = e->add_card(card_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186 if (res == SparsePRTEntry::added) _occupied_cards++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187 #if SPARSE_PRT_VERBOSE
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
188 gclog_or_tty->print_cr(" after add_card[%d]: valid-cards = %d.",
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
189 pointer_delta(e, _entries, SparsePRTEntry::size()),
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
190 e->num_valid_cards());
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
191 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
192 assert(e->num_valid_cards() > 0, "Postcondition");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193 return res != SparsePRTEntry::overflow;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
194 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
195
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
196 bool RSHashTable::get_cards(RegionIdx_t region_ind, CardIdx_t* cards) {
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
197 int ind = (int) (region_ind & capacity_mask());
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
198 int cur_ind = _buckets[ind];
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199 SparsePRTEntry* cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200 while (cur_ind != NullEntry &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
201 (cur = entry(cur_ind))->r_ind() != region_ind) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
202 cur_ind = cur->next_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205 if (cur_ind == NullEntry) return false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 // Otherwise...
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
207 assert(cur->r_ind() == region_ind, "Postcondition of loop + test above.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
208 assert(cur->num_valid_cards() > 0, "Inv");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
209 cur->copy_cards(cards);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
210 return true;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
211 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
212
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
213 SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
214 int ind = (int) (region_ind & capacity_mask());
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
215 int cur_ind = _buckets[ind];
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
216 SparsePRTEntry* cur;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
217 while (cur_ind != NullEntry &&
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
218 (cur = entry(cur_ind))->r_ind() != region_ind) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
219 cur_ind = cur->next_index();
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
220 }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
221
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
222 if (cur_ind == NullEntry) return NULL;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
223 // Otherwise...
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
224 assert(cur->r_ind() == region_ind, "Postcondition of loop + test above.");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
225 assert(cur->num_valid_cards() > 0, "Inv");
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
226 return cur;
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
227 }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
228
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
229 bool RSHashTable::delete_entry(RegionIdx_t region_ind) {
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
230 int ind = (int) (region_ind & capacity_mask());
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
231 int* prev_loc = &_buckets[ind];
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
232 int cur_ind = *prev_loc;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233 SparsePRTEntry* cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234 while (cur_ind != NullEntry &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235 (cur = entry(cur_ind))->r_ind() != region_ind) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
236 prev_loc = cur->next_index_addr();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237 cur_ind = *prev_loc;
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
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240 if (cur_ind == NullEntry) return false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241 // Otherwise, splice out "cur".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 *prev_loc = cur->next_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
243 _occupied_cards -= cur->num_valid_cards();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
244 free_entry(cur_ind);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
245 _occupied_entries--;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
246 return true;
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
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
249 SparsePRTEntry*
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
250 RSHashTable::entry_for_region_ind(RegionIdx_t region_ind) const {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
251 assert(occupied_entries() < capacity(), "Precondition");
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
252 int ind = (int) (region_ind & capacity_mask());
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
253 int cur_ind = _buckets[ind];
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
254 SparsePRTEntry* cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
255 while (cur_ind != NullEntry &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
256 (cur = entry(cur_ind))->r_ind() != region_ind) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
257 cur_ind = cur->next_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
258 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
259
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
260 if (cur_ind != NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
261 assert(cur->r_ind() == region_ind, "Loop postcondition + test");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
262 return cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
263 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
264 return NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
265 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
266 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
267
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
268 SparsePRTEntry*
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
269 RSHashTable::entry_for_region_ind_create(RegionIdx_t region_ind) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
270 SparsePRTEntry* res = entry_for_region_ind(region_ind);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
271 if (res == NULL) {
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
272 int new_ind = alloc_entry();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
273 assert(0 <= new_ind && (size_t)new_ind < capacity(), "There should be room.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
274 res = entry(new_ind);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
275 res->init(region_ind);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
276 // Insert at front.
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
277 int ind = (int) (region_ind & capacity_mask());
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
278 res->set_next_index(_buckets[ind]);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
279 _buckets[ind] = new_ind;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
280 _occupied_entries++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
281 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
282 return res;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
283 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
284
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
285 int RSHashTable::alloc_entry() {
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
286 int res;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
287 if (_free_list != NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
288 res = _free_list;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
289 _free_list = entry(res)->next_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
290 return res;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
291 } else if ((size_t) _free_region+1 < capacity()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
292 res = _free_region;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
293 _free_region++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
294 return res;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
295 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
296 return NullEntry;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
297 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
298 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
299
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
300 void RSHashTable::free_entry(int fi) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
301 entry(fi)->set_next_index(_free_list);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
302 _free_list = fi;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
303 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
304
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
305 void RSHashTable::add_entry(SparsePRTEntry* e) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
306 assert(e->num_valid_cards() > 0, "Precondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
307 SparsePRTEntry* e2 = entry_for_region_ind_create(e->r_ind());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
308 e->copy_cards(e2);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
309 _occupied_cards += e2->num_valid_cards();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
310 assert(e2->num_valid_cards() > 0, "Postcondition.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
311 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
312
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1884
diff changeset
313 CardIdx_t RSHashTableIter::find_first_card_in_list() {
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
314 CardIdx_t res;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
315 while (_bl_ind != RSHashTable::NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
316 res = _rsht->entry(_bl_ind)->card(0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
317 if (res != SparsePRTEntry::NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
318 return res;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
319 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
320 _bl_ind = _rsht->entry(_bl_ind)->next_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
321 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
322 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
323 // Otherwise, none found:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
324 return SparsePRTEntry::NullEntry;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
325 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
326
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1884
diff changeset
327 size_t RSHashTableIter::compute_card_ind(CardIdx_t ci) {
1884
9f4848ebbabd 6992189: G1: inconsistent base used in sparse rem set iterator
tonyp
parents: 1708
diff changeset
328 return (_rsht->entry(_bl_ind)->r_ind() * HeapRegion::CardsPerRegion) + ci;
342
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
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1884
diff changeset
331 bool RSHashTableIter::has_next(size_t& card_index) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
332 _card_ind++;
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
333 CardIdx_t ci;
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
334 if (_card_ind < SparsePRTEntry::cards_num() &&
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
335 ((ci = _rsht->entry(_bl_ind)->card(_card_ind)) !=
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
336 SparsePRTEntry::NullEntry)) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
337 card_index = compute_card_ind(ci);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
338 return true;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
339 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
340 // Otherwise, must find the next valid entry.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
341 _card_ind = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
343 if (_bl_ind != RSHashTable::NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
344 _bl_ind = _rsht->entry(_bl_ind)->next_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
345 ci = find_first_card_in_list();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
346 if (ci != SparsePRTEntry::NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
347 card_index = compute_card_ind(ci);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
348 return true;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
349 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
350 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
351 // If we didn't return above, must go to the next non-null table index.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
352 _tbl_ind++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
353 while ((size_t)_tbl_ind < _rsht->capacity()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
354 _bl_ind = _rsht->_buckets[_tbl_ind];
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
355 ci = find_first_card_in_list();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
356 if (ci != SparsePRTEntry::NullEntry) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
357 card_index = compute_card_ind(ci);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
358 return true;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
359 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
360 // Otherwise, try next entry.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
361 _tbl_ind++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
362 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
363 // Otherwise, there were no entry.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
364 return false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
365 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
366
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
367 bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index) const {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
368 SparsePRTEntry* e = entry_for_region_ind(region_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
369 return (e != NULL && e->contains_card(card_index));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
370 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
371
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
372 size_t RSHashTable::mem_size() const {
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
373 return sizeof(this) +
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
374 capacity() * (SparsePRTEntry::size() + sizeof(int));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
375 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
376
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
377 // ----------------------------------------------------------------------
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
378
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
379 SparsePRT* SparsePRT::_head_expanded_list = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
380
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
381 void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
382 // We could expand multiple times in a pause -- only put on list once.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
383 if (sprt->expanded()) return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
384 sprt->set_expanded(true);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
385 SparsePRT* hd = _head_expanded_list;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
386 while (true) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
387 sprt->_next_expanded = hd;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
388 SparsePRT* res =
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
389 (SparsePRT*)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
390 Atomic::cmpxchg_ptr(sprt, &_head_expanded_list, hd);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
391 if (res == hd) return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
392 else hd = res;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
393 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
394 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
395
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
396
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
397 SparsePRT* SparsePRT::get_from_expanded_list() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
398 SparsePRT* hd = _head_expanded_list;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
399 while (hd != NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
400 SparsePRT* next = hd->next_expanded();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
401 SparsePRT* res =
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
402 (SparsePRT*)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
403 Atomic::cmpxchg_ptr(next, &_head_expanded_list, hd);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
404 if (res == hd) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
405 hd->set_next_expanded(NULL);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
406 return hd;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
407 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
408 hd = res;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
409 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
410 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
411 return NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
412 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
413
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
414 void SparsePRT::reset_for_cleanup_tasks() {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
415 _head_expanded_list = NULL;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
416 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
417
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
418 void SparsePRT::do_cleanup_work(SparsePRTCleanupTask* sprt_cleanup_task) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
419 if (should_be_on_expanded_list()) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
420 sprt_cleanup_task->add(this);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
421 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
422 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
423
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
424 void SparsePRT::finish_cleanup_task(SparsePRTCleanupTask* sprt_cleanup_task) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
425 assert(ParGCRareEvent_lock->owned_by_self(), "pre-condition");
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
426 SparsePRT* head = sprt_cleanup_task->head();
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
427 SparsePRT* tail = sprt_cleanup_task->tail();
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
428 if (head != NULL) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
429 assert(tail != NULL, "if head is not NULL, so should tail");
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
430
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
431 tail->set_next_expanded(_head_expanded_list);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
432 _head_expanded_list = head;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
433 } else {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
434 assert(tail == NULL, "if head is NULL, so should tail");
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
435 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
436 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
437
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
438 bool SparsePRT::should_be_on_expanded_list() {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
439 if (_expanded) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
440 assert(_cur != _next, "if _expanded is true, cur should be != _next");
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
441 } else {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
442 assert(_cur == _next, "if _expanded is false, cur should be == _next");
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
443 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
444 return expanded();
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
445 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
446
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
447 void SparsePRT::cleanup_all() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
448 // First clean up all expanded tables so they agree on next and cur.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
449 SparsePRT* sprt = get_from_expanded_list();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
450 while (sprt != NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
451 sprt->cleanup();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
452 sprt = get_from_expanded_list();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
453 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
454 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
455
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
456
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
457 SparsePRT::SparsePRT(HeapRegion* hr) :
1708
a03ae377b2e8 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 1552
diff changeset
458 _hr(hr), _expanded(false), _next_expanded(NULL)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
459 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
460 _cur = new RSHashTable(InitialCapacity);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
461 _next = _cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
462 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
463
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
464
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
465 SparsePRT::~SparsePRT() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
466 assert(_next != NULL && _cur != NULL, "Inv");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
467 if (_cur != _next) { delete _cur; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
468 delete _next;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
469 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
470
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
471
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
472 size_t SparsePRT::mem_size() const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
473 // We ignore "_cur" here, because it either = _next, or else it is
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
474 // on the deleted list.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
475 return sizeof(this) + _next->mem_size();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
476 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
477
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
478 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
479 #if SPARSE_PRT_VERBOSE
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 3766
diff changeset
480 gclog_or_tty->print_cr(" Adding card %d from region %d to region %u sparse.",
3766
c3f1170908be 7045330: G1: Simplify/fix the HeapRegionSeq class
tonyp
parents: 2173
diff changeset
481 card_index, region_id, _hr->hrs_index());
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
482 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
483 if (_next->occupied_entries() * 2 > _next->capacity()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
484 expand();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
485 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
486 return _next->add_card(region_id, card_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
487 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
488
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
489 bool SparsePRT::get_cards(RegionIdx_t region_id, CardIdx_t* cards) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
490 return _next->get_cards(region_id, cards);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
491 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
492
1261
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
493 SparsePRTEntry* SparsePRT::get_entry(RegionIdx_t region_id) {
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
494 return _next->get_entry(region_id);
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
495 }
0414c1049f15 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 1045
diff changeset
496
807
d44bdab1c03d 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 617
diff changeset
497 bool SparsePRT::delete_entry(RegionIdx_t region_id) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
498 return _next->delete_entry(region_id);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
499 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
500
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
501 void SparsePRT::clear() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
502 // If they differ, _next is bigger then cur, so next has no chance of
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
503 // being the initial size.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
504 if (_next != _cur) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
505 delete _next;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
506 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
507
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
508 if (_cur->capacity() != InitialCapacity) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
509 delete _cur;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
510 _cur = new RSHashTable(InitialCapacity);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
511 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
512 _cur->clear();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
513 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
514 _next = _cur;
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
515 _expanded = false;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
516 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
517
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
518 void SparsePRT::cleanup() {
1045
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
519 // Make sure that the current and next tables agree.
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
520 if (_cur != _next) {
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
521 delete _cur;
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
522 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
523 _cur = _next;
617
0db4adb6e914 6810698: G1: two small bugs in the sparse remembered sets
tonyp
parents: 342
diff changeset
524 set_expanded(false);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
525 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
526
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
527 void SparsePRT::expand() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
528 RSHashTable* last = _next;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
529 _next = new RSHashTable(last->capacity() * 2);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
530
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
531 #if SPARSE_PRT_VERBOSE
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 3766
diff changeset
532 gclog_or_tty->print_cr(" Expanded sparse table for %u to %d.",
3766
c3f1170908be 7045330: G1: Simplify/fix the HeapRegionSeq class
tonyp
parents: 2173
diff changeset
533 _hr->hrs_index(), _next->capacity());
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
534 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
535 for (size_t i = 0; i < last->capacity(); i++) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
536 SparsePRTEntry* e = last->entry((int)i);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
537 if (e->valid_entry()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
538 #if SPARSE_PRT_VERBOSE
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
539 gclog_or_tty->print_cr(" During expansion, transferred entry for %d.",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
540 e->r_ind());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
541 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
542 _next->add_entry(e);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
543 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
544 }
1045
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
545 if (last != _cur) {
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
546 delete last;
fa2f65ebeb08 6870843: G1: G1 GC memory leak
apetrusenko
parents: 942
diff changeset
547 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
548 add_to_expanded_list(this);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
549 }
2173
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
550
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
551 void SparsePRTCleanupTask::add(SparsePRT* sprt) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
552 assert(sprt->should_be_on_expanded_list(), "pre-condition");
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
553
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
554 sprt->set_next_expanded(NULL);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
555 if (_tail != NULL) {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
556 _tail->set_next_expanded(sprt);
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
557 } else {
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
558 _head = sprt;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
559 }
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
560 _tail = sprt;
97ba643ea3ed 7014261: G1: RSet-related failures
tonyp
parents: 1972
diff changeset
561 }