1 /*
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
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 *
53 GCArguments& _arguments;
54 const char* _hs_err_name;
55
56 IncludedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) :
57 _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {}
58 };
59
60 EPSILONGC_ONLY(static EpsilonArguments epsilonArguments;)
61 G1GC_ONLY(static G1Arguments g1Arguments;)
62 PARALLELGC_ONLY(static ParallelArguments parallelArguments;)
63 SERIALGC_ONLY(static SerialArguments serialArguments;)
64 SHENANDOAHGC_ONLY(static ShenandoahArguments shenandoahArguments;)
65 ZGC_ONLY(static ZArguments zArguments;)
66
67 // Table of included GCs, for translating between command
68 // line flag, CollectedHeap::Name and GCArguments instance.
69 static const IncludedGC IncludedGCs[] = {
70 EPSILONGC_ONLY_ARG(IncludedGC(UseEpsilonGC, CollectedHeap::Epsilon, epsilonArguments, "epsilon gc"))
71 G1GC_ONLY_ARG(IncludedGC(UseG1GC, CollectedHeap::G1, g1Arguments, "g1 gc"))
72 PARALLELGC_ONLY_ARG(IncludedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments, "parallel gc"))
73 PARALLELGC_ONLY_ARG(IncludedGC(UseParallelOldGC, CollectedHeap::Parallel, parallelArguments, "parallel gc"))
74 SERIALGC_ONLY_ARG(IncludedGC(UseSerialGC, CollectedHeap::Serial, serialArguments, "serial gc"))
75 SHENANDOAHGC_ONLY_ARG(IncludedGC(UseShenandoahGC, CollectedHeap::Shenandoah, shenandoahArguments, "shenandoah gc"))
76 ZGC_ONLY_ARG(IncludedGC(UseZGC, CollectedHeap::Z, zArguments, "z gc"))
77 };
78
79 #define FOR_EACH_INCLUDED_GC(var) \
80 for (const IncludedGC* var = &IncludedGCs[0]; var < &IncludedGCs[ARRAY_SIZE(IncludedGCs)]; var++)
81
82 #define FAIL_IF_SELECTED(option, enabled) \
83 if (option == enabled && FLAG_IS_CMDLINE(option)) { \
84 vm_exit_during_initialization(enabled ? \
85 "Option -XX:+" #option " not supported" : \
86 "Option -XX:-" #option " not supported"); \
87 }
88
89 GCArguments* GCConfig::_arguments = NULL;
90 bool GCConfig::_gc_selected_ergonomically = false;
91
92 void GCConfig::fail_if_non_included_gc_is_selected() {
93 NOT_EPSILONGC( FAIL_IF_SELECTED(UseEpsilonGC, true));
94 NOT_G1GC( FAIL_IF_SELECTED(UseG1GC, true));
95 NOT_PARALLELGC( FAIL_IF_SELECTED(UseParallelGC, true));
96 NOT_PARALLELGC( FAIL_IF_SELECTED(UseParallelOldGC, true));
97 NOT_SERIALGC( FAIL_IF_SELECTED(UseSerialGC, true));
98 NOT_SERIALGC( FAIL_IF_SELECTED(UseParallelOldGC, false));
99 NOT_SHENANDOAHGC(FAIL_IF_SELECTED(UseShenandoahGC, true));
100 NOT_ZGC( FAIL_IF_SELECTED(UseZGC, true));
101 }
102
103 void GCConfig::select_gc_ergonomically() {
104 if (os::is_server_class_machine()) {
105 #if INCLUDE_G1GC
106 FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true);
107 #elif INCLUDE_PARALLELGC
108 FLAG_SET_ERGO_IF_DEFAULT(UseParallelGC, true);
109 #elif INCLUDE_SERIALGC
110 FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
111 #endif
112 } else {
113 #if INCLUDE_SERIALGC
114 FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
115 #endif
116 }
117 }
118
|
1 /*
2 * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
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 *
53 GCArguments& _arguments;
54 const char* _hs_err_name;
55
56 IncludedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) :
57 _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {}
58 };
59
60 EPSILONGC_ONLY(static EpsilonArguments epsilonArguments;)
61 G1GC_ONLY(static G1Arguments g1Arguments;)
62 PARALLELGC_ONLY(static ParallelArguments parallelArguments;)
63 SERIALGC_ONLY(static SerialArguments serialArguments;)
64 SHENANDOAHGC_ONLY(static ShenandoahArguments shenandoahArguments;)
65 ZGC_ONLY(static ZArguments zArguments;)
66
67 // Table of included GCs, for translating between command
68 // line flag, CollectedHeap::Name and GCArguments instance.
69 static const IncludedGC IncludedGCs[] = {
70 EPSILONGC_ONLY_ARG(IncludedGC(UseEpsilonGC, CollectedHeap::Epsilon, epsilonArguments, "epsilon gc"))
71 G1GC_ONLY_ARG(IncludedGC(UseG1GC, CollectedHeap::G1, g1Arguments, "g1 gc"))
72 PARALLELGC_ONLY_ARG(IncludedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments, "parallel gc"))
73 SERIALGC_ONLY_ARG(IncludedGC(UseSerialGC, CollectedHeap::Serial, serialArguments, "serial gc"))
74 SHENANDOAHGC_ONLY_ARG(IncludedGC(UseShenandoahGC, CollectedHeap::Shenandoah, shenandoahArguments, "shenandoah gc"))
75 ZGC_ONLY_ARG(IncludedGC(UseZGC, CollectedHeap::Z, zArguments, "z gc"))
76 };
77
78 #define FOR_EACH_INCLUDED_GC(var) \
79 for (const IncludedGC* var = &IncludedGCs[0]; var < &IncludedGCs[ARRAY_SIZE(IncludedGCs)]; var++)
80
81 #define FAIL_IF_SELECTED(option, enabled) \
82 if (option == enabled && FLAG_IS_CMDLINE(option)) { \
83 vm_exit_during_initialization(enabled ? \
84 "Option -XX:+" #option " not supported" : \
85 "Option -XX:-" #option " not supported"); \
86 }
87
88 GCArguments* GCConfig::_arguments = NULL;
89 bool GCConfig::_gc_selected_ergonomically = false;
90
91 void GCConfig::fail_if_non_included_gc_is_selected() {
92 NOT_EPSILONGC( FAIL_IF_SELECTED(UseEpsilonGC, true));
93 NOT_G1GC( FAIL_IF_SELECTED(UseG1GC, true));
94 NOT_PARALLELGC( FAIL_IF_SELECTED(UseParallelGC, true));
95 NOT_SERIALGC( FAIL_IF_SELECTED(UseSerialGC, true));
96 NOT_SHENANDOAHGC(FAIL_IF_SELECTED(UseShenandoahGC, true));
97 NOT_ZGC( FAIL_IF_SELECTED(UseZGC, true));
98 }
99
100 void GCConfig::select_gc_ergonomically() {
101 if (os::is_server_class_machine()) {
102 #if INCLUDE_G1GC
103 FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true);
104 #elif INCLUDE_PARALLELGC
105 FLAG_SET_ERGO_IF_DEFAULT(UseParallelGC, true);
106 #elif INCLUDE_SERIALGC
107 FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
108 #endif
109 } else {
110 #if INCLUDE_SERIALGC
111 FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
112 #endif
113 }
114 }
115
|