author | shade |
Thu, 18 Jan 2018 12:08:41 +0100 | |
branch | epsilon-gc-branch |
changeset 56022 | dd005db4ec5c |
parent 55974 | 06122633fead |
child 56028 | 267a6ce379ba |
permissions | -rw-r--r-- |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
1 |
/* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
4 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
8 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
13 |
* accompanied this code). |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
14 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
18 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
21 |
* questions. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
22 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
23 |
*/ |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
24 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
26 |
#include "gc/shared/gcArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
27 |
#include "gc/serial/serialArguments.hpp" |
48179 | 28 |
#include "logging/log.hpp" |
48012
90bb2706e6b4
8191562: Missing include in gcArguments.cpp breaks minimal JVM build
rkennke
parents:
47996
diff
changeset
|
29 |
#include "memory/allocation.inline.hpp" |
90bb2706e6b4
8191562: Missing include in gcArguments.cpp breaks minimal JVM build
rkennke
parents:
47996
diff
changeset
|
30 |
#include "runtime/arguments.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
31 |
#include "runtime/globals.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
32 |
#include "runtime/globals_extension.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
33 |
#include "runtime/java.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
34 |
#include "runtime/os.hpp" |
47912 | 35 |
#include "utilities/defaultStream.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
36 |
#include "utilities/macros.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
37 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
38 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
39 |
#include "gc/parallel/parallelArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
40 |
#include "gc/cms/cmsArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
41 |
#include "gc/g1/g1Arguments.hpp" |
55935 | 42 |
#include "gc/epsilon/epsilonArguments.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
43 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
44 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
45 |
GCArguments* GCArguments::_instance = NULL; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
46 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
47 |
GCArguments* GCArguments::arguments() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
48 |
assert(is_initialized(), "Heap factory not yet created"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
49 |
return _instance; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
50 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
51 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
52 |
bool GCArguments::is_initialized() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
53 |
return _instance != NULL; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
54 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
55 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
56 |
bool GCArguments::gc_selected() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
57 |
#if INCLUDE_ALL_GCS |
56022
dd005db4ec5c
Support -XX:+UseNoGC as the alias for -XX:+UseEpsilonGC
shade
parents:
55974
diff
changeset
|
58 |
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC || (UseEpsilonGC || UseNoGC); |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
59 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
60 |
return UseSerialGC; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
61 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
62 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
63 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
64 |
void GCArguments::select_gc() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
65 |
if (!gc_selected()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
66 |
select_gc_ergonomically(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
67 |
if (!gc_selected()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
68 |
vm_exit_during_initialization("Garbage collector not selected (default collector explicitly disabled)", NULL); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
69 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
70 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
71 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
72 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
73 |
void GCArguments::select_gc_ergonomically() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
74 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
75 |
if (os::is_server_class_machine()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
76 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
77 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
78 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
79 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
80 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
81 |
UNSUPPORTED_OPTION(UseG1GC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
82 |
UNSUPPORTED_OPTION(UseParallelGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
83 |
UNSUPPORTED_OPTION(UseParallelOldGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
84 |
UNSUPPORTED_OPTION(UseConcMarkSweepGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
85 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
86 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
87 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
88 |
|
48179 | 89 |
bool GCArguments::parse_verification_type(const char* type) { |
90 |
log_warning(gc, verify)("VerifyGCType is not supported by this collector."); |
|
91 |
// Return false to avoid multiple warnings. |
|
92 |
return false; |
|
93 |
} |
|
94 |
||
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
95 |
void GCArguments::initialize_flags() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
96 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
97 |
if (MinHeapFreeRatio == 100) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
98 |
// Keeping the heap 100% free is hard ;-) so limit it to 99%. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
99 |
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
100 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
101 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
102 |
// If class unloading is disabled, also disable concurrent class unloading. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
103 |
if (!ClassUnloading) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
104 |
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
105 |
FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
106 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
107 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
108 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
109 |
|
48179 | 110 |
void GCArguments::post_heap_initialize() { |
111 |
if (strlen(VerifyGCType) > 0) { |
|
112 |
const char delimiter[] = " ,\n"; |
|
113 |
size_t length = strlen(VerifyGCType); |
|
114 |
char* type_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal); |
|
115 |
strncpy(type_list, VerifyGCType, length + 1); |
|
116 |
char* token = strtok(type_list, delimiter); |
|
117 |
while (token != NULL) { |
|
118 |
bool success = parse_verification_type(token); |
|
119 |
if (!success) { |
|
120 |
break; |
|
121 |
} |
|
122 |
token = strtok(NULL, delimiter); |
|
123 |
} |
|
124 |
FREE_C_HEAP_ARRAY(char, type_list); |
|
125 |
} |
|
126 |
} |
|
127 |
||
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
128 |
jint GCArguments::initialize() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
129 |
assert(!is_initialized(), "GC arguments already initialized"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
130 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
131 |
select_gc(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
132 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
133 |
#if !INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
134 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
135 |
jio_fprintf(defaultStream::error_stream(), "UseParallelGC not supported in this VM.\n"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
136 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
137 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
138 |
jio_fprintf(defaultStream::error_stream(), "UseG1GC not supported in this VM.\n"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
139 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
140 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
141 |
jio_fprintf(defaultStream::error_stream(), "UseConcMarkSweepGC not supported in this VM.\n"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
142 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
143 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
144 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
145 |
_instance = new ParallelArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
146 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
147 |
_instance = new G1Arguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
148 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
149 |
_instance = new CMSArguments(); |
56022
dd005db4ec5c
Support -XX:+UseNoGC as the alias for -XX:+UseEpsilonGC
shade
parents:
55974
diff
changeset
|
150 |
} else if (UseEpsilonGC || UseNoGC) { |
55935 | 151 |
_instance = new EpsilonArguments(); |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
152 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
153 |
} else if (UseSerialGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
154 |
_instance = new SerialArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
155 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
156 |
ShouldNotReachHere(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
157 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
158 |
return JNI_OK; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
159 |
} |