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