author | rkennke |
Tue, 21 Nov 2017 12:48:17 +0100 | |
changeset 48012 | 90bb2706e6b4 |
parent 47996 | 0fd0f31ade3e |
child 48179 | 34fe70d22e9c |
child 55935 | f4e069848424 |
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" |
48012
90bb2706e6b4
8191562: Missing include in gcArguments.cpp breaks minimal JVM build
rkennke
parents:
47996
diff
changeset
|
28 |
#include "memory/allocation.inline.hpp" |
90bb2706e6b4
8191562: Missing include in gcArguments.cpp breaks minimal JVM build
rkennke
parents:
47996
diff
changeset
|
29 |
#include "runtime/arguments.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
30 |
#include "runtime/globals.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
31 |
#include "runtime/globals_extension.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
32 |
#include "runtime/java.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
33 |
#include "runtime/os.hpp" |
47912 | 34 |
#include "utilities/defaultStream.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
35 |
#include "utilities/macros.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
36 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
37 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
38 |
#include "gc/parallel/parallelArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
39 |
#include "gc/cms/cmsArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
40 |
#include "gc/g1/g1Arguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
41 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
42 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
43 |
GCArguments* GCArguments::_instance = NULL; |
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::arguments() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
46 |
assert(is_initialized(), "Heap factory not yet created"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
47 |
return _instance; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
48 |
} |
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 |
bool GCArguments::is_initialized() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
51 |
return _instance != NULL; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
52 |
} |
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 |
bool GCArguments::gc_selected() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
55 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
56 |
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
57 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
58 |
return UseSerialGC; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
59 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
60 |
} |
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 |
void GCArguments::select_gc() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
63 |
if (!gc_selected()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
64 |
select_gc_ergonomically(); |
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 |
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
|
67 |
} |
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 |
void GCArguments::select_gc_ergonomically() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
72 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
73 |
if (os::is_server_class_machine()) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
74 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
75 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
76 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
77 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
78 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
79 |
UNSUPPORTED_OPTION(UseG1GC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
80 |
UNSUPPORTED_OPTION(UseParallelGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
81 |
UNSUPPORTED_OPTION(UseParallelOldGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
82 |
UNSUPPORTED_OPTION(UseConcMarkSweepGC); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
83 |
FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
84 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
85 |
} |
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 |
void GCArguments::initialize_flags() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
88 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
89 |
if (MinHeapFreeRatio == 100) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
90 |
// 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
|
91 |
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
92 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
93 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
94 |
// If class unloading is disabled, also disable concurrent class unloading. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
95 |
if (!ClassUnloading) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
96 |
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
97 |
FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
98 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
99 |
#endif // INCLUDE_ALL_GCS |
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 |
jint GCArguments::initialize() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
103 |
assert(!is_initialized(), "GC arguments already initialized"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
104 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
105 |
select_gc(); |
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 |
#if !INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
108 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
109 |
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
|
110 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
111 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
112 |
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
|
113 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
114 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
115 |
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
|
116 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
117 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
118 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
119 |
_instance = new ParallelArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
120 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
121 |
_instance = new G1Arguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
122 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
123 |
_instance = new CMSArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
124 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
125 |
} else if (UseSerialGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
126 |
_instance = new SerialArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
127 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
128 |
ShouldNotReachHere(); |
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 |
return JNI_OK; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
131 |
} |