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/parallel/adjoiningGenerations.hpp"
27 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
28 #include "gc/parallel/generationSizer.hpp"
29 #include "gc/parallel/parallelScavengeHeap.hpp"
30 #include "logging/log.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "utilities/align.hpp"
33 #include "utilities/ostream.hpp"
34
35 // If boundary moving is being used, create the young gen and old
36 // gen with ASPSYoungGen and ASPSOldGen, respectively. Revert to
37 // the old behavior otherwise (with PSYoungGen and PSOldGen).
38
39 AdjoiningGenerations::AdjoiningGenerations(ReservedSpace old_young_rs,
40 GenerationSizer* policy,
41 size_t alignment) :
42 _virtual_spaces(old_young_rs, policy->min_old_size(),
43 policy->min_young_size(), alignment) {
44 size_t init_low_byte_size = policy->initial_old_size();
45 size_t min_low_byte_size = policy->min_old_size();
46 size_t max_low_byte_size = policy->max_old_size();
47 size_t init_high_byte_size = policy->initial_young_size();
48 size_t min_high_byte_size = policy->min_young_size();
49 size_t max_high_byte_size = policy->max_young_size();
50
112 assert(young_gen()->gen_size_limit() == young_rs.size(),
113 "Consistency check");
114 _old_gen->initialize(old_rs, alignment, "old", 1);
115 assert(old_gen()->gen_size_limit() == old_rs.size(), "Consistency check");
116 }
117 }
118
119 size_t AdjoiningGenerations::reserved_byte_size() {
120 return virtual_spaces()->reserved_space().size();
121 }
122
123 void log_before_expansion(bool old, size_t expand_in_bytes, size_t change_in_bytes, size_t max_size) {
124 Log(heap, ergo) log;
125 if (!log.is_debug()) {
126 return;
127 }
128 log.debug("Before expansion of %s gen with boundary move", old ? "old" : "young");
129 log.debug(" Requested change: " SIZE_FORMAT_HEX " Attempted change: " SIZE_FORMAT_HEX,
130 expand_in_bytes, change_in_bytes);
131 ResourceMark rm;
132 ParallelScavengeHeap::heap()->print_on(log.debug_stream());
133 log.debug(" PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
134 }
135
136 void log_after_expansion(bool old, size_t max_size) {
137 Log(heap, ergo) log;
138 if (!log.is_debug()) {
139 return;
140 }
141 log.debug("After expansion of %s gen with boundary move", old ? "old" : "young");
142 ResourceMark rm;
143 ParallelScavengeHeap::heap()->print_on(log.debug_stream());
144 log.debug(" PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
145 }
146
147 // Make checks on the current sizes of the generations and
148 // the constraints on the sizes of the generations. Push
149 // up the boundary within the constraints. A partial
150 // push can occur.
151 void AdjoiningGenerations::request_old_gen_expansion(size_t expand_in_bytes) {
152 assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
153
154 assert_lock_strong(ExpandHeap_lock);
155 assert_locked_or_safepoint(Heap_lock);
156
157 // These sizes limit the amount the boundaries can move. Effectively,
158 // the generation says how much it is willing to yield to the other
159 // generation.
160 const size_t young_gen_available = young_gen()->available_for_contraction();
161 const size_t old_gen_available = old_gen()->available_for_expansion();
162 const size_t alignment = virtual_spaces()->alignment();
163 size_t change_in_bytes = MIN3(young_gen_available,
|
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/parallel/adjoiningGenerations.hpp"
27 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
28 #include "gc/parallel/generationSizer.hpp"
29 #include "gc/parallel/parallelScavengeHeap.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "utilities/align.hpp"
34 #include "utilities/ostream.hpp"
35
36 // If boundary moving is being used, create the young gen and old
37 // gen with ASPSYoungGen and ASPSOldGen, respectively. Revert to
38 // the old behavior otherwise (with PSYoungGen and PSOldGen).
39
40 AdjoiningGenerations::AdjoiningGenerations(ReservedSpace old_young_rs,
41 GenerationSizer* policy,
42 size_t alignment) :
43 _virtual_spaces(old_young_rs, policy->min_old_size(),
44 policy->min_young_size(), alignment) {
45 size_t init_low_byte_size = policy->initial_old_size();
46 size_t min_low_byte_size = policy->min_old_size();
47 size_t max_low_byte_size = policy->max_old_size();
48 size_t init_high_byte_size = policy->initial_young_size();
49 size_t min_high_byte_size = policy->min_young_size();
50 size_t max_high_byte_size = policy->max_young_size();
51
113 assert(young_gen()->gen_size_limit() == young_rs.size(),
114 "Consistency check");
115 _old_gen->initialize(old_rs, alignment, "old", 1);
116 assert(old_gen()->gen_size_limit() == old_rs.size(), "Consistency check");
117 }
118 }
119
120 size_t AdjoiningGenerations::reserved_byte_size() {
121 return virtual_spaces()->reserved_space().size();
122 }
123
124 void log_before_expansion(bool old, size_t expand_in_bytes, size_t change_in_bytes, size_t max_size) {
125 Log(heap, ergo) log;
126 if (!log.is_debug()) {
127 return;
128 }
129 log.debug("Before expansion of %s gen with boundary move", old ? "old" : "young");
130 log.debug(" Requested change: " SIZE_FORMAT_HEX " Attempted change: " SIZE_FORMAT_HEX,
131 expand_in_bytes, change_in_bytes);
132 ResourceMark rm;
133 LogStream ls(log.debug());
134 ParallelScavengeHeap::heap()->print_on(&ls);
135 log.debug(" PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
136 }
137
138 void log_after_expansion(bool old, size_t max_size) {
139 Log(heap, ergo) log;
140 if (!log.is_debug()) {
141 return;
142 }
143 log.debug("After expansion of %s gen with boundary move", old ? "old" : "young");
144 ResourceMark rm;
145 LogStream ls(log.debug());
146 ParallelScavengeHeap::heap()->print_on(&ls);
147 log.debug(" PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
148 }
149
150 // Make checks on the current sizes of the generations and
151 // the constraints on the sizes of the generations. Push
152 // up the boundary within the constraints. A partial
153 // push can occur.
154 void AdjoiningGenerations::request_old_gen_expansion(size_t expand_in_bytes) {
155 assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
156
157 assert_lock_strong(ExpandHeap_lock);
158 assert_locked_or_safepoint(Heap_lock);
159
160 // These sizes limit the amount the boundaries can move. Effectively,
161 // the generation says how much it is willing to yield to the other
162 // generation.
163 const size_t young_gen_available = young_gen()->available_for_contraction();
164 const size_t old_gen_available = old_gen()->available_for_expansion();
165 const size_t alignment = virtual_spaces()->alignment();
166 size_t change_in_bytes = MIN3(young_gen_available,
|