author | pliden |
Tue, 12 Jun 2018 17:40:28 +0200 | |
changeset 50525 | 767cdb97f103 |
parent 50523 | 7b7c75d87f9b |
child 50629 | 645a5962201d |
permissions | -rw-r--r-- |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
1 |
/* |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
4 |
* |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
8 |
* |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
13 |
* accompanied this code). |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
14 |
* |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
18 |
* |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
21 |
* questions. |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
22 |
* |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
23 |
*/ |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
24 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
26 |
#include "gc/shared/gcConfig.hpp" |
49982 | 27 |
#include "runtime/globals_extension.hpp" |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
28 |
#include "runtime/java.hpp" |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
29 |
#include "runtime/os.hpp" |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
30 |
#include "utilities/macros.hpp" |
49982 | 31 |
#if INCLUDE_CMSGC |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
32 |
#include "gc/cms/cmsArguments.hpp" |
49982 | 33 |
#endif |
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
49982
diff
changeset
|
34 |
#if INCLUDE_EPSILONGC |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
49982
diff
changeset
|
35 |
#include "gc/epsilon/epsilonArguments.hpp" |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
49982
diff
changeset
|
36 |
#endif |
49982 | 37 |
#if INCLUDE_G1GC |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
38 |
#include "gc/g1/g1Arguments.hpp" |
49982 | 39 |
#endif |
40 |
#if INCLUDE_PARALLELGC |
|
41 |
#include "gc/parallel/parallelArguments.hpp" |
|
42 |
#endif |
|
43 |
#if INCLUDE_SERIALGC |
|
44 |
#include "gc/serial/serialArguments.hpp" |
|
45 |
#endif |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
46 |
#if INCLUDE_ZGC |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
47 |
#include "gc/z/zArguments.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
48 |
#endif |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
49 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
50 |
struct SupportedGC { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
51 |
bool& _flag; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
52 |
CollectedHeap::Name _name; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
53 |
GCArguments& _arguments; |
49922
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
54 |
const char* _hs_err_name; |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
55 |
|
49922
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
56 |
SupportedGC(bool& flag, CollectedHeap::Name name, GCArguments& arguments, const char* hs_err_name) : |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
57 |
_flag(flag), _name(name), _arguments(arguments), _hs_err_name(hs_err_name) {} |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
58 |
}; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
59 |
|
49982 | 60 |
CMSGC_ONLY(static CMSArguments cmsArguments;) |
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
49982
diff
changeset
|
61 |
EPSILONGC_ONLY(static EpsilonArguments epsilonArguments;) |
49982 | 62 |
G1GC_ONLY(static G1Arguments g1Arguments;) |
63 |
PARALLELGC_ONLY(static ParallelArguments parallelArguments;) |
|
64 |
SERIALGC_ONLY(static SerialArguments serialArguments;) |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
65 |
ZGC_ONLY(static ZArguments zArguments;) |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
66 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
67 |
// Table of supported GCs, for translating between command |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
68 |
// line flag, CollectedHeap::Name and GCArguments instance. |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
69 |
static const SupportedGC SupportedGCs[] = { |
49982 | 70 |
CMSGC_ONLY_ARG(SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS, cmsArguments, "concurrent mark sweep gc")) |
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
49982
diff
changeset
|
71 |
EPSILONGC_ONLY_ARG(SupportedGC(UseEpsilonGC, CollectedHeap::Epsilon, epsilonArguments, "epsilon gc")) |
49982 | 72 |
G1GC_ONLY_ARG(SupportedGC(UseG1GC, CollectedHeap::G1, g1Arguments, "g1 gc")) |
73 |
PARALLELGC_ONLY_ARG(SupportedGC(UseParallelGC, CollectedHeap::Parallel, parallelArguments, "parallel gc")) |
|
74 |
PARALLELGC_ONLY_ARG(SupportedGC(UseParallelOldGC, CollectedHeap::Parallel, parallelArguments, "parallel gc")) |
|
75 |
SERIALGC_ONLY_ARG(SupportedGC(UseSerialGC, CollectedHeap::Serial, serialArguments, "serial gc")) |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
76 |
ZGC_ONLY_ARG(SupportedGC(UseZGC, CollectedHeap::Z, zArguments, "z gc")) |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
77 |
}; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
78 |
|
49923 | 79 |
#define FOR_EACH_SUPPORTED_GC(var) \ |
80 |
for (const SupportedGC* var = &SupportedGCs[0]; var < &SupportedGCs[ARRAY_SIZE(SupportedGCs)]; var++) |
|
81 |
||
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
82 |
GCArguments* GCConfig::_arguments = NULL; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
83 |
bool GCConfig::_gc_selected_ergonomically = false; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
84 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
85 |
void GCConfig::select_gc_ergonomically() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
86 |
if (os::is_server_class_machine()) { |
49982 | 87 |
#if INCLUDE_G1GC |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
88 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); |
49982 | 89 |
#elif INCLUDE_PARALLELGC |
90 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true); |
|
91 |
#elif INCLUDE_SERIALGC |
|
92 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
|
93 |
#endif |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
94 |
} else { |
49982 | 95 |
#if INCLUDE_SERIALGC |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
96 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
49982 | 97 |
#endif |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
98 |
} |
49982 | 99 |
|
100 |
NOT_CMSGC( UNSUPPORTED_OPTION(UseConcMarkSweepGC)); |
|
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
49982
diff
changeset
|
101 |
NOT_EPSILONGC( UNSUPPORTED_OPTION(UseEpsilonGC);) |
49982 | 102 |
NOT_G1GC( UNSUPPORTED_OPTION(UseG1GC);) |
103 |
NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelGC);) |
|
104 |
NOT_PARALLELGC(UNSUPPORTED_OPTION(UseParallelOldGC)); |
|
105 |
NOT_SERIALGC( UNSUPPORTED_OPTION(UseSerialGC);) |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
50523
diff
changeset
|
106 |
NOT_ZGC( UNSUPPORTED_OPTION(UseZGC);) |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
107 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
108 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
109 |
bool GCConfig::is_no_gc_selected() { |
49923 | 110 |
FOR_EACH_SUPPORTED_GC(gc) { |
111 |
if (gc->_flag) { |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
112 |
return false; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
113 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
114 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
115 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
116 |
return true; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
117 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
118 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
119 |
bool GCConfig::is_exactly_one_gc_selected() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
120 |
CollectedHeap::Name selected = CollectedHeap::None; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
121 |
|
49923 | 122 |
FOR_EACH_SUPPORTED_GC(gc) { |
123 |
if (gc->_flag) { |
|
124 |
if (gc->_name == selected || selected == CollectedHeap::None) { |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
125 |
// Selected |
49923 | 126 |
selected = gc->_name; |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
127 |
} else { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
128 |
// More than one selected |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
129 |
return false; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
130 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
131 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
132 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
133 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
134 |
return selected != CollectedHeap::None; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
135 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
136 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
137 |
GCArguments* GCConfig::select_gc() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
138 |
if (is_no_gc_selected()) { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
139 |
// Try select GC ergonomically |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
140 |
select_gc_ergonomically(); |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
141 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
142 |
if (is_no_gc_selected()) { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
143 |
// Failed to select GC ergonomically |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
144 |
vm_exit_during_initialization("Garbage collector not selected " |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
145 |
"(default collector explicitly disabled)", NULL); |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
146 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
147 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
148 |
// Succeeded to select GC ergonomically |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
149 |
_gc_selected_ergonomically = true; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
150 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
151 |
|
49982 | 152 |
if (!is_exactly_one_gc_selected()) { |
153 |
// More than one GC selected |
|
154 |
vm_exit_during_initialization("Multiple garbage collectors selected", NULL); |
|
155 |
} |
|
156 |
||
157 |
#if INCLUDE_PARALLELGC && !INCLUDE_SERIALGC |
|
158 |
if (FLAG_IS_CMDLINE(UseParallelOldGC) && !UseParallelOldGC) { |
|
159 |
vm_exit_during_initialization("This JVM build only supports UseParallelOldGC as the full GC"); |
|
160 |
} |
|
161 |
#endif |
|
162 |
||
163 |
// Exactly one GC selected |
|
164 |
FOR_EACH_SUPPORTED_GC(gc) { |
|
165 |
if (gc->_flag) { |
|
166 |
return &gc->_arguments; |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
167 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
168 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
169 |
|
49982 | 170 |
fatal("Should have found the selected GC"); |
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
171 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
172 |
return NULL; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
173 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
174 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
175 |
void GCConfig::initialize() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
176 |
assert(_arguments == NULL, "Already initialized"); |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
177 |
_arguments = select_gc(); |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
178 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
179 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
180 |
bool GCConfig::is_gc_supported(CollectedHeap::Name name) { |
49923 | 181 |
FOR_EACH_SUPPORTED_GC(gc) { |
182 |
if (gc->_name == name) { |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
183 |
// Supported |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
184 |
return true; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
185 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
186 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
187 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
188 |
// Not supported |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
189 |
return false; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
190 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
191 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
192 |
bool GCConfig::is_gc_selected(CollectedHeap::Name name) { |
49923 | 193 |
FOR_EACH_SUPPORTED_GC(gc) { |
194 |
if (gc->_name == name && gc->_flag) { |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
195 |
// Selected |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
196 |
return true; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
197 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
198 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
199 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
200 |
// Not selected |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
201 |
return false; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
202 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
203 |
|
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
204 |
bool GCConfig::is_gc_selected_ergonomically() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
205 |
return _gc_selected_ergonomically; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
206 |
} |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
207 |
|
49922
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
208 |
const char* GCConfig::hs_err_name() { |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
209 |
if (is_exactly_one_gc_selected()) { |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
210 |
// Exacly one GC selected |
49923 | 211 |
FOR_EACH_SUPPORTED_GC(gc) { |
212 |
if (gc->_flag) { |
|
213 |
return gc->_hs_err_name; |
|
49922
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
214 |
} |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
215 |
} |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
216 |
} |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
217 |
|
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
218 |
// Zero or more than one GC selected |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
219 |
return "unknown gc"; |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
220 |
} |
3a64eea72624
8202364: Add GCConfig::hs_err_name() to avoid GC-specific code in error reporting
pliden
parents:
49629
diff
changeset
|
221 |
|
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
222 |
GCArguments* GCConfig::arguments() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
223 |
assert(_arguments != NULL, "Not initialized"); |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
224 |
return _arguments; |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
diff
changeset
|
225 |
} |