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/parallel/parallelArguments.hpp"
27 #include "gc/parallel/parallelScavengeHeap.hpp"
28 #include "gc/shared/adaptiveSizePolicy.hpp"
29 #include "gc/shared/collectorPolicy.hpp"
30 #include "gc/shared/gcArguments.inline.hpp"
31 #include "runtime/globals.hpp"
32 #include "runtime/globals_extension.hpp"
33 #include "runtime/java.hpp"
34 #include "runtime/vm_version.hpp"
35 #include "utilities/defaultStream.hpp"
36
37 size_t ParallelArguments::conservative_max_heap_alignment() {
38 return CollectorPolicy::compute_heap_alignment();
39 }
40
41 void ParallelArguments::initialize_flags() {
42 GCArguments::initialize_flags();
43 assert(UseParallelGC || UseParallelOldGC, "Error");
44 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
45 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
46 FLAG_SET_DEFAULT(UseParallelOldGC, true);
47 }
48 FLAG_SET_DEFAULT(UseParallelGC, true);
49
50 // If no heap maximum was requested explicitly, use some reasonable fraction
51 // of the physical memory, up to a maximum of 1GB.
52 FLAG_SET_DEFAULT(ParallelGCThreads,
53 Abstract_VM_Version::parallel_worker_threads());
54 if (ParallelGCThreads == 0) {
55 jio_fprintf(defaultStream::error_stream(),
56 "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
57 vm_exit(1);
58 }
75 if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
76 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
77 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
78 }
79 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
80 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
81 }
82 }
83
84 if (UseParallelOldGC) {
85 // Par compact uses lower default values since they are treated as
86 // minimums. These are different defaults because of the different
87 // interpretation and are not ergonomically set.
88 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
89 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
90 }
91 }
92 }
93
94 CollectedHeap* ParallelArguments::create_heap() {
95 return create_heap_with_policy<ParallelScavengeHeap, GenerationSizer>();
96 }
|
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/parallel/parallelArguments.hpp"
27 #include "gc/parallel/parallelScavengeHeap.hpp"
28 #include "gc/shared/adaptiveSizePolicy.hpp"
29 #include "gc/shared/gcArguments.inline.hpp"
30 #include "gc/shared/genArguments.hpp"
31 #include "runtime/globals.hpp"
32 #include "runtime/globals_extension.hpp"
33 #include "runtime/java.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/vm_version.hpp"
36 #include "utilities/defaultStream.hpp"
37
38 size_t ParallelArguments::conservative_max_heap_alignment() {
39 return compute_heap_alignment();
40 }
41
42 void ParallelArguments::initialize_heap_flags_one_pass(PSSettings& s) {
43 // Do basic sizing work
44 GenArguments::initialize_heap_flags(s);
45
46 // The survivor ratio's are calculated "raw", unlike the
47 // default gc, which adds 2 to the ratio value. We need to
48 // make sure the values are valid before using them.
49 if (MinSurvivorRatio < 3) {
50 FLAG_SET_ERGO(uintx, MinSurvivorRatio, 3);
51 }
52
53 if (InitialSurvivorRatio < 3) {
54 FLAG_SET_ERGO(uintx, InitialSurvivorRatio, 3);
55 }
56 }
57
58 PSSettings ParallelArguments::initialize_heap_flags() {
59 PSSettings s;
60
61 initialize_heap_flags_one_pass(s);
62
63 const size_t max_page_sz = os::page_size_for_region_aligned(s._max_heap_byte_size, 8);
64 const size_t min_pages = 4; // 1 for eden + 1 for each survivor + 1 for old
65 const size_t min_page_sz = os::page_size_for_region_aligned(s._min_heap_byte_size, min_pages);
66 const size_t page_sz = MIN2(max_page_sz, min_page_sz);
67
68 // Can a page size be something else than a power of two?
69 assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2");
70 size_t new_alignment = align_up(page_sz, s._gen_alignment);
71 if (new_alignment != s._gen_alignment) {
72 s._gen_alignment = new_alignment;
73 s._space_alignment = new_alignment;
74 // Redo everything from the start
75 initialize_heap_flags_one_pass(s);
76 }
77
78 GenArguments::initialize_size_info(s);
79
80 return s;
81 }
82
83 void ParallelArguments::initialize_flags() {
84 GCArguments::initialize_flags();
85 assert(UseParallelGC || UseParallelOldGC, "Error");
86 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
87 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
88 FLAG_SET_DEFAULT(UseParallelOldGC, true);
89 }
90 FLAG_SET_DEFAULT(UseParallelGC, true);
91
92 // If no heap maximum was requested explicitly, use some reasonable fraction
93 // of the physical memory, up to a maximum of 1GB.
94 FLAG_SET_DEFAULT(ParallelGCThreads,
95 Abstract_VM_Version::parallel_worker_threads());
96 if (ParallelGCThreads == 0) {
97 jio_fprintf(defaultStream::error_stream(),
98 "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
99 vm_exit(1);
100 }
117 if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
118 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
119 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
120 }
121 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
122 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
123 }
124 }
125
126 if (UseParallelOldGC) {
127 // Par compact uses lower default values since they are treated as
128 // minimums. These are different defaults because of the different
129 // interpretation and are not ergonomically set.
130 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
131 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
132 }
133 }
134 }
135
136 CollectedHeap* ParallelArguments::create_heap() {
137 return new ParallelScavengeHeap(initialize_heap_flags());
138 }
|