author | mgerdin |
Wed, 27 Apr 2016 11:25:16 +0200 | |
changeset 38109 | 6503703df058 |
parent 37985 | 539c597ee0fa |
child 38162 | 4e2c3433a3ae |
permissions | -rw-r--r-- |
33203 | 1 |
/* |
37039
79f62b89a7a6
8151178: Move the collection set out of the G1 collector policy
mgerdin
parents:
36365
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33203 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "gc/g1/g1CollectedHeap.hpp" |
|
37039
79f62b89a7a6
8151178: Move the collection set out of the G1 collector policy
mgerdin
parents:
36365
diff
changeset
|
27 |
#include "gc/g1/g1CollectionSet.hpp" |
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37039
diff
changeset
|
28 |
#include "gc/g1/g1Policy.hpp" |
33203 | 29 |
#include "gc/g1/heapRegion.hpp" |
30 |
#include "gc/g1/heapRegion.inline.hpp" |
|
31 |
#include "gc/g1/heapRegionRemSet.hpp" |
|
32 |
#include "gc/g1/youngList.hpp" |
|
35061 | 33 |
#include "logging/log.hpp" |
33203 | 34 |
#include "utilities/ostream.hpp" |
35 |
||
36 |
YoungList::YoungList(G1CollectedHeap* g1h) : |
|
36365
bcc9c9afda49
8150390: Move rs length sampling data to the sampling thread
mgerdin
parents:
36090
diff
changeset
|
37 |
_g1h(g1h), _head(NULL), _length(0), |
33203 | 38 |
_survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) { |
36365
bcc9c9afda49
8150390: Move rs length sampling data to the sampling thread
mgerdin
parents:
36090
diff
changeset
|
39 |
guarantee(check_list_empty(), "just making sure..."); |
33203 | 40 |
} |
41 |
||
42 |
void YoungList::push_region(HeapRegion *hr) { |
|
43 |
assert(!hr->is_young(), "should not already be young"); |
|
44 |
assert(hr->get_next_young_region() == NULL, "cause it should!"); |
|
45 |
||
46 |
hr->set_next_young_region(_head); |
|
47 |
_head = hr; |
|
48 |
||
38109
6503703df058
8155209: Move setting of young index in cset to G1CollectionSet
mgerdin
parents:
37985
diff
changeset
|
49 |
_g1h->g1_policy()->set_region_eden(hr); |
33203 | 50 |
++_length; |
51 |
} |
|
52 |
||
53 |
void YoungList::add_survivor_region(HeapRegion* hr) { |
|
54 |
assert(hr->is_survivor(), "should be flagged as survivor region"); |
|
55 |
assert(hr->get_next_young_region() == NULL, "cause it should!"); |
|
56 |
||
57 |
hr->set_next_young_region(_survivor_head); |
|
58 |
if (_survivor_head == NULL) { |
|
59 |
_survivor_tail = hr; |
|
60 |
} |
|
61 |
_survivor_head = hr; |
|
62 |
++_survivor_length; |
|
63 |
} |
|
64 |
||
65 |
void YoungList::empty_list(HeapRegion* list) { |
|
66 |
while (list != NULL) { |
|
67 |
HeapRegion* next = list->get_next_young_region(); |
|
68 |
list->set_next_young_region(NULL); |
|
69 |
list->uninstall_surv_rate_group(); |
|
70 |
// This is called before a Full GC and all the non-empty / |
|
71 |
// non-humongous regions at the end of the Full GC will end up as |
|
72 |
// old anyway. |
|
73 |
list->set_old(); |
|
74 |
list = next; |
|
75 |
} |
|
76 |
} |
|
77 |
||
78 |
void YoungList::empty_list() { |
|
79 |
assert(check_list_well_formed(), "young list should be well formed"); |
|
80 |
||
81 |
empty_list(_head); |
|
82 |
_head = NULL; |
|
83 |
_length = 0; |
|
84 |
||
85 |
empty_list(_survivor_head); |
|
86 |
_survivor_head = NULL; |
|
87 |
_survivor_tail = NULL; |
|
88 |
_survivor_length = 0; |
|
89 |
||
36365
bcc9c9afda49
8150390: Move rs length sampling data to the sampling thread
mgerdin
parents:
36090
diff
changeset
|
90 |
assert(check_list_empty(), "just making sure..."); |
33203 | 91 |
} |
92 |
||
93 |
bool YoungList::check_list_well_formed() { |
|
94 |
bool ret = true; |
|
95 |
||
96 |
uint length = 0; |
|
97 |
HeapRegion* curr = _head; |
|
98 |
HeapRegion* last = NULL; |
|
99 |
while (curr != NULL) { |
|
100 |
if (!curr->is_young()) { |
|
36090
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
101 |
log_error(gc, verify)("### YOUNG REGION " PTR_FORMAT "-" PTR_FORMAT " " |
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
102 |
"incorrectly tagged (y: %d, surv: %d)", |
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
103 |
p2i(curr->bottom()), p2i(curr->end()), |
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
104 |
curr->is_young(), curr->is_survivor()); |
33203 | 105 |
ret = false; |
106 |
} |
|
107 |
++length; |
|
108 |
last = curr; |
|
109 |
curr = curr->get_next_young_region(); |
|
110 |
} |
|
111 |
ret = ret && (length == _length); |
|
112 |
||
113 |
if (!ret) { |
|
36090
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
114 |
log_error(gc, verify)("### YOUNG LIST seems not well formed!"); |
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
115 |
log_error(gc, verify)("### list has %u entries, _length is %u", length, _length); |
33203 | 116 |
} |
117 |
||
118 |
return ret; |
|
119 |
} |
|
120 |
||
36365
bcc9c9afda49
8150390: Move rs length sampling data to the sampling thread
mgerdin
parents:
36090
diff
changeset
|
121 |
bool YoungList::check_list_empty() { |
33203 | 122 |
bool ret = true; |
123 |
||
124 |
if (_length != 0) { |
|
36090
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
125 |
log_error(gc, verify)("### YOUNG LIST should have 0 length, not %u", _length); |
33203 | 126 |
ret = false; |
127 |
} |
|
128 |
if (_head != NULL) { |
|
36090
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
129 |
log_error(gc, verify)("### YOUNG LIST does not have a NULL head"); |
33203 | 130 |
ret = false; |
131 |
} |
|
132 |
if (!ret) { |
|
36090
cffc1dd98258
8149541: Use log_error() instead of log_info() when verification reports a problem
brutisso
parents:
35061
diff
changeset
|
133 |
log_error(gc, verify)("### YOUNG LIST does not seem empty"); |
33203 | 134 |
} |
135 |
||
136 |
return ret; |
|
137 |
} |
|
138 |
||
139 |
void |
|
140 |
YoungList::reset_auxilary_lists() { |
|
141 |
guarantee( is_empty(), "young list should be empty" ); |
|
142 |
assert(check_list_well_formed(), "young list should be well formed"); |
|
143 |
||
144 |
// Add survivor regions to SurvRateGroup. |
|
145 |
_g1h->g1_policy()->note_start_adding_survivor_regions(); |
|
146 |
_g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */); |
|
147 |
||
148 |
for (HeapRegion* curr = _survivor_head; |
|
149 |
curr != NULL; |
|
150 |
curr = curr->get_next_young_region()) { |
|
38109
6503703df058
8155209: Move setting of young index in cset to G1CollectionSet
mgerdin
parents:
37985
diff
changeset
|
151 |
_g1h->g1_policy()->set_region_survivor(curr); |
33203 | 152 |
|
153 |
// The region is a non-empty survivor so let's add it to |
|
154 |
// the incremental collection set for the next evacuation |
|
155 |
// pause. |
|
37039
79f62b89a7a6
8151178: Move the collection set out of the G1 collector policy
mgerdin
parents:
36365
diff
changeset
|
156 |
_g1h->collection_set()->add_survivor_regions(curr); |
33203 | 157 |
} |
158 |
_g1h->g1_policy()->note_stop_adding_survivor_regions(); |
|
159 |
||
160 |
_head = _survivor_head; |
|
161 |
_length = _survivor_length; |
|
162 |
if (_survivor_head != NULL) { |
|
163 |
assert(_survivor_tail != NULL, "cause it shouldn't be"); |
|
164 |
assert(_survivor_length > 0, "invariant"); |
|
165 |
_survivor_tail->set_next_young_region(NULL); |
|
166 |
} |
|
167 |
||
168 |
// Don't clear the survivor list handles until the start of |
|
169 |
// the next evacuation pause - we need it in order to re-tag |
|
170 |
// the survivor regions from this evacuation pause as 'young' |
|
171 |
// at the start of the next. |
|
172 |
||
173 |
_g1h->g1_policy()->finished_recalculating_age_indexes(false /* is_survivors */); |
|
174 |
||
175 |
assert(check_list_well_formed(), "young list should be well formed"); |
|
176 |
} |
|
177 |
||
178 |
void YoungList::print() { |
|
179 |
HeapRegion* lists[] = {_head, _survivor_head}; |
|
180 |
const char* names[] = {"YOUNG", "SURVIVOR"}; |
|
181 |
||
182 |
for (uint list = 0; list < ARRAY_SIZE(lists); ++list) { |
|
35061 | 183 |
tty->print_cr("%s LIST CONTENTS", names[list]); |
33203 | 184 |
HeapRegion *curr = lists[list]; |
185 |
if (curr == NULL) { |
|
35061 | 186 |
tty->print_cr(" empty"); |
33203 | 187 |
} |
188 |
while (curr != NULL) { |
|
35061 | 189 |
tty->print_cr(" " HR_FORMAT ", P: " PTR_FORMAT ", N: " PTR_FORMAT ", age: %4d", |
33203 | 190 |
HR_FORMAT_PARAMS(curr), |
191 |
p2i(curr->prev_top_at_mark_start()), |
|
192 |
p2i(curr->next_top_at_mark_start()), |
|
193 |
curr->age_in_surv_rate_group_cond()); |
|
194 |
curr = curr->get_next_young_region(); |
|
195 |
} |
|
196 |
} |
|
197 |
||
35061 | 198 |
tty->cr(); |
33203 | 199 |
} |