21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/serial/serialArguments.hpp" |
|
27 #include "gc/shared/gcConfig.hpp" |
26 #include "gc/shared/gcConfig.hpp" |
|
27 #include "runtime/globals_extension.hpp" |
28 #include "runtime/java.hpp" |
28 #include "runtime/java.hpp" |
29 #include "runtime/os.hpp" |
29 #include "runtime/os.hpp" |
30 #include "utilities/macros.hpp" |
30 #include "utilities/macros.hpp" |
31 #if INCLUDE_ALL_GCS |
31 #if INCLUDE_CMSGC |
|
32 #include "gc/cms/cmsArguments.hpp" |
|
33 #endif |
|
34 #if INCLUDE_G1GC |
|
35 #include "gc/g1/g1Arguments.hpp" |
|
36 #endif |
|
37 #if INCLUDE_PARALLELGC |
32 #include "gc/parallel/parallelArguments.hpp" |
38 #include "gc/parallel/parallelArguments.hpp" |
33 #include "gc/cms/cmsArguments.hpp" |
39 #endif |
34 #include "gc/g1/g1Arguments.hpp" |
40 #if INCLUDE_SERIALGC |
35 #endif // INCLUDE_ALL_GCS |
41 #include "gc/serial/serialArguments.hpp" |
|
42 #endif |
36 |
43 |
37 struct SupportedGC { |
44 struct SupportedGC { |
38 bool& _flag; |
45 bool& _flag; |
39 CollectedHeap::Name _name; |
46 CollectedHeap::Name _name; |
40 GCArguments& _arguments; |
47 GCArguments& _arguments; |
42 |
49 |
43 SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) : |
50 SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) : |
44 _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {} |
51 _flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {} |
45 }; |
52 }; |
46 |
53 |
47 static SerialArguments serialArguments; |
54 CMSGC_ONLY(static CMSArguments cmsArguments;) |
48 #if INCLUDE_ALL_GCS |
55 G1GC_ONLY(static G1Arguments g1Arguments;) |
49 static ParallelArguments parallelArguments; |
56 PARALLELGC_ONLY(static ParallelArguments parallelArguments;) |
50 static CMSArguments cmsArguments; |
57 SERIALGC_ONLY(static SerialArguments serialArguments;) |
51 static G1Arguments g1Arguments; |
|
52 #endif // INCLUDE_ALL_GCS |
|
53 |
58 |
54 // Table of supported GCs, for translating between command |
59 // Table of supported GCs, for translating between command |
55 // line flag, CollectedHeap::Name and GCArguments instance. |
60 // line flag, CollectedHeap::Name and GCArguments instance. |
56 static const SupportedGC SupportedGCs[] = { |
61 static const SupportedGC SupportedGCs[] = { |
57 SupportedGC(UseSerialGC, CollectedHeap::Serial, serialArguments, "serial gc"), |
62 CMSGC_ONLY_ARG(SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS, cmsArguments, "concurrent mark sweep gc")) |
58 #if INCLUDE_ALL_GCS |
63 G1GC_ONLY_ARG(SupportedGC(UseG1GC, CollectedHeap::G1, g1Arguments, "g1 gc")) |
59 SupportedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments, "parallel gc"), |
64 PARALLELGC_ONLY_ARG(SupportedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments, "parallel gc")) |
60 SupportedGC(UseParallelOldGC, CollectedHeap::Parallel, parallelArguments, "parallel gc"), |
65 PARALLELGC_ONLY_ARG(SupportedGC(UseParallelOldGC, CollectedHeap::Parallel, parallelArguments, "parallel gc")) |
61 SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS, cmsArguments, "concurrent mark sweep gc"), |
66 SERIALGC_ONLY_ARG(SupportedGC(UseSerialGC, CollectedHeap::Serial, serialArguments, "serial gc")) |
62 SupportedGC(UseG1GC, CollectedHeap::G1, g1Arguments, "g1 gc"), |
|
63 #endif // INCLUDE_ALL_GCS |
|
64 }; |
67 }; |
65 |
68 |
66 #define FOR_EACH_SUPPORTED_GC(var) \ |
69 #define FOR_EACH_SUPPORTED_GC(var) \ |
67 for (const SupportedGC* var = &SupportedGCs[0]; var < &SupportedGCs[ARRAY_SIZE(SupportedGCs)]; var++) |
70 for (const SupportedGC* var = &SupportedGCs[0]; var < &SupportedGCs[ARRAY_SIZE(SupportedGCs)]; var++) |
68 |
71 |
69 GCArguments* GCConfig::_arguments = NULL; |
72 GCArguments* GCConfig::_arguments = NULL; |
70 bool GCConfig::_gc_selected_ergonomically = false; |
73 bool GCConfig::_gc_selected_ergonomically = false; |
71 |
74 |
72 void GCConfig::select_gc_ergonomically() { |
75 void GCConfig::select_gc_ergonomically() { |
73 #if INCLUDE_ALL_GCS |
|
74 if (os::is_server_class_machine()) { |
76 if (os::is_server_class_machine()) { |
|
77 #if INCLUDE_G1GC |
75 FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); |
78 FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); |
|
79 #elif INCLUDE_PARALLELGC |
|
80 FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true); |
|
81 #elif INCLUDE_SERIALGC |
|
82 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
|
83 #endif |
76 } else { |
84 } else { |
|
85 #if INCLUDE_SERIALGC |
77 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
86 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
78 } |
87 #endif |
79 #else |
88 } |
80 UNSUPPORTED_OPTION(UseG1GC); |
89 |
81 UNSUPPORTED_OPTION(UseParallelGC); |
90 NOT_CMSGC( UNSUPPORTED_OPTION(UseConcMarkSweepGC)); |
82 UNSUPPORTED_OPTION(UseParallelOldGC); |
91 NOT_G1GC( UNSUPPORTED_OPTION(UseG1GC);) |
83 UNSUPPORTED_OPTION(UseConcMarkSweepGC); |
92 NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelGC);) |
84 FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
93 NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelOldGC)); |
85 #endif // INCLUDE_ALL_GCS |
94 NOT_SERIALGC( UNSUPPORTED_OPTION(UseSerialGC);) |
86 } |
95 } |
87 |
96 |
88 bool GCConfig::is_no_gc_selected() { |
97 bool GCConfig::is_no_gc_selected() { |
89 FOR_EACH_SUPPORTED_GC(gc) { |
98 FOR_EACH_SUPPORTED_GC(gc) { |
90 if (gc->_flag) { |
99 if (gc->_flag) { |
126 |
135 |
127 // Succeeded to select GC ergonomically |
136 // Succeeded to select GC ergonomically |
128 _gc_selected_ergonomically = true; |
137 _gc_selected_ergonomically = true; |
129 } |
138 } |
130 |
139 |
131 if (is_exactly_one_gc_selected()) { |
140 if (!is_exactly_one_gc_selected()) { |
132 // Exacly one GC selected |
141 // More than one GC selected |
133 FOR_EACH_SUPPORTED_GC(gc) { |
142 vm_exit_during_initialization("Multiple garbage collectors selected", NULL); |
134 if (gc->_flag) { |
143 } |
135 return &gc->_arguments; |
144 |
136 } |
145 #if INCLUDE_PARALLELGC && !INCLUDE_SERIALGC |
137 } |
146 if (FLAG_IS_CMDLINE(UseParallelOldGC) && !UseParallelOldGC) { |
138 } |
147 vm_exit_during_initialization("This JVM build only supports UseParallelOldGC as the full GC"); |
139 |
148 } |
140 // More than one GC selected |
149 #endif |
141 vm_exit_during_initialization("Multiple garbage collectors selected", NULL); |
150 |
|
151 // Exactly one GC selected |
|
152 FOR_EACH_SUPPORTED_GC(gc) { |
|
153 if (gc->_flag) { |
|
154 return &gc->_arguments; |
|
155 } |
|
156 } |
|
157 |
|
158 fatal("Should have found the selected GC"); |
142 |
159 |
143 return NULL; |
160 return NULL; |
144 } |
161 } |
145 |
162 |
146 void GCConfig::initialize() { |
163 void GCConfig::initialize() { |