author | sjohanss |
Tue, 09 Sep 2014 04:48:41 +0200 | |
changeset 26840 | f3c7613a7bbb |
parent 26839 | 021bfc544c6f |
child 26846 | 7d4376f8560e |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
23453
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
2 |
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5545
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5545
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:
5545
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
19339 | 26 |
#include "code/nmethod.hpp" |
7397 | 27 |
#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" |
28 |
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
|
29 |
#include "gc_implementation/g1/g1OopClosures.inline.hpp" |
|
30 |
#include "gc_implementation/g1/heapRegion.inline.hpp" |
|
26840 | 31 |
#include "gc_implementation/g1/heapRegionBounds.inline.hpp" |
7397 | 32 |
#include "gc_implementation/g1/heapRegionRemSet.hpp" |
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26157
diff
changeset
|
33 |
#include "gc_implementation/g1/heapRegionManager.inline.hpp" |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
34 |
#include "gc_implementation/shared/liveRange.hpp" |
7397 | 35 |
#include "memory/genOopClosures.inline.hpp" |
36 |
#include "memory/iterator.hpp" |
|
24487
71ff0bd674eb
8042737: Introduce umbrella header prefetch.inline.hpp
goetz
parents:
24424
diff
changeset
|
37 |
#include "memory/space.inline.hpp" |
7397 | 38 |
#include "oops/oop.inline.hpp" |
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24487
diff
changeset
|
39 |
#include "runtime/atomic.inline.hpp" |
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
23538
diff
changeset
|
40 |
#include "runtime/orderAccess.inline.hpp" |
1374 | 41 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
42 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
43 |
|
10677
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
44 |
int HeapRegion::LogOfHRGrainBytes = 0; |
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
45 |
int HeapRegion::LogOfHRGrainWords = 0; |
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
46 |
size_t HeapRegion::GrainBytes = 0; |
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
47 |
size_t HeapRegion::GrainWords = 0; |
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
48 |
size_t HeapRegion::CardsPerRegion = 0; |
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
49 |
|
1374 | 50 |
HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13482
diff
changeset
|
51 |
HeapRegion* hr, ExtendedOopClosure* cl, |
1374 | 52 |
CardTableModRefBS::PrecisionStyle precision, |
53 |
FilterKind fk) : |
|
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
54 |
DirtyCardToOopClosure(hr, cl, precision, NULL), |
13336
e582172ff6ff
7114678: G1: various small fixes, code cleanup, and refactoring
tonyp
parents:
12508
diff
changeset
|
55 |
_hr(hr), _fk(fk), _g1(g1) { } |
1374 | 56 |
|
57 |
FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, |
|
58 |
OopClosure* oc) : |
|
13336
e582172ff6ff
7114678: G1: various small fixes, code cleanup, and refactoring
tonyp
parents:
12508
diff
changeset
|
59 |
_r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { } |
1374 | 60 |
|
61 |
template<class ClosureType> |
|
62 |
HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h, |
|
63 |
HeapRegion* hr, |
|
64 |
HeapWord* cur, HeapWord* top) { |
|
65 |
oop cur_oop = oop(cur); |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
66 |
size_t oop_size = hr->block_size(cur); |
1374 | 67 |
HeapWord* next_obj = cur + oop_size; |
68 |
while (next_obj < top) { |
|
69 |
// Keep filtering the remembered set. |
|
70 |
if (!g1h->is_obj_dead(cur_oop, hr)) { |
|
71 |
// Bottom lies entirely below top, so we can call the |
|
72 |
// non-memRegion version of oop_iterate below. |
|
73 |
cur_oop->oop_iterate(cl); |
|
74 |
} |
|
75 |
cur = next_obj; |
|
76 |
cur_oop = oop(cur); |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
77 |
oop_size = hr->block_size(cur); |
1374 | 78 |
next_obj = cur + oop_size; |
79 |
} |
|
80 |
return cur; |
|
81 |
} |
|
82 |
||
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
83 |
void HeapRegionDCTOC::walk_mem_region(MemRegion mr, |
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
84 |
HeapWord* bottom, |
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
85 |
HeapWord* top) { |
1374 | 86 |
G1CollectedHeap* g1h = _g1; |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
87 |
size_t oop_size; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13482
diff
changeset
|
88 |
ExtendedOopClosure* cl2 = NULL; |
10670
4ea0e7d2ffbc
6484982: G1: process references during evacuation pauses
johnc
parents:
10669
diff
changeset
|
89 |
|
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
90 |
FilterIntoCSClosure intoCSFilt(this, g1h, _cl); |
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
91 |
FilterOutOfRegionClosure outOfRegionFilt(_hr, _cl); |
10670
4ea0e7d2ffbc
6484982: G1: process references during evacuation pauses
johnc
parents:
10669
diff
changeset
|
92 |
|
1374 | 93 |
switch (_fk) { |
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
94 |
case NoFilterKind: cl2 = _cl; break; |
1374 | 95 |
case IntoCSFilterKind: cl2 = &intoCSFilt; break; |
96 |
case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break; |
|
10674
09e6f8d20337
7097053: G1: assert(da ? referent->is_oop() : referent->is_oop_or_null()) failed: referenceProcessor.cpp:1054
johnc
parents:
10670
diff
changeset
|
97 |
default: ShouldNotReachHere(); |
1374 | 98 |
} |
99 |
||
100 |
// Start filtering what we add to the remembered set. If the object is |
|
101 |
// not considered dead, either because it is marked (in the mark bitmap) |
|
102 |
// or it was allocated after marking finished, then we add it. Otherwise |
|
103 |
// we can safely ignore the object. |
|
104 |
if (!g1h->is_obj_dead(oop(bottom), _hr)) { |
|
105 |
oop_size = oop(bottom)->oop_iterate(cl2, mr); |
|
106 |
} else { |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
107 |
oop_size = _hr->block_size(bottom); |
1374 | 108 |
} |
109 |
||
110 |
bottom += oop_size; |
|
111 |
||
112 |
if (bottom < top) { |
|
113 |
// We replicate the loop below for several kinds of possible filters. |
|
114 |
switch (_fk) { |
|
115 |
case NoFilterKind: |
|
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
116 |
bottom = walk_mem_region_loop(_cl, g1h, _hr, bottom, top); |
1374 | 117 |
break; |
10670
4ea0e7d2ffbc
6484982: G1: process references during evacuation pauses
johnc
parents:
10669
diff
changeset
|
118 |
|
1374 | 119 |
case IntoCSFilterKind: { |
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
120 |
FilterIntoCSClosure filt(this, g1h, _cl); |
1374 | 121 |
bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); |
122 |
break; |
|
123 |
} |
|
10670
4ea0e7d2ffbc
6484982: G1: process references during evacuation pauses
johnc
parents:
10669
diff
changeset
|
124 |
|
1374 | 125 |
case OutOfRegionFilterKind: { |
25360
5b6141bf7564
8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC
mgerdin
parents:
25351
diff
changeset
|
126 |
FilterOutOfRegionClosure filt(_hr, _cl); |
1374 | 127 |
bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); |
128 |
break; |
|
129 |
} |
|
10670
4ea0e7d2ffbc
6484982: G1: process references during evacuation pauses
johnc
parents:
10669
diff
changeset
|
130 |
|
1374 | 131 |
default: |
132 |
ShouldNotReachHere(); |
|
133 |
} |
|
134 |
||
135 |
// Last object. Need to do dead-obj filtering here too. |
|
136 |
if (!g1h->is_obj_dead(oop(bottom), _hr)) { |
|
137 |
oop(bottom)->oop_iterate(cl2, mr); |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
||
19986
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19728
diff
changeset
|
142 |
size_t HeapRegion::max_region_size() { |
26840 | 143 |
return HeapRegionBounds::max_size(); |
19986
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19728
diff
changeset
|
144 |
} |
33d188c66ed9
8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
19728
diff
changeset
|
145 |
|
19728
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19339
diff
changeset
|
146 |
void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) { |
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
147 |
uintx region_size = G1HeapRegionSize; |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
148 |
if (FLAG_IS_DEFAULT(G1HeapRegionSize)) { |
19728
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19339
diff
changeset
|
149 |
size_t average_heap_size = (initial_heap_size + max_heap_size) / 2; |
26840 | 150 |
region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(), |
151 |
(uintx) HeapRegionBounds::min_size()); |
|
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
152 |
} |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
153 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
154 |
int region_size_log = log2_long((jlong) region_size); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
155 |
// Recalculate the region size to make sure it's a power of |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
156 |
// 2. This means that region_size is the largest power of 2 that's |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
157 |
// <= what we've calculated so far. |
5377
bcf55c5acf4e
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
5350
diff
changeset
|
158 |
region_size = ((uintx)1 << region_size_log); |
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
159 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
160 |
// Now make sure that we don't go over or under our limits. |
26840 | 161 |
if (region_size < HeapRegionBounds::min_size()) { |
162 |
region_size = HeapRegionBounds::min_size(); |
|
163 |
} else if (region_size > HeapRegionBounds::max_size()) { |
|
164 |
region_size = HeapRegionBounds::max_size(); |
|
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
165 |
} |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
166 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
167 |
// And recalculate the log. |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
168 |
region_size_log = log2_long((jlong) region_size); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
169 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
170 |
// Now, set up the globals. |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
171 |
guarantee(LogOfHRGrainBytes == 0, "we should only set it once"); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
172 |
LogOfHRGrainBytes = region_size_log; |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
173 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
174 |
guarantee(LogOfHRGrainWords == 0, "we should only set it once"); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
175 |
LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize; |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
176 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
177 |
guarantee(GrainBytes == 0, "we should only set it once"); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
178 |
// The cast to int is safe, given that we've bounded region_size by |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
179 |
// MIN_REGION_SIZE and MAX_REGION_SIZE. |
10677
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
180 |
GrainBytes = (size_t)region_size; |
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
181 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
182 |
guarantee(GrainWords == 0, "we should only set it once"); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
183 |
GrainWords = GrainBytes >> LogHeapWordSize; |
12381
1438e0fbfa27
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
12379
diff
changeset
|
184 |
guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity"); |
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
185 |
|
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
186 |
guarantee(CardsPerRegion == 0, "we should only set it once"); |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
187 |
CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift; |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
188 |
} |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3283
diff
changeset
|
189 |
|
1374 | 190 |
void HeapRegion::reset_after_compaction() { |
191 |
G1OffsetTableContigSpace::reset_after_compaction(); |
|
192 |
// After a compaction the mark bitmap is invalid, so we must |
|
193 |
// treat all objects as being inside the unmarked area. |
|
194 |
zero_marked_bytes(); |
|
195 |
init_top_at_mark_start(); |
|
196 |
} |
|
197 |
||
23453
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
198 |
void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) { |
7923 | 199 |
assert(_humongous_start_region == NULL, |
200 |
"we should have already filtered out humongous regions"); |
|
26827 | 201 |
assert(_end == orig_end(), |
7923 | 202 |
"we should have already filtered out humongous regions"); |
203 |
||
1374 | 204 |
_in_collection_set = false; |
205 |
||
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
26827
diff
changeset
|
206 |
set_allocation_context(AllocationContext::system()); |
1374 | 207 |
set_young_index_in_cset(-1); |
208 |
uninstall_surv_rate_group(); |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
209 |
set_free(); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
7923
diff
changeset
|
210 |
reset_pre_dummy_top(); |
1374 | 211 |
|
212 |
if (!par) { |
|
213 |
// If this is parallel, this will be done later. |
|
214 |
HeapRegionRemSet* hrrs = rem_set(); |
|
23453
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
215 |
if (locked) { |
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
216 |
hrrs->clear_locked(); |
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
217 |
} else { |
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
218 |
hrrs->clear(); |
09cfb0164acf
8027295: Free CSet takes ~50% of young pause time
tschatzl
parents:
23451
diff
changeset
|
219 |
} |
1387 | 220 |
_claimed = InitialClaimValue; |
1374 | 221 |
} |
222 |
zero_marked_bytes(); |
|
223 |
||
224 |
_offsets.resize(HeapRegion::GrainWords); |
|
225 |
init_top_at_mark_start(); |
|
1388 | 226 |
if (clear_space) clear(SpaceDecorator::Mangle); |
1374 | 227 |
} |
228 |
||
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
229 |
void HeapRegion::par_clear() { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
230 |
assert(used() == 0, "the region should have been already cleared"); |
10677
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
231 |
assert(capacity() == HeapRegion::GrainBytes, "should be back to normal"); |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
232 |
HeapRegionRemSet* hrrs = rem_set(); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
233 |
hrrs->clear(); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
234 |
CardTableModRefBS* ct_bs = |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
235 |
(CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set(); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
236 |
ct_bs->clear(MemRegion(bottom(), end())); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
237 |
} |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
238 |
|
1374 | 239 |
void HeapRegion::calc_gc_efficiency() { |
13482 | 240 |
// GC efficiency is the ratio of how much space would be |
241 |
// reclaimed over how long we predict it would take to reclaim it. |
|
1374 | 242 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
11756
28b6fe22e43d
7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents:
11586
diff
changeset
|
243 |
G1CollectorPolicy* g1p = g1h->g1_policy(); |
13482 | 244 |
|
245 |
// Retrieve a prediction of the elapsed time for this region for |
|
246 |
// a mixed gc because the region will only be evacuated during a |
|
247 |
// mixed gc. |
|
248 |
double region_elapsed_time_ms = |
|
249 |
g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */); |
|
250 |
_gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; |
|
1374 | 251 |
} |
252 |
||
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
253 |
void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) { |
7923 | 254 |
assert(!isHumongous(), "sanity / pre-condition"); |
26827 | 255 |
assert(end() == orig_end(), |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
256 |
"Should be normal before the humongous object allocation"); |
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
257 |
assert(top() == bottom(), "should be empty"); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
258 |
assert(bottom() <= new_top && new_top <= new_end, "pre-condition"); |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
259 |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
260 |
_type.set_starts_humongous(); |
1374 | 261 |
_humongous_start_region = this; |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
262 |
|
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
263 |
set_end(new_end); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
264 |
_offsets.set_for_starts_humongous(new_top); |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
265 |
} |
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
266 |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
267 |
void HeapRegion::set_continuesHumongous(HeapRegion* first_hr) { |
7923 | 268 |
assert(!isHumongous(), "sanity / pre-condition"); |
26827 | 269 |
assert(end() == orig_end(), |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
270 |
"Should be normal before the humongous object allocation"); |
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
271 |
assert(top() == bottom(), "should be empty"); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
272 |
assert(first_hr->startsHumongous(), "pre-condition"); |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
6260
diff
changeset
|
273 |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
274 |
_type.set_continues_humongous(); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
275 |
_humongous_start_region = first_hr; |
1374 | 276 |
} |
277 |
||
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
278 |
void HeapRegion::clear_humongous() { |
7923 | 279 |
assert(isHumongous(), "pre-condition"); |
280 |
||
281 |
if (startsHumongous()) { |
|
282 |
assert(top() <= end(), "pre-condition"); |
|
26827 | 283 |
set_end(orig_end()); |
7923 | 284 |
if (top() > end()) { |
285 |
// at least one "continues humongous" region after it |
|
286 |
set_top(end()); |
|
287 |
} |
|
288 |
} else { |
|
289 |
// continues humongous |
|
26827 | 290 |
assert(end() == orig_end(), "sanity"); |
7923 | 291 |
} |
292 |
||
10677
370a8da2d63f
7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents:
10674
diff
changeset
|
293 |
assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); |
7923 | 294 |
_humongous_start_region = NULL; |
295 |
} |
|
296 |
||
1374 | 297 |
bool HeapRegion::claimHeapRegion(jint claimValue) { |
298 |
jint current = _claimed; |
|
299 |
if (current != claimValue) { |
|
300 |
jint res = Atomic::cmpxchg(claimValue, &_claimed, current); |
|
301 |
if (res == current) { |
|
302 |
return true; |
|
303 |
} |
|
304 |
} |
|
305 |
return false; |
|
306 |
} |
|
307 |
||
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26157
diff
changeset
|
308 |
HeapRegion::HeapRegion(uint hrm_index, |
12381
1438e0fbfa27
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
12379
diff
changeset
|
309 |
G1BlockOffsetSharedArray* sharedOffsetArray, |
26839 | 310 |
MemRegion mr) : |
13756
3b72f3da8cd4
7016955: G1: remove the is_zeroed parameter from the HeapRegion constructor
johnc
parents:
13728
diff
changeset
|
311 |
G1OffsetTableContigSpace(sharedOffsetArray, mr), |
26839 | 312 |
_hrm_index(hrm_index), |
313 |
_allocation_context(AllocationContext::system()), |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
314 |
_humongous_start_region(NULL), |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
9995
diff
changeset
|
315 |
_in_collection_set(false), |
26827 | 316 |
_next_in_special_set(NULL), |
1387 | 317 |
_claimed(InitialClaimValue), _evacuation_failed(false), |
12382
6aaecb1cbfe1
7145441: G1: collection set chooser-related cleanup
tonyp
parents:
12381
diff
changeset
|
318 |
_prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0), |
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
319 |
_next_young_region(NULL), |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
320 |
_next_dirty_cards_region(NULL), _next(NULL), _prev(NULL), |
7923 | 321 |
#ifdef ASSERT |
322 |
_containing_set(NULL), |
|
323 |
#endif // ASSERT |
|
324 |
_young_index_in_cset(-1), _surv_rate_group(NULL), _age_index(-1), |
|
325 |
_rem_set(NULL), _recorded_rs_length(0), _predicted_elapsed_time_ms(0), |
|
5350
cccf0925702e
6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents:
5344
diff
changeset
|
326 |
_predicted_bytes_to_copy(0) |
1374 | 327 |
{ |
19339 | 328 |
_rem_set = new HeapRegionRemSet(sharedOffsetArray, this); |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
329 |
assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant."); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
330 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
331 |
initialize(mr); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
332 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
333 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
334 |
void HeapRegion::initialize(MemRegion mr, bool clear_space, bool mangle_space) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
335 |
assert(_rem_set->is_empty(), "Remembered set must be empty"); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
336 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
337 |
G1OffsetTableContigSpace::initialize(mr, clear_space, mangle_space); |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
338 |
|
13756
3b72f3da8cd4
7016955: G1: remove the is_zeroed parameter from the HeapRegion constructor
johnc
parents:
13728
diff
changeset
|
339 |
hr_clear(false /*par*/, false /*clear_space*/); |
1388 | 340 |
set_top(bottom()); |
25479
0de5bbdaef7d
8047821: G1 Does not use the save_marks functionality as intended
mgerdin
parents:
25360
diff
changeset
|
341 |
record_top_and_timestamp(); |
26827 | 342 |
|
343 |
assert(mr.end() == orig_end(), |
|
344 |
err_msg("Given region end address " PTR_FORMAT " should match exactly " |
|
345 |
"bottom plus one region size, i.e. " PTR_FORMAT, |
|
346 |
p2i(mr.end()), p2i(orig_end()))); |
|
1374 | 347 |
} |
348 |
||
13336
e582172ff6ff
7114678: G1: various small fixes, code cleanup, and refactoring
tonyp
parents:
12508
diff
changeset
|
349 |
CompactibleSpace* HeapRegion::next_compaction_space() const { |
25730
7eb4e685f739
8048112: G1 Full GC needs to support the case when the very first region is not available
tschatzl
parents:
25492
diff
changeset
|
350 |
return G1CollectedHeap::heap()->next_compaction_region(this); |
1374 | 351 |
} |
352 |
||
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
353 |
void HeapRegion::note_self_forwarding_removal_start(bool during_initial_mark, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
354 |
bool during_conc_mark) { |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
355 |
// We always recreate the prev marking info and we'll explicitly |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
356 |
// mark all objects we find to be self-forwarded on the prev |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
357 |
// bitmap. So all objects need to be below PTAMS. |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
358 |
_prev_marked_bytes = 0; |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
359 |
|
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
360 |
if (during_initial_mark) { |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
361 |
// During initial-mark, we'll also explicitly mark all objects |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
362 |
// we find to be self-forwarded on the next bitmap. So all |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
363 |
// objects need to be below NTAMS. |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
364 |
_next_top_at_mark_start = top(); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
365 |
_next_marked_bytes = 0; |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
366 |
} else if (during_conc_mark) { |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
367 |
// During concurrent mark, all objects in the CSet (including |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
368 |
// the ones we find to be self-forwarded) are implicitly live. |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
369 |
// So all objects need to be above NTAMS. |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
370 |
_next_top_at_mark_start = bottom(); |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
371 |
_next_marked_bytes = 0; |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
372 |
} |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
373 |
} |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
374 |
|
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
375 |
void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
376 |
bool during_conc_mark, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
377 |
size_t marked_bytes) { |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
378 |
assert(0 <= marked_bytes && marked_bytes <= used(), |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
379 |
err_msg("marked: "SIZE_FORMAT" used: "SIZE_FORMAT, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
380 |
marked_bytes, used())); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
381 |
_prev_top_at_mark_start = top(); |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
382 |
_prev_marked_bytes = marked_bytes; |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
383 |
} |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11393
diff
changeset
|
384 |
|
1374 | 385 |
HeapWord* |
386 |
HeapRegion::object_iterate_mem_careful(MemRegion mr, |
|
387 |
ObjectClosure* cl) { |
|
388 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
|
389 |
// We used to use "block_start_careful" here. But we're actually happy |
|
390 |
// to update the BOT while we do this... |
|
391 |
HeapWord* cur = block_start(mr.start()); |
|
392 |
mr = mr.intersection(used_region()); |
|
393 |
if (mr.is_empty()) return NULL; |
|
394 |
// Otherwise, find the obj that extends onto mr.start(). |
|
395 |
||
396 |
assert(cur <= mr.start() |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
3191
diff
changeset
|
397 |
&& (oop(cur)->klass_or_null() == NULL || |
1374 | 398 |
cur + oop(cur)->size() > mr.start()), |
399 |
"postcondition of block_start"); |
|
400 |
oop obj; |
|
401 |
while (cur < mr.end()) { |
|
402 |
obj = oop(cur); |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
3191
diff
changeset
|
403 |
if (obj->klass_or_null() == NULL) { |
1374 | 404 |
// Ran into an unparseable point. |
405 |
return cur; |
|
406 |
} else if (!g1h->is_obj_dead(obj)) { |
|
407 |
cl->do_object(obj); |
|
408 |
} |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
409 |
cur += block_size(cur); |
1374 | 410 |
} |
411 |
return NULL; |
|
412 |
} |
|
413 |
||
414 |
HeapWord* |
|
415 |
HeapRegion:: |
|
416 |
oops_on_card_seq_iterate_careful(MemRegion mr, |
|
6068
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
417 |
FilterOutOfRegionClosure* cl, |
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
418 |
bool filter_young, |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
419 |
jbyte* card_ptr) { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
420 |
// Currently, we should only have to clean the card if filter_young |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
421 |
// is true and vice versa. |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
422 |
if (filter_young) { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
423 |
assert(card_ptr != NULL, "pre-condition"); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
424 |
} else { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
425 |
assert(card_ptr == NULL, "pre-condition"); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
426 |
} |
1374 | 427 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
428 |
||
429 |
// If we're within a stop-world GC, then we might look at a card in a |
|
430 |
// GC alloc region that extends onto a GC LAB, which may not be |
|
431 |
// parseable. Stop such at the "saved_mark" of the region. |
|
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
432 |
if (g1h->is_gc_active()) { |
1374 | 433 |
mr = mr.intersection(used_region_at_save_marks()); |
434 |
} else { |
|
435 |
mr = mr.intersection(used_region()); |
|
436 |
} |
|
437 |
if (mr.is_empty()) return NULL; |
|
438 |
// Otherwise, find the obj that extends onto mr.start(). |
|
439 |
||
6068
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
440 |
// The intersection of the incoming mr (for the card) and the |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
441 |
// allocated part of the region is non-empty. This implies that |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
442 |
// we have actually allocated into this region. The code in |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
443 |
// G1CollectedHeap.cpp that allocates a new region sets the |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
444 |
// is_young tag on the region before allocating. Thus we |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
445 |
// safely know if this region is young. |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
446 |
if (is_young() && filter_young) { |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
447 |
return NULL; |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
448 |
} |
80ef41e75a2d
6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents:
5547
diff
changeset
|
449 |
|
6247 | 450 |
assert(!is_young(), "check value of filter_young"); |
451 |
||
9418
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
452 |
// We can only clean the card here, after we make the decision that |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
453 |
// the card is not young. And we only clean the card if we have been |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
454 |
// asked to (i.e., card_ptr != NULL). |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
455 |
if (card_ptr != NULL) { |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
456 |
*card_ptr = CardTableModRefBS::clean_card_val(); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
457 |
// We must complete this write before we do any of the reads below. |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
458 |
OrderAccess::storeload(); |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
459 |
} |
32a87dd6b746
7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents:
8928
diff
changeset
|
460 |
|
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
461 |
// Cache the boundaries of the memory region in some const locals |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
462 |
HeapWord* const start = mr.start(); |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
463 |
HeapWord* const end = mr.end(); |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
464 |
|
1374 | 465 |
// We used to use "block_start_careful" here. But we're actually happy |
466 |
// to update the BOT while we do this... |
|
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
467 |
HeapWord* cur = block_start(start); |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
468 |
assert(cur <= start, "Postcondition"); |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
469 |
|
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
470 |
oop obj; |
1374 | 471 |
|
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
472 |
HeapWord* next = cur; |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
473 |
while (next <= start) { |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
474 |
cur = next; |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
475 |
obj = oop(cur); |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
476 |
if (obj->klass_or_null() == NULL) { |
1374 | 477 |
// Ran into an unparseable point. |
478 |
return cur; |
|
479 |
} |
|
480 |
// Otherwise... |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
481 |
next = cur + block_size(cur); |
1374 | 482 |
} |
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
483 |
|
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
484 |
// If we finish the above loop...We have a parseable object that |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
485 |
// begins on or before the start of the memory region, and ends |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
486 |
// inside or spans the entire region. |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
487 |
|
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
488 |
assert(obj == oop(cur), "sanity"); |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
489 |
assert(cur <= start, "Loop postcondition"); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
490 |
assert(obj->klass_or_null() != NULL, "Loop postcondition"); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
491 |
assert((cur + block_size(cur)) > start, "Loop postcondition"); |
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
492 |
|
1374 | 493 |
if (!g1h->is_obj_dead(obj)) { |
494 |
obj->oop_iterate(cl, mr); |
|
495 |
} |
|
496 |
||
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
497 |
while (cur < end) { |
1374 | 498 |
obj = oop(cur); |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
3191
diff
changeset
|
499 |
if (obj->klass_or_null() == NULL) { |
1374 | 500 |
// Ran into an unparseable point. |
501 |
return cur; |
|
502 |
}; |
|
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
503 |
|
1374 | 504 |
// Otherwise: |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
505 |
next = cur + block_size(cur); |
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
506 |
|
1374 | 507 |
if (!g1h->is_obj_dead(obj)) { |
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
508 |
if (next < end || !obj->is_objArray()) { |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
509 |
// This object either does not span the MemRegion |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
510 |
// boundary, or if it does it's not an array. |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
511 |
// Apply closure to whole object. |
1374 | 512 |
obj->oop_iterate(cl); |
513 |
} else { |
|
11586
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
514 |
// This obj is an array that spans the boundary. |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
515 |
// Stop at the boundary. |
ccc217c177ee
7133038: G1: Some small profile based optimizations
johnc
parents:
11455
diff
changeset
|
516 |
obj->oop_iterate(cl, mr); |
1374 | 517 |
} |
518 |
} |
|
519 |
cur = next; |
|
520 |
} |
|
521 |
return NULL; |
|
522 |
} |
|
523 |
||
19339 | 524 |
// Code roots support |
525 |
||
526 |
void HeapRegion::add_strong_code_root(nmethod* nm) { |
|
527 |
HeapRegionRemSet* hrrs = rem_set(); |
|
528 |
hrrs->add_strong_code_root(nm); |
|
529 |
} |
|
530 |
||
26422 | 531 |
void HeapRegion::add_strong_code_root_locked(nmethod* nm) { |
532 |
assert_locked_or_safepoint(CodeCache_lock); |
|
533 |
HeapRegionRemSet* hrrs = rem_set(); |
|
534 |
hrrs->add_strong_code_root_locked(nm); |
|
535 |
} |
|
536 |
||
19339 | 537 |
void HeapRegion::remove_strong_code_root(nmethod* nm) { |
538 |
HeapRegionRemSet* hrrs = rem_set(); |
|
539 |
hrrs->remove_strong_code_root(nm); |
|
540 |
} |
|
541 |
||
542 |
void HeapRegion::strong_code_roots_do(CodeBlobClosure* blk) const { |
|
543 |
HeapRegionRemSet* hrrs = rem_set(); |
|
544 |
hrrs->strong_code_roots_do(blk); |
|
545 |
} |
|
546 |
||
547 |
class VerifyStrongCodeRootOopClosure: public OopClosure { |
|
548 |
const HeapRegion* _hr; |
|
549 |
nmethod* _nm; |
|
550 |
bool _failures; |
|
551 |
bool _has_oops_in_region; |
|
552 |
||
553 |
template <class T> void do_oop_work(T* p) { |
|
554 |
T heap_oop = oopDesc::load_heap_oop(p); |
|
555 |
if (!oopDesc::is_null(heap_oop)) { |
|
556 |
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
|
557 |
||
558 |
// Note: not all the oops embedded in the nmethod are in the |
|
559 |
// current region. We only look at those which are. |
|
560 |
if (_hr->is_in(obj)) { |
|
561 |
// Object is in the region. Check that its less than top |
|
562 |
if (_hr->top() <= (HeapWord*)obj) { |
|
563 |
// Object is above top |
|
564 |
gclog_or_tty->print_cr("Object "PTR_FORMAT" in region " |
|
565 |
"["PTR_FORMAT", "PTR_FORMAT") is above " |
|
566 |
"top "PTR_FORMAT, |
|
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
19986
diff
changeset
|
567 |
(void *)obj, _hr->bottom(), _hr->end(), _hr->top()); |
19339 | 568 |
_failures = true; |
569 |
return; |
|
570 |
} |
|
571 |
// Nmethod has at least one oop in the current region |
|
572 |
_has_oops_in_region = true; |
|
573 |
} |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
public: |
|
578 |
VerifyStrongCodeRootOopClosure(const HeapRegion* hr, nmethod* nm): |
|
579 |
_hr(hr), _failures(false), _has_oops_in_region(false) {} |
|
580 |
||
581 |
void do_oop(narrowOop* p) { do_oop_work(p); } |
|
582 |
void do_oop(oop* p) { do_oop_work(p); } |
|
583 |
||
584 |
bool failures() { return _failures; } |
|
585 |
bool has_oops_in_region() { return _has_oops_in_region; } |
|
586 |
}; |
|
587 |
||
588 |
class VerifyStrongCodeRootCodeBlobClosure: public CodeBlobClosure { |
|
589 |
const HeapRegion* _hr; |
|
590 |
bool _failures; |
|
591 |
public: |
|
592 |
VerifyStrongCodeRootCodeBlobClosure(const HeapRegion* hr) : |
|
593 |
_hr(hr), _failures(false) {} |
|
594 |
||
595 |
void do_code_blob(CodeBlob* cb) { |
|
596 |
nmethod* nm = (cb == NULL) ? NULL : cb->as_nmethod_or_null(); |
|
597 |
if (nm != NULL) { |
|
598 |
// Verify that the nemthod is live |
|
599 |
if (!nm->is_alive()) { |
|
600 |
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has dead nmethod " |
|
601 |
PTR_FORMAT" in its strong code roots", |
|
602 |
_hr->bottom(), _hr->end(), nm); |
|
603 |
_failures = true; |
|
604 |
} else { |
|
605 |
VerifyStrongCodeRootOopClosure oop_cl(_hr, nm); |
|
606 |
nm->oops_do(&oop_cl); |
|
607 |
if (!oop_cl.has_oops_in_region()) { |
|
608 |
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has nmethod " |
|
609 |
PTR_FORMAT" in its strong code roots " |
|
610 |
"with no pointers into region", |
|
611 |
_hr->bottom(), _hr->end(), nm); |
|
612 |
_failures = true; |
|
613 |
} else if (oop_cl.failures()) { |
|
614 |
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has other " |
|
615 |
"failures for nmethod "PTR_FORMAT, |
|
616 |
_hr->bottom(), _hr->end(), nm); |
|
617 |
_failures = true; |
|
618 |
} |
|
619 |
} |
|
620 |
} |
|
621 |
} |
|
622 |
||
623 |
bool failures() { return _failures; } |
|
624 |
}; |
|
625 |
||
626 |
void HeapRegion::verify_strong_code_roots(VerifyOption vo, bool* failures) const { |
|
627 |
if (!G1VerifyHeapRegionCodeRoots) { |
|
628 |
// We're not verifying code roots. |
|
629 |
return; |
|
630 |
} |
|
631 |
if (vo == VerifyOption_G1UseMarkWord) { |
|
632 |
// Marking verification during a full GC is performed after class |
|
633 |
// unloading, code cache unloading, etc so the strong code roots |
|
634 |
// attached to each heap region are in an inconsistent state. They won't |
|
635 |
// be consistent until the strong code roots are rebuilt after the |
|
636 |
// actual GC. Skip verifying the strong code roots in this particular |
|
637 |
// time. |
|
638 |
assert(VerifyDuringGC, "only way to get here"); |
|
639 |
return; |
|
640 |
} |
|
641 |
||
642 |
HeapRegionRemSet* hrrs = rem_set(); |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
22551
diff
changeset
|
643 |
size_t strong_code_roots_length = hrrs->strong_code_roots_list_length(); |
19339 | 644 |
|
645 |
// if this region is empty then there should be no entries |
|
646 |
// on its strong code root list |
|
647 |
if (is_empty()) { |
|
648 |
if (strong_code_roots_length > 0) { |
|
649 |
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is empty " |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
22551
diff
changeset
|
650 |
"but has "SIZE_FORMAT" code root entries", |
19339 | 651 |
bottom(), end(), strong_code_roots_length); |
652 |
*failures = true; |
|
653 |
} |
|
654 |
return; |
|
655 |
} |
|
656 |
||
21563
ccbd86010788
8027756: assert(!hr->isHumongous()) failed: code root in humongous region?
tschatzl
parents:
21561
diff
changeset
|
657 |
if (continuesHumongous()) { |
19339 | 658 |
if (strong_code_roots_length > 0) { |
21563
ccbd86010788
8027756: assert(!hr->isHumongous()) failed: code root in humongous region?
tschatzl
parents:
21561
diff
changeset
|
659 |
gclog_or_tty->print_cr("region "HR_FORMAT" is a continuation of a humongous " |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
22551
diff
changeset
|
660 |
"region but has "SIZE_FORMAT" code root entries", |
21563
ccbd86010788
8027756: assert(!hr->isHumongous()) failed: code root in humongous region?
tschatzl
parents:
21561
diff
changeset
|
661 |
HR_FORMAT_PARAMS(this), strong_code_roots_length); |
19339 | 662 |
*failures = true; |
663 |
} |
|
664 |
return; |
|
665 |
} |
|
666 |
||
667 |
VerifyStrongCodeRootCodeBlobClosure cb_cl(this); |
|
668 |
strong_code_roots_do(&cb_cl); |
|
669 |
||
670 |
if (cb_cl.failures()) { |
|
671 |
*failures = true; |
|
672 |
} |
|
673 |
} |
|
674 |
||
1374 | 675 |
void HeapRegion::print() const { print_on(gclog_or_tty); } |
676 |
void HeapRegion::print_on(outputStream* st) const { |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
26827
diff
changeset
|
677 |
st->print("AC%4u", allocation_context()); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
26827
diff
changeset
|
678 |
|
26696
623a25e6c686
8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
26571
diff
changeset
|
679 |
st->print(" %2s", get_short_type_str()); |
1374 | 680 |
if (in_collection_set()) |
681 |
st->print(" CS"); |
|
682 |
else |
|
683 |
st->print(" "); |
|
10997
0be4b3be7197
7099849: G1: include heap region information in hs_err files
tonyp
parents:
10770
diff
changeset
|
684 |
st->print(" TS %5d", _gc_time_stamp); |
5344 | 685 |
st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT, |
686 |
prev_top_at_mark_start(), next_top_at_mark_start()); |
|
1374 | 687 |
G1OffsetTableContigSpace::print_on(st); |
688 |
} |
|
689 |
||
19339 | 690 |
class VerifyLiveClosure: public OopClosure { |
691 |
private: |
|
692 |
G1CollectedHeap* _g1h; |
|
693 |
CardTableModRefBS* _bs; |
|
694 |
oop _containing_obj; |
|
695 |
bool _failures; |
|
696 |
int _n_failures; |
|
697 |
VerifyOption _vo; |
|
698 |
public: |
|
699 |
// _vo == UsePrevMarking -> use "prev" marking information, |
|
700 |
// _vo == UseNextMarking -> use "next" marking information, |
|
701 |
// _vo == UseMarkWord -> use mark word from object header. |
|
702 |
VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : |
|
703 |
_g1h(g1h), _bs(NULL), _containing_obj(NULL), |
|
704 |
_failures(false), _n_failures(0), _vo(vo) |
|
705 |
{ |
|
706 |
BarrierSet* bs = _g1h->barrier_set(); |
|
707 |
if (bs->is_a(BarrierSet::CardTableModRef)) |
|
708 |
_bs = (CardTableModRefBS*)bs; |
|
709 |
} |
|
710 |
||
711 |
void set_containing_obj(oop obj) { |
|
712 |
_containing_obj = obj; |
|
713 |
} |
|
714 |
||
715 |
bool failures() { return _failures; } |
|
716 |
int n_failures() { return _n_failures; } |
|
717 |
||
718 |
virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
|
719 |
virtual void do_oop( oop* p) { do_oop_work(p); } |
|
720 |
||
721 |
void print_object(outputStream* out, oop obj) { |
|
722 |
#ifdef PRODUCT |
|
723 |
Klass* k = obj->klass(); |
|
724 |
const char* class_name = InstanceKlass::cast(k)->external_name(); |
|
725 |
out->print_cr("class name %s", class_name); |
|
726 |
#else // PRODUCT |
|
727 |
obj->print_on(out); |
|
728 |
#endif // PRODUCT |
|
729 |
} |
|
730 |
||
731 |
template <class T> |
|
732 |
void do_oop_work(T* p) { |
|
733 |
assert(_containing_obj != NULL, "Precondition"); |
|
734 |
assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo), |
|
735 |
"Precondition"); |
|
736 |
T heap_oop = oopDesc::load_heap_oop(p); |
|
737 |
if (!oopDesc::is_null(heap_oop)) { |
|
738 |
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
|
739 |
bool failed = false; |
|
740 |
if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) { |
|
741 |
MutexLockerEx x(ParGCRareEvent_lock, |
|
742 |
Mutex::_no_safepoint_check_flag); |
|
743 |
||
744 |
if (!_failures) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
745 |
gclog_or_tty->cr(); |
19339 | 746 |
gclog_or_tty->print_cr("----------"); |
747 |
} |
|
748 |
if (!_g1h->is_in_closed_subset(obj)) { |
|
749 |
HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
|
750 |
gclog_or_tty->print_cr("Field "PTR_FORMAT |
|
751 |
" of live obj "PTR_FORMAT" in region " |
|
752 |
"["PTR_FORMAT", "PTR_FORMAT")", |
|
753 |
p, (void*) _containing_obj, |
|
754 |
from->bottom(), from->end()); |
|
755 |
print_object(gclog_or_tty, _containing_obj); |
|
756 |
gclog_or_tty->print_cr("points to obj "PTR_FORMAT" not in the heap", |
|
757 |
(void*) obj); |
|
758 |
} else { |
|
759 |
HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
|
760 |
HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj); |
|
761 |
gclog_or_tty->print_cr("Field "PTR_FORMAT |
|
762 |
" of live obj "PTR_FORMAT" in region " |
|
763 |
"["PTR_FORMAT", "PTR_FORMAT")", |
|
764 |
p, (void*) _containing_obj, |
|
765 |
from->bottom(), from->end()); |
|
766 |
print_object(gclog_or_tty, _containing_obj); |
|
767 |
gclog_or_tty->print_cr("points to dead obj "PTR_FORMAT" in region " |
|
768 |
"["PTR_FORMAT", "PTR_FORMAT")", |
|
769 |
(void*) obj, to->bottom(), to->end()); |
|
770 |
print_object(gclog_or_tty, obj); |
|
771 |
} |
|
772 |
gclog_or_tty->print_cr("----------"); |
|
773 |
gclog_or_tty->flush(); |
|
774 |
_failures = true; |
|
775 |
failed = true; |
|
776 |
_n_failures++; |
|
777 |
} |
|
778 |
||
779 |
if (!_g1h->full_collection() || G1VerifyRSetsDuringFullGC) { |
|
780 |
HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
|
781 |
HeapRegion* to = _g1h->heap_region_containing(obj); |
|
782 |
if (from != NULL && to != NULL && |
|
783 |
from != to && |
|
784 |
!to->isHumongous()) { |
|
785 |
jbyte cv_obj = *_bs->byte_for_const(_containing_obj); |
|
786 |
jbyte cv_field = *_bs->byte_for_const(p); |
|
787 |
const jbyte dirty = CardTableModRefBS::dirty_card_val(); |
|
788 |
||
789 |
bool is_bad = !(from->is_young() |
|
790 |
|| to->rem_set()->contains_reference(p) |
|
791 |
|| !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed |
|
792 |
(_containing_obj->is_objArray() ? |
|
793 |
cv_field == dirty |
|
794 |
: cv_obj == dirty || cv_field == dirty)); |
|
795 |
if (is_bad) { |
|
796 |
MutexLockerEx x(ParGCRareEvent_lock, |
|
797 |
Mutex::_no_safepoint_check_flag); |
|
798 |
||
799 |
if (!_failures) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
800 |
gclog_or_tty->cr(); |
19339 | 801 |
gclog_or_tty->print_cr("----------"); |
802 |
} |
|
803 |
gclog_or_tty->print_cr("Missing rem set entry:"); |
|
804 |
gclog_or_tty->print_cr("Field "PTR_FORMAT" " |
|
805 |
"of obj "PTR_FORMAT", " |
|
806 |
"in region "HR_FORMAT, |
|
807 |
p, (void*) _containing_obj, |
|
808 |
HR_FORMAT_PARAMS(from)); |
|
809 |
_containing_obj->print_on(gclog_or_tty); |
|
810 |
gclog_or_tty->print_cr("points to obj "PTR_FORMAT" " |
|
811 |
"in region "HR_FORMAT, |
|
812 |
(void*) obj, |
|
813 |
HR_FORMAT_PARAMS(to)); |
|
814 |
obj->print_on(gclog_or_tty); |
|
815 |
gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.", |
|
816 |
cv_obj, cv_field); |
|
817 |
gclog_or_tty->print_cr("----------"); |
|
818 |
gclog_or_tty->flush(); |
|
819 |
_failures = true; |
|
820 |
if (!failed) _n_failures++; |
|
821 |
} |
|
822 |
} |
|
823 |
} |
|
824 |
} |
|
825 |
} |
|
826 |
}; |
|
3000 | 827 |
|
1374 | 828 |
// This really ought to be commoned up into OffsetTableContigSpace somehow. |
829 |
// We would need a mechanism to make that code skip dead objects. |
|
830 |
||
12379 | 831 |
void HeapRegion::verify(VerifyOption vo, |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
832 |
bool* failures) const { |
1374 | 833 |
G1CollectedHeap* g1 = G1CollectedHeap::heap(); |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
834 |
*failures = false; |
1374 | 835 |
HeapWord* p = bottom(); |
836 |
HeapWord* prev_p = NULL; |
|
9995
290620c08233
7004681: G1: Extend marking verification to Full GCs
johnc
parents:
9989
diff
changeset
|
837 |
VerifyLiveClosure vl_cl(g1, vo); |
6260
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
838 |
bool is_humongous = isHumongous(); |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
839 |
size_t object_num = 0; |
1374 | 840 |
while (p < top()) { |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
841 |
oop obj = oop(p); |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
842 |
size_t obj_size = block_size(p); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
843 |
object_num += 1; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
844 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
845 |
if (is_humongous != g1->isHumongous(obj_size) && |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
846 |
!g1->is_obj_dead(obj, this)) { // Dead objects may have bigger block_size since they span several objects. |
6260
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
847 |
gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size (" |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
848 |
SIZE_FORMAT" words) in a %shumongous region", |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
849 |
p, g1->isHumongous(obj_size) ? "" : "non-", |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
850 |
obj_size, is_humongous ? "" : "non-"); |
6260
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
851 |
*failures = true; |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
852 |
return; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
853 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
854 |
|
9995
290620c08233
7004681: G1: Extend marking verification to Full GCs
johnc
parents:
9989
diff
changeset
|
855 |
if (!g1->is_obj_dead_cond(obj, this, vo)) { |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
856 |
if (obj->is_oop()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13482
diff
changeset
|
857 |
Klass* klass = obj->klass(); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
858 |
bool is_metaspace_object = Metaspace::contains(klass) || |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
859 |
(vo == VerifyOption_G1UsePrevMarking && |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
860 |
ClassLoaderDataGraph::unload_list_contains(klass)); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
861 |
if (!is_metaspace_object) { |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
862 |
gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " |
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
19986
diff
changeset
|
863 |
"not metadata", klass, (void *)obj); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
864 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
865 |
return; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
866 |
} else if (!klass->is_klass()) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
867 |
gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " |
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
19986
diff
changeset
|
868 |
"not a klass", klass, (void *)obj); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
869 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
870 |
return; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
871 |
} else { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
872 |
vl_cl.set_containing_obj(obj); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13482
diff
changeset
|
873 |
obj->oop_iterate_no_header(&vl_cl); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
874 |
if (vl_cl.failures()) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
875 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
876 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
877 |
if (G1MaxVerifyFailures >= 0 && |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
878 |
vl_cl.n_failures() >= G1MaxVerifyFailures) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
879 |
return; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
880 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
881 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
882 |
} else { |
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
19986
diff
changeset
|
883 |
gclog_or_tty->print_cr(PTR_FORMAT" no an oop", (void *)obj); |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
884 |
*failures = true; |
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
885 |
return; |
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
886 |
} |
1374 | 887 |
} |
888 |
prev_p = p; |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
889 |
p += obj_size; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
890 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
891 |
|
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26422
diff
changeset
|
892 |
if (!is_young() && !is_empty()) { |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26422
diff
changeset
|
893 |
_offsets.verify(); |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26422
diff
changeset
|
894 |
} |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26422
diff
changeset
|
895 |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
896 |
if (p != top()) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
897 |
gclog_or_tty->print_cr("end of last object "PTR_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
898 |
"does not match top "PTR_FORMAT, p, top()); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
899 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
900 |
return; |
1374 | 901 |
} |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
902 |
|
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
903 |
HeapWord* the_end = end(); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
904 |
assert(p == top(), "it should still hold"); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
905 |
// Do some extra BOT consistency checking for addresses in the |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
906 |
// range [top, end). BOT look-ups in this range should yield |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
907 |
// top. No point in doing that if top == end (there's nothing there). |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
908 |
if (p < the_end) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
909 |
// Look up top |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
910 |
HeapWord* addr_1 = p; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
911 |
HeapWord* b_start_1 = _offsets.block_start_const(addr_1); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
912 |
if (b_start_1 != p) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
913 |
gclog_or_tty->print_cr("BOT look up for top: "PTR_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
914 |
" yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
915 |
addr_1, b_start_1, p); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
916 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
917 |
return; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
918 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
919 |
|
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
920 |
// Look up top + 1 |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
921 |
HeapWord* addr_2 = p + 1; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
922 |
if (addr_2 < the_end) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
923 |
HeapWord* b_start_2 = _offsets.block_start_const(addr_2); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
924 |
if (b_start_2 != p) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
925 |
gclog_or_tty->print_cr("BOT look up for top + 1: "PTR_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
926 |
" yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
927 |
addr_2, b_start_2, p); |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
928 |
*failures = true; |
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
929 |
return; |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
930 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
931 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
932 |
|
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
933 |
// Look up an address between top and end |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
934 |
size_t diff = pointer_delta(the_end, p) / 2; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
935 |
HeapWord* addr_3 = p + diff; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
936 |
if (addr_3 < the_end) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
937 |
HeapWord* b_start_3 = _offsets.block_start_const(addr_3); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
938 |
if (b_start_3 != p) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
939 |
gclog_or_tty->print_cr("BOT look up for top + diff: "PTR_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
940 |
" yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
941 |
addr_3, b_start_3, p); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
942 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
943 |
return; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
944 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
945 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
946 |
|
22551 | 947 |
// Look up end - 1 |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
948 |
HeapWord* addr_4 = the_end - 1; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
949 |
HeapWord* b_start_4 = _offsets.block_start_const(addr_4); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
950 |
if (b_start_4 != p) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
951 |
gclog_or_tty->print_cr("BOT look up for end - 1: "PTR_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
952 |
" yielded "PTR_FORMAT", expecting "PTR_FORMAT, |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
953 |
addr_4, b_start_4, p); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
954 |
*failures = true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
955 |
return; |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
956 |
} |
1374 | 957 |
} |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
958 |
|
6260
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
959 |
if (is_humongous && object_num > 1) { |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
960 |
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is humongous " |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
961 |
"but has "SIZE_FORMAT", objects", |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
962 |
bottom(), end(), object_num); |
fba83fd3adc7
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
6247
diff
changeset
|
963 |
*failures = true; |
4023
6c3401503290
6882730: G1: parallel heap verification messes up region dump
tonyp
parents:
3697
diff
changeset
|
964 |
return; |
1374 | 965 |
} |
19339 | 966 |
|
967 |
verify_strong_code_roots(vo, failures); |
|
968 |
} |
|
969 |
||
970 |
void HeapRegion::verify() const { |
|
971 |
bool dummy = false; |
|
972 |
verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy); |
|
1374 | 973 |
} |
974 |
||
975 |
// G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go |
|
976 |
// away eventually. |
|
977 |
||
1388 | 978 |
void G1OffsetTableContigSpace::clear(bool mangle_space) { |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
979 |
set_top(bottom()); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
980 |
set_saved_mark_word(bottom()); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
981 |
CompactibleSpace::clear(mangle_space); |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
982 |
reset_bot(); |
1374 | 983 |
} |
984 |
||
985 |
void G1OffsetTableContigSpace::set_bottom(HeapWord* new_bottom) { |
|
986 |
Space::set_bottom(new_bottom); |
|
987 |
_offsets.set_bottom(new_bottom); |
|
988 |
} |
|
989 |
||
990 |
void G1OffsetTableContigSpace::set_end(HeapWord* new_end) { |
|
991 |
Space::set_end(new_end); |
|
992 |
_offsets.resize(new_end - bottom()); |
|
993 |
} |
|
994 |
||
995 |
void G1OffsetTableContigSpace::print() const { |
|
996 |
print_short(); |
|
997 |
gclog_or_tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " |
|
998 |
INTPTR_FORMAT ", " INTPTR_FORMAT ")", |
|
999 |
bottom(), top(), _offsets.threshold(), end()); |
|
1000 |
} |
|
1001 |
||
1002 |
HeapWord* G1OffsetTableContigSpace::initialize_threshold() { |
|
1003 |
return _offsets.initialize_threshold(); |
|
1004 |
} |
|
1005 |
||
1006 |
HeapWord* G1OffsetTableContigSpace::cross_threshold(HeapWord* start, |
|
1007 |
HeapWord* end) { |
|
1008 |
_offsets.alloc_block(start, end); |
|
1009 |
return _offsets.threshold(); |
|
1010 |
} |
|
1011 |
||
1012 |
HeapWord* G1OffsetTableContigSpace::saved_mark_word() const { |
|
1013 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
|
1014 |
assert( _gc_time_stamp <= g1h->get_gc_time_stamp(), "invariant" ); |
|
1015 |
if (_gc_time_stamp < g1h->get_gc_time_stamp()) |
|
1016 |
return top(); |
|
1017 |
else |
|
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1018 |
return Space::saved_mark_word(); |
1374 | 1019 |
} |
1020 |
||
25479
0de5bbdaef7d
8047821: G1 Does not use the save_marks functionality as intended
mgerdin
parents:
25360
diff
changeset
|
1021 |
void G1OffsetTableContigSpace::record_top_and_timestamp() { |
1374 | 1022 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
1023 |
unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp(); |
|
1024 |
||
1025 |
if (_gc_time_stamp < curr_gc_time_stamp) { |
|
1026 |
// The order of these is important, as another thread might be |
|
1027 |
// about to start scanning this region. If it does so after |
|
1028 |
// set_saved_mark and before _gc_time_stamp = ..., then the latter |
|
1029 |
// will be false, and it will pick up top() as the high water mark |
|
1030 |
// of region. If it does so after _gc_time_stamp = ..., then it |
|
1031 |
// will pick up the right saved_mark_word() as the high water mark |
|
22551 | 1032 |
// of the region. Either way, the behavior will be correct. |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1033 |
Space::set_saved_mark_word(top()); |
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
3191
diff
changeset
|
1034 |
OrderAccess::storestore(); |
1385
1751733b089b
6723570: G1: assertion failure: p == current_top or oop(p)->is_oop(),"p is not a block start" (revisited!)
iveresov
parents:
1374
diff
changeset
|
1035 |
_gc_time_stamp = curr_gc_time_stamp; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
7923
diff
changeset
|
1036 |
// No need to do another barrier to flush the writes above. If |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
7923
diff
changeset
|
1037 |
// this is called in parallel with other threads trying to |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
7923
diff
changeset
|
1038 |
// allocate into the region, the caller should call this while |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
7923
diff
changeset
|
1039 |
// holding a lock and when the lock is released the writes will be |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
7923
diff
changeset
|
1040 |
// flushed. |
1374 | 1041 |
} |
1042 |
} |
|
1043 |
||
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1044 |
void G1OffsetTableContigSpace::safe_object_iterate(ObjectClosure* blk) { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1045 |
object_iterate(blk); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1046 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1047 |
|
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1048 |
void G1OffsetTableContigSpace::object_iterate(ObjectClosure* blk) { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1049 |
HeapWord* p = bottom(); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1050 |
while (p < top()) { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1051 |
if (block_is_obj(p)) { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1052 |
blk->do_object(oop(p)); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1053 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1054 |
p += block_size(p); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1055 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1056 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1057 |
|
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1058 |
#define block_is_always_obj(q) true |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1059 |
void G1OffsetTableContigSpace::prepare_for_compaction(CompactPoint* cp) { |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1060 |
SCAN_AND_FORWARD(cp, top, block_is_always_obj, block_size); |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1061 |
} |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1062 |
#undef block_is_always_obj |
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1063 |
|
1374 | 1064 |
G1OffsetTableContigSpace:: |
1065 |
G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, |
|
13756
3b72f3da8cd4
7016955: G1: remove the is_zeroed parameter from the HeapRegion constructor
johnc
parents:
13728
diff
changeset
|
1066 |
MemRegion mr) : |
1374 | 1067 |
_offsets(sharedOffsetArray, mr), |
1068 |
_par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true), |
|
1069 |
_gc_time_stamp(0) |
|
1070 |
{ |
|
1071 |
_offsets.set_space(this); |
|
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
1072 |
} |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
1073 |
|
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
1074 |
void G1OffsetTableContigSpace::initialize(MemRegion mr, bool clear_space, bool mangle_space) { |
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
1075 |
CompactibleSpace::initialize(mr, clear_space, mangle_space); |
25481
1427aa24638c
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
25479
diff
changeset
|
1076 |
_top = bottom(); |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
1077 |
reset_bot(); |
1374 | 1078 |
} |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25730
diff
changeset
|
1079 |