author | tschatzl |
Wed, 08 Aug 2018 15:31:06 +0200 | |
changeset 51332 | c25572739e7c |
parent 49194 | ece10494786c |
child 54110 | f4f0dce5d0bb |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48961
120b61d50f85
8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47998
diff
changeset
|
2 |
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4461
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4461
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4461
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
26 |
#include "gc/shared/cardTable.hpp" |
30764 | 27 |
#include "gc/shared/collectedHeap.hpp" |
28 |
#include "gc/shared/space.inline.hpp" |
|
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
29 |
#include "logging/log.hpp" |
30291
54cdc5c1a9cb
8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents:
30154
diff
changeset
|
30 |
#include "memory/virtualspace.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
31 |
#include "runtime/java.hpp" |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
32 |
#include "runtime/os.hpp" |
13195 | 33 |
#include "services/memTracker.hpp" |
46625 | 34 |
#include "utilities/align.hpp" |
7397 | 35 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
36 |
size_t CardTable::compute_byte_map_size() { |
1 | 37 |
assert(_guard_index == cards_required(_whole_heap.word_size()) - 1, |
22775 | 38 |
"uninitialized, check declaration order"); |
39 |
assert(_page_size != 0, "uninitialized, check declaration order"); |
|
1 | 40 |
const size_t granularity = os::vm_allocation_granularity(); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
41 |
return align_up(_guard_index + 1, MAX2(_page_size, granularity)); |
1 | 42 |
} |
43 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
44 |
CardTable::CardTable(MemRegion whole_heap, bool conc_scan) : |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
45 |
_scanned_concurrently(conc_scan), |
1 | 46 |
_whole_heap(whole_heap), |
26160 | 47 |
_guard_index(0), |
48 |
_last_valid_index(0), |
|
194 | 49 |
_page_size(os::vm_page_size()), |
26160 | 50 |
_byte_map_size(0), |
51332 | 51 |
_byte_map(NULL), |
52 |
_byte_map_base(NULL), |
|
53 |
_cur_covered_regions(0), |
|
26160 | 54 |
_covered(NULL), |
55 |
_committed(NULL), |
|
51332 | 56 |
_guard_region() |
1 | 57 |
{ |
26160 | 58 |
assert((uintptr_t(_whole_heap.start()) & (card_size - 1)) == 0, "heap must start at card boundary"); |
59 |
assert((uintptr_t(_whole_heap.end()) & (card_size - 1)) == 0, "heap must end at card boundary"); |
|
60 |
||
61 |
assert(card_size <= 512, "card_size must be less than 512"); // why? |
|
62 |
||
63 |
_covered = new MemRegion[_max_covered_regions]; |
|
64 |
if (_covered == NULL) { |
|
65 |
vm_exit_during_initialization("Could not allocate card table covered region set."); |
|
66 |
} |
|
67 |
} |
|
68 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
69 |
CardTable::~CardTable() { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
70 |
if (_covered) { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
71 |
delete[] _covered; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
72 |
_covered = NULL; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
73 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
74 |
if (_committed) { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
75 |
delete[] _committed; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
76 |
_committed = NULL; |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
77 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
78 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
79 |
|
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
80 |
void CardTable::initialize() { |
26160 | 81 |
_guard_index = cards_required(_whole_heap.word_size()) - 1; |
82 |
_last_valid_index = _guard_index - 1; |
|
83 |
||
84 |
_byte_map_size = compute_byte_map_size(); |
|
85 |
||
1 | 86 |
HeapWord* low_bound = _whole_heap.start(); |
87 |
HeapWord* high_bound = _whole_heap.end(); |
|
88 |
||
26160 | 89 |
_cur_covered_regions = 0; |
90 |
_committed = new MemRegion[_max_covered_regions]; |
|
91 |
if (_committed == NULL) { |
|
92 |
vm_exit_during_initialization("Could not allocate card table committed region set."); |
|
1 | 93 |
} |
17376
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
17087
diff
changeset
|
94 |
|
1 | 95 |
const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 : |
96 |
MAX2(_page_size, (size_t) os::vm_allocation_granularity()); |
|
97 |
ReservedSpace heap_rs(_byte_map_size, rs_align, false); |
|
13195 | 98 |
|
99 |
MemTracker::record_virtual_memory_type((address)heap_rs.base(), mtGC); |
|
100 |
||
37462 | 101 |
os::trace_page_sizes("Card Table", _guard_index + 1, _guard_index + 1, |
1 | 102 |
_page_size, heap_rs.base(), heap_rs.size()); |
103 |
if (!heap_rs.is_reserved()) { |
|
104 |
vm_exit_during_initialization("Could not reserve enough space for the " |
|
105 |
"card marking array"); |
|
106 |
} |
|
107 |
||
22551 | 108 |
// The assembler store_check code will do an unsigned shift of the oop, |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
109 |
// then add it to _byte_map_base, i.e. |
1 | 110 |
// |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
111 |
// _byte_map = _byte_map_base + (uintptr_t(low_bound) >> card_shift) |
1 | 112 |
_byte_map = (jbyte*) heap_rs.base(); |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
113 |
_byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift); |
1 | 114 |
assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map"); |
115 |
assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map"); |
|
116 |
||
117 |
jbyte* guard_card = &_byte_map[_guard_index]; |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
118 |
HeapWord* guard_page = align_down((HeapWord*)guard_card, _page_size); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
119 |
_guard_region = MemRegion(guard_page, _page_size); |
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
17376
diff
changeset
|
120 |
os::commit_memory_or_exit((char*)guard_page, _page_size, _page_size, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
17376
diff
changeset
|
121 |
!ExecMem, "card table last card"); |
1 | 122 |
*guard_card = last_card; |
123 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
124 |
log_trace(gc, barrier)("CardTable::CardTable: "); |
35061 | 125 |
log_trace(gc, barrier)(" &_byte_map[0]: " INTPTR_FORMAT " &_byte_map[_last_valid_index]: " INTPTR_FORMAT, |
126 |
p2i(&_byte_map[0]), p2i(&_byte_map[_last_valid_index])); |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
127 |
log_trace(gc, barrier)(" _byte_map_base: " INTPTR_FORMAT, p2i(_byte_map_base)); |
1 | 128 |
} |
129 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
130 |
int CardTable::find_covering_region_by_base(HeapWord* base) { |
1 | 131 |
int i; |
132 |
for (i = 0; i < _cur_covered_regions; i++) { |
|
133 |
if (_covered[i].start() == base) return i; |
|
134 |
if (_covered[i].start() > base) break; |
|
135 |
} |
|
136 |
// If we didn't find it, create a new one. |
|
137 |
assert(_cur_covered_regions < _max_covered_regions, |
|
138 |
"too many covered regions"); |
|
139 |
// Move the ones above up, to maintain sorted order. |
|
140 |
for (int j = _cur_covered_regions; j > i; j--) { |
|
141 |
_covered[j] = _covered[j-1]; |
|
142 |
_committed[j] = _committed[j-1]; |
|
143 |
} |
|
144 |
int res = i; |
|
145 |
_cur_covered_regions++; |
|
146 |
_covered[res].set_start(base); |
|
147 |
_covered[res].set_word_size(0); |
|
148 |
jbyte* ct_start = byte_for(base); |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
149 |
HeapWord* ct_start_aligned = align_down((HeapWord*)ct_start, _page_size); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
150 |
_committed[res].set_start(ct_start_aligned); |
1 | 151 |
_committed[res].set_word_size(0); |
152 |
return res; |
|
153 |
} |
|
154 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
155 |
int CardTable::find_covering_region_containing(HeapWord* addr) { |
1 | 156 |
for (int i = 0; i < _cur_covered_regions; i++) { |
157 |
if (_covered[i].contains(addr)) { |
|
158 |
return i; |
|
159 |
} |
|
160 |
} |
|
161 |
assert(0, "address outside of heap?"); |
|
162 |
return -1; |
|
163 |
} |
|
164 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
165 |
HeapWord* CardTable::largest_prev_committed_end(int ind) const { |
1 | 166 |
HeapWord* max_end = NULL; |
167 |
for (int j = 0; j < ind; j++) { |
|
168 |
HeapWord* this_end = _committed[j].end(); |
|
169 |
if (this_end > max_end) max_end = this_end; |
|
170 |
} |
|
171 |
return max_end; |
|
172 |
} |
|
173 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
174 |
MemRegion CardTable::committed_unique_to_self(int self, MemRegion mr) const { |
1 | 175 |
MemRegion result = mr; |
176 |
for (int r = 0; r < _cur_covered_regions; r += 1) { |
|
177 |
if (r != self) { |
|
178 |
result = result.minus(_committed[r]); |
|
179 |
} |
|
180 |
} |
|
181 |
// Never include the guard page. |
|
182 |
result = result.minus(_guard_region); |
|
183 |
return result; |
|
184 |
} |
|
185 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
186 |
void CardTable::resize_covered_region(MemRegion new_region) { |
1 | 187 |
// We don't change the start of a region, only the end. |
188 |
assert(_whole_heap.contains(new_region), |
|
189 |
"attempt to cover area not in reserved area"); |
|
190 |
debug_only(verify_guard();) |
|
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
191 |
// collided is true if the expansion would push into another committed region |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
192 |
debug_only(bool collided = false;) |
179
59e3abf83f72
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
1
diff
changeset
|
193 |
int const ind = find_covering_region_by_base(new_region.start()); |
59e3abf83f72
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
1
diff
changeset
|
194 |
MemRegion const old_region = _covered[ind]; |
1 | 195 |
assert(old_region.start() == new_region.start(), "just checking"); |
196 |
if (new_region.word_size() != old_region.word_size()) { |
|
197 |
// Commit new or uncommit old pages, if necessary. |
|
198 |
MemRegion cur_committed = _committed[ind]; |
|
22551 | 199 |
// Extend the end of this _committed region |
1 | 200 |
// to cover the end of any lower _committed regions. |
201 |
// This forms overlapping regions, but never interior regions. |
|
179
59e3abf83f72
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
1
diff
changeset
|
202 |
HeapWord* const max_prev_end = largest_prev_committed_end(ind); |
1 | 203 |
if (max_prev_end > cur_committed.end()) { |
204 |
cur_committed.set_end(max_prev_end); |
|
205 |
} |
|
206 |
// Align the end up to a page size (starts are already aligned). |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
207 |
HeapWord* new_end = (HeapWord*) byte_after(new_region.last()); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
208 |
HeapWord* new_end_aligned = align_up(new_end, _page_size); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
209 |
assert(new_end_aligned >= new_end, "align up, but less"); |
2107
338528868274
6786346: intermittent Internal Error (src/share/vm/memory/cardTableModRefBS.cpp:226)
jmasa
parents:
1676
diff
changeset
|
210 |
// Check the other regions (excludes "ind") to ensure that |
338528868274
6786346: intermittent Internal Error (src/share/vm/memory/cardTableModRefBS.cpp:226)
jmasa
parents:
1676
diff
changeset
|
211 |
// the new_end_aligned does not intrude onto the committed |
338528868274
6786346: intermittent Internal Error (src/share/vm/memory/cardTableModRefBS.cpp:226)
jmasa
parents:
1676
diff
changeset
|
212 |
// space of another region. |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
213 |
int ri = 0; |
28026
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
214 |
for (ri = ind + 1; ri < _cur_covered_regions; ri++) { |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
215 |
if (new_end_aligned > _committed[ri].start()) { |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
216 |
assert(new_end_aligned <= _committed[ri].end(), |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
217 |
"An earlier committed region can't cover a later committed region"); |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
218 |
// Any region containing the new end |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
219 |
// should start at or beyond the region found (ind) |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
220 |
// for the new end (committed regions are not expected to |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
221 |
// be proper subsets of other committed regions). |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
222 |
assert(_committed[ri].start() >= _committed[ind].start(), |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
223 |
"New end of committed region is inconsistent"); |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
224 |
new_end_aligned = _committed[ri].start(); |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
225 |
// new_end_aligned can be equal to the start of its |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
226 |
// committed region (i.e., of "ind") if a second |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
227 |
// region following "ind" also start at the same location |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
228 |
// as "ind". |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
229 |
assert(new_end_aligned >= _committed[ind].start(), |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
230 |
"New end of committed region is before start"); |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
231 |
debug_only(collided = true;) |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
232 |
// Should only collide with 1 region |
3694b71eef6c
8059066: CardTableModRefBS might commit the same page twice
ehelin
parents:
27904
diff
changeset
|
233 |
break; |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
234 |
} |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
235 |
} |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
236 |
#ifdef ASSERT |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
237 |
for (++ri; ri < _cur_covered_regions; ri++) { |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
238 |
assert(!_committed[ri].contains(new_end_aligned), |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
239 |
"New end of committed region is in a second committed region"); |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
240 |
} |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
241 |
#endif |
1 | 242 |
// The guard page is always committed and should not be committed over. |
3587
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
243 |
// "guarded" is used for assertion checking below and recalls the fact |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
244 |
// that the would-be end of the new committed region would have |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
245 |
// penetrated the guard page. |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
246 |
HeapWord* new_end_for_commit = new_end_aligned; |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
247 |
|
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
248 |
DEBUG_ONLY(bool guarded = false;) |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
249 |
if (new_end_for_commit > _guard_region.start()) { |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
250 |
new_end_for_commit = _guard_region.start(); |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
251 |
DEBUG_ONLY(guarded = true;) |
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
252 |
} |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
253 |
|
1 | 254 |
if (new_end_for_commit > cur_committed.end()) { |
255 |
// Must commit new pages. |
|
179
59e3abf83f72
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
1
diff
changeset
|
256 |
MemRegion const new_committed = |
1 | 257 |
MemRegion(cur_committed.end(), new_end_for_commit); |
258 |
||
259 |
assert(!new_committed.is_empty(), "Region should not be empty here"); |
|
18069
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
17376
diff
changeset
|
260 |
os::commit_memory_or_exit((char*)new_committed.start(), |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
17376
diff
changeset
|
261 |
new_committed.byte_size(), _page_size, |
e6d4971c8650
8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents:
17376
diff
changeset
|
262 |
!ExecMem, "card table expansion"); |
1 | 263 |
// Use new_end_aligned (as opposed to new_end_for_commit) because |
264 |
// the cur_committed region may include the guard region. |
|
265 |
} else if (new_end_aligned < cur_committed.end()) { |
|
266 |
// Must uncommit pages. |
|
179
59e3abf83f72
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
1
diff
changeset
|
267 |
MemRegion const uncommit_region = |
1 | 268 |
committed_unique_to_self(ind, MemRegion(new_end_aligned, |
269 |
cur_committed.end())); |
|
270 |
if (!uncommit_region.is_empty()) { |
|
5892
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
271 |
// It is not safe to uncommit cards if the boundary between |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
272 |
// the generations is moving. A shrink can uncommit cards |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
273 |
// owned by generation A but being used by generation B. |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
274 |
if (!UseAdaptiveGCBoundary) { |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
275 |
if (!os::uncommit_memory((char*)uncommit_region.start(), |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
276 |
uncommit_region.byte_size())) { |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
277 |
assert(false, "Card table contraction failed"); |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
278 |
// The call failed so don't change the end of the |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
279 |
// committed region. This is better than taking the |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
280 |
// VM down. |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
281 |
new_end_aligned = _committed[ind].end(); |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
282 |
} |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
283 |
} else { |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
284 |
new_end_aligned = _committed[ind].end(); |
1 | 285 |
} |
286 |
} |
|
287 |
} |
|
288 |
// In any case, we can reset the end of the current committed entry. |
|
289 |
_committed[ind].set_end(new_end_aligned); |
|
290 |
||
5892
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
291 |
#ifdef ASSERT |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
292 |
// Check that the last card in the new region is committed according |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
293 |
// to the tables. |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
294 |
bool covered = false; |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
295 |
for (int cr = 0; cr < _cur_covered_regions; cr++) { |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
296 |
if (_committed[cr].contains(new_end - 1)) { |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
297 |
covered = true; |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
298 |
break; |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
299 |
} |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
300 |
} |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
301 |
assert(covered, "Card for end of new region not committed"); |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
302 |
#endif |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
303 |
|
1 | 304 |
// The default of 0 is not necessarily clean cards. |
305 |
jbyte* entry; |
|
306 |
if (old_region.last() < _whole_heap.start()) { |
|
307 |
entry = byte_for(_whole_heap.start()); |
|
308 |
} else { |
|
309 |
entry = byte_after(old_region.last()); |
|
310 |
} |
|
1676
d80e69372634
6653214: MemoryPoolMXBean.setUsageThreshold() does not support large heap sizes.
swamyv
parents:
1388
diff
changeset
|
311 |
assert(index_for(new_region.last()) < _guard_index, |
1 | 312 |
"The guard card will be overwritten"); |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
313 |
// This line commented out cleans the newly expanded region and |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
314 |
// not the aligned up expanded region. |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
315 |
// jbyte* const end = byte_after(new_region.last()); |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
316 |
jbyte* const end = (jbyte*) new_end_for_commit; |
3587
0140e816d000
6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents:
2154
diff
changeset
|
317 |
assert((end >= byte_after(new_region.last())) || collided || guarded, |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
318 |
"Expect to be beyond new region unless impacting another region"); |
1 | 319 |
// do nothing if we resized downward. |
754
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
320 |
#ifdef ASSERT |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
321 |
for (int ri = 0; ri < _cur_covered_regions; ri++) { |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
322 |
if (ri != ind) { |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
323 |
// The end of the new committed region should not |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
324 |
// be in any existing region unless it matches |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
325 |
// the start of the next region. |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
326 |
assert(!_committed[ri].contains(end) || |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
327 |
(_committed[ri].start() == (HeapWord*) end), |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
328 |
"Overlapping committed regions"); |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
329 |
} |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
330 |
} |
fb9904179b42
6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents:
360
diff
changeset
|
331 |
#endif |
1 | 332 |
if (entry < end) { |
333 |
memset(entry, clean_card, pointer_delta(end, entry, sizeof(jbyte))); |
|
334 |
} |
|
335 |
} |
|
336 |
// In any case, the covered size changes. |
|
337 |
_covered[ind].set_word_size(new_region.word_size()); |
|
35061 | 338 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
339 |
log_trace(gc, barrier)("CardTable::resize_covered_region: "); |
35061 | 340 |
log_trace(gc, barrier)(" _covered[%d].start(): " INTPTR_FORMAT " _covered[%d].last(): " INTPTR_FORMAT, |
341 |
ind, p2i(_covered[ind].start()), ind, p2i(_covered[ind].last())); |
|
342 |
log_trace(gc, barrier)(" _committed[%d].start(): " INTPTR_FORMAT " _committed[%d].last(): " INTPTR_FORMAT, |
|
343 |
ind, p2i(_committed[ind].start()), ind, p2i(_committed[ind].last())); |
|
344 |
log_trace(gc, barrier)(" byte_for(start): " INTPTR_FORMAT " byte_for(last): " INTPTR_FORMAT, |
|
345 |
p2i(byte_for(_covered[ind].start())), p2i(byte_for(_covered[ind].last()))); |
|
346 |
log_trace(gc, barrier)(" addr_for(start): " INTPTR_FORMAT " addr_for(last): " INTPTR_FORMAT, |
|
347 |
p2i(addr_for((jbyte*) _committed[ind].start())), p2i(addr_for((jbyte*) _committed[ind].last()))); |
|
348 |
||
5892
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
349 |
// Touch the last card of the covered region to show that it |
477b32b9d021
6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents:
5547
diff
changeset
|
350 |
// is committed (or SEGV). |
18073
f02460441ddc
8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents:
18069
diff
changeset
|
351 |
debug_only((void) (*byte_for(_covered[ind].last()));) |
1 | 352 |
debug_only(verify_guard();) |
353 |
} |
|
354 |
||
355 |
// Note that these versions are precise! The scanning code has to handle the |
|
356 |
// fact that the write barrier may be either precise or imprecise. |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
357 |
void CardTable::dirty_MemRegion(MemRegion mr) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
358 |
assert(align_down(mr.start(), HeapWordSize) == mr.start(), "Unaligned start"); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
359 |
assert(align_up (mr.end(), HeapWordSize) == mr.end(), "Unaligned end" ); |
1 | 360 |
jbyte* cur = byte_for(mr.start()); |
361 |
jbyte* last = byte_after(mr.last()); |
|
362 |
while (cur < last) { |
|
363 |
*cur = dirty_card; |
|
364 |
cur++; |
|
365 |
} |
|
366 |
} |
|
367 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
368 |
void CardTable::clear_MemRegion(MemRegion mr) { |
1 | 369 |
// Be conservative: only clean cards entirely contained within the |
370 |
// region. |
|
371 |
jbyte* cur; |
|
372 |
if (mr.start() == _whole_heap.start()) { |
|
373 |
cur = byte_for(mr.start()); |
|
374 |
} else { |
|
375 |
assert(mr.start() > _whole_heap.start(), "mr is not covered."); |
|
376 |
cur = byte_after(mr.start() - 1); |
|
377 |
} |
|
378 |
jbyte* last = byte_after(mr.last()); |
|
379 |
memset(cur, clean_card, pointer_delta(last, cur, sizeof(jbyte))); |
|
380 |
} |
|
381 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
382 |
void CardTable::clear(MemRegion mr) { |
1 | 383 |
for (int i = 0; i < _cur_covered_regions; i++) { |
384 |
MemRegion mri = mr.intersection(_covered[i]); |
|
385 |
if (!mri.is_empty()) clear_MemRegion(mri); |
|
386 |
} |
|
387 |
} |
|
388 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
389 |
void CardTable::dirty(MemRegion mr) { |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
390 |
jbyte* first = byte_for(mr.start()); |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
391 |
jbyte* last = byte_after(mr.last()); |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
392 |
memset(first, dirty_card, last-first); |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
393 |
} |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
394 |
|
9183
3d0e0687fe28
7036482: clear argument is redundant and unused in cardtable methods
ysr
parents:
7397
diff
changeset
|
395 |
// Unlike several other card table methods, dirty_card_iterate() |
3d0e0687fe28
7036482: clear argument is redundant and unused in cardtable methods
ysr
parents:
7397
diff
changeset
|
396 |
// iterates over dirty cards ranges in increasing address order. |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
397 |
void CardTable::dirty_card_iterate(MemRegion mr, MemRegionClosure* cl) { |
1 | 398 |
for (int i = 0; i < _cur_covered_regions; i++) { |
399 |
MemRegion mri = mr.intersection(_covered[i]); |
|
400 |
if (!mri.is_empty()) { |
|
401 |
jbyte *cur_entry, *next_entry, *limit; |
|
402 |
for (cur_entry = byte_for(mri.start()), limit = byte_for(mri.last()); |
|
403 |
cur_entry <= limit; |
|
404 |
cur_entry = next_entry) { |
|
405 |
next_entry = cur_entry + 1; |
|
406 |
if (*cur_entry == dirty_card) { |
|
407 |
size_t dirty_cards; |
|
408 |
// Accumulate maximal dirty card range, starting at cur_entry |
|
409 |
for (dirty_cards = 1; |
|
410 |
next_entry <= limit && *next_entry == dirty_card; |
|
411 |
dirty_cards++, next_entry++); |
|
412 |
MemRegion cur_cards(addr_for(cur_entry), |
|
413 |
dirty_cards*card_size_in_words); |
|
414 |
cl->do_MemRegion(cur_cards); |
|
415 |
} |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
} |
|
420 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
421 |
MemRegion CardTable::dirty_card_range_after_reset(MemRegion mr, |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
422 |
bool reset, |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
423 |
int reset_val) { |
1 | 424 |
for (int i = 0; i < _cur_covered_regions; i++) { |
425 |
MemRegion mri = mr.intersection(_covered[i]); |
|
426 |
if (!mri.is_empty()) { |
|
427 |
jbyte* cur_entry, *next_entry, *limit; |
|
428 |
for (cur_entry = byte_for(mri.start()), limit = byte_for(mri.last()); |
|
429 |
cur_entry <= limit; |
|
430 |
cur_entry = next_entry) { |
|
431 |
next_entry = cur_entry + 1; |
|
432 |
if (*cur_entry == dirty_card) { |
|
433 |
size_t dirty_cards; |
|
434 |
// Accumulate maximal dirty card range, starting at cur_entry |
|
435 |
for (dirty_cards = 1; |
|
436 |
next_entry <= limit && *next_entry == dirty_card; |
|
437 |
dirty_cards++, next_entry++); |
|
438 |
MemRegion cur_cards(addr_for(cur_entry), |
|
439 |
dirty_cards*card_size_in_words); |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
440 |
if (reset) { |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
441 |
for (size_t i = 0; i < dirty_cards; i++) { |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
442 |
cur_entry[i] = reset_val; |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
443 |
} |
1 | 444 |
} |
445 |
return cur_cards; |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
} |
|
450 |
return MemRegion(mr.end(), mr.end()); |
|
451 |
} |
|
452 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
453 |
uintx CardTable::ct_max_alignment_constraint() { |
1 | 454 |
return card_size * os::vm_page_size(); |
455 |
} |
|
456 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
457 |
void CardTable::verify_guard() { |
1 | 458 |
// For product build verification |
459 |
guarantee(_byte_map[_guard_index] == last_card, |
|
460 |
"card table guard has been modified"); |
|
461 |
} |
|
462 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
463 |
void CardTable::invalidate(MemRegion mr) { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
464 |
assert(align_down(mr.start(), HeapWordSize) == mr.start(), "Unaligned start"); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
465 |
assert(align_up (mr.end(), HeapWordSize) == mr.end(), "Unaligned end" ); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
466 |
for (int i = 0; i < _cur_covered_regions; i++) { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
467 |
MemRegion mri = mr.intersection(_covered[i]); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
468 |
if (!mri.is_empty()) dirty_MemRegion(mri); |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
469 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
470 |
} |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
471 |
|
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
472 |
void CardTable::verify() { |
1 | 473 |
verify_guard(); |
474 |
} |
|
475 |
||
476 |
#ifndef PRODUCT |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
477 |
void CardTable::verify_region(MemRegion mr, |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
478 |
jbyte val, bool val_equals) { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
479 |
jbyte* start = byte_for(mr.start()); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
480 |
jbyte* end = byte_for(mr.last()); |
26160 | 481 |
bool failures = false; |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
482 |
for (jbyte* curr = start; curr <= end; ++curr) { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
483 |
jbyte curr_val = *curr; |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
484 |
bool failed = (val_equals) ? (curr_val != val) : (curr_val == val); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
485 |
if (failed) { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
486 |
if (!failures) { |
37226
9b0d4b523ce4
8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents:
35061
diff
changeset
|
487 |
log_error(gc, verify)("== CT verification failed: [" INTPTR_FORMAT "," INTPTR_FORMAT "]", p2i(start), p2i(end)); |
9b0d4b523ce4
8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents:
35061
diff
changeset
|
488 |
log_error(gc, verify)("== %sexpecting value: %d", (val_equals) ? "" : "not ", val); |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
489 |
failures = true; |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
490 |
} |
37226
9b0d4b523ce4
8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents:
35061
diff
changeset
|
491 |
log_error(gc, verify)("== card " PTR_FORMAT " [" PTR_FORMAT "," PTR_FORMAT "], val: %d", |
9b0d4b523ce4
8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents:
35061
diff
changeset
|
492 |
p2i(curr), p2i(addr_for(curr)), |
9b0d4b523ce4
8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents:
35061
diff
changeset
|
493 |
p2i((HeapWord*) (((size_t) addr_for(curr)) + card_size)), |
9b0d4b523ce4
8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents:
35061
diff
changeset
|
494 |
(int) curr_val); |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
495 |
} |
1 | 496 |
} |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
497 |
guarantee(!failures, "there should not have been any failures"); |
1 | 498 |
} |
3695
421cfcc8843c
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
3587
diff
changeset
|
499 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
500 |
void CardTable::verify_not_dirty_region(MemRegion mr) { |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
501 |
verify_region(mr, dirty_card, false /* val_equals */); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
502 |
} |
3695
421cfcc8843c
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
3587
diff
changeset
|
503 |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
504 |
void CardTable::verify_dirty_region(MemRegion mr) { |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
9336
diff
changeset
|
505 |
verify_region(mr, dirty_card, true /* val_equals */); |
3695
421cfcc8843c
6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents:
3587
diff
changeset
|
506 |
} |
1 | 507 |
#endif |
508 |
||
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
509 |
void CardTable::print_on(outputStream* st) const { |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
510 |
st->print_cr("Card table byte_map: [" INTPTR_FORMAT "," INTPTR_FORMAT "] _byte_map_base: " INTPTR_FORMAT, |
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49007
diff
changeset
|
511 |
p2i(_byte_map), p2i(_byte_map + _byte_map_size), p2i(_byte_map_base)); |
12268 | 512 |
} |