author | stefank |
Thu, 22 Feb 2018 18:36:07 +0100 | |
changeset 49047 | 8f004146e407 |
parent 48179 | 34fe70d22e9c |
child 49602 | db050c11c3b5 |
child 55974 | 06122633fead |
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" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
42 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
43 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
44 |
GCArguments* GCArguments::_instance = NULL; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
45 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
46 |
GCArguments* GCArguments::arguments() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
47 |
assert(is_initialized(), "Heap factory not yet created"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
48 |
return _instance; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
49 |
} |
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 |
bool GCArguments::is_initialized() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
52 |
return _instance != NULL; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
53 |
} |
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 |
bool GCArguments::gc_selected() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
56 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
57 |
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
58 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
59 |
return UseSerialGC; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
60 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
61 |
} |
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 |
void GCArguments::select_gc() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
64 |
if (!gc_selected()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
65 |
select_gc_ergonomically(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
66 |
if (!gc_selected()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
67 |
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
|
68 |
} |
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 |
void GCArguments::select_gc_ergonomically() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
73 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
74 |
if (os::is_server_class_machine()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
75 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
76 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
77 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
78 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
79 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
80 |
UNSUPPORTED_OPTION(UseG1GC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
81 |
UNSUPPORTED_OPTION(UseParallelGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
82 |
UNSUPPORTED_OPTION(UseParallelOldGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
83 |
UNSUPPORTED_OPTION(UseConcMarkSweepGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
84 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
85 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
86 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
87 |
|
48179 | 88 |
bool GCArguments::parse_verification_type(const char* type) { |
89 |
log_warning(gc, verify)("VerifyGCType is not supported by this collector."); |
|
90 |
// Return false to avoid multiple warnings. |
|
91 |
return false; |
|
92 |
} |
|
93 |
||
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
94 |
void GCArguments::initialize_flags() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
95 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
96 |
if (MinHeapFreeRatio == 100) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
97 |
// 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
|
98 |
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
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 |
// If class unloading is disabled, also disable concurrent class unloading. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
102 |
if (!ClassUnloading) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
103 |
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
104 |
FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
105 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
106 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
107 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
108 |
|
48179 | 109 |
void GCArguments::post_heap_initialize() { |
110 |
if (strlen(VerifyGCType) > 0) { |
|
111 |
const char delimiter[] = " ,\n"; |
|
112 |
size_t length = strlen(VerifyGCType); |
|
113 |
char* type_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal); |
|
114 |
strncpy(type_list, VerifyGCType, length + 1); |
|
115 |
char* token = strtok(type_list, delimiter); |
|
116 |
while (token != NULL) { |
|
117 |
bool success = parse_verification_type(token); |
|
118 |
if (!success) { |
|
119 |
break; |
|
120 |
} |
|
121 |
token = strtok(NULL, delimiter); |
|
122 |
} |
|
123 |
FREE_C_HEAP_ARRAY(char, type_list); |
|
124 |
} |
|
125 |
} |
|
126 |
||
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
127 |
jint GCArguments::initialize() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
128 |
assert(!is_initialized(), "GC arguments already initialized"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
129 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
130 |
select_gc(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
131 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
132 |
#if !INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
133 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
134 |
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
|
135 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
136 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
137 |
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
|
138 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
139 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
140 |
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
|
141 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
142 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
143 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
144 |
_instance = new ParallelArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
145 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
146 |
_instance = new G1Arguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
147 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
148 |
_instance = new CMSArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
149 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
150 |
} else if (UseSerialGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
151 |
_instance = new SerialArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
152 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
153 |
ShouldNotReachHere(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
154 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
155 |
return JNI_OK; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
156 |
} |