author | pliden |
Mon, 26 Mar 2018 12:44:39 +0200 | |
changeset 49602 | db050c11c3b5 |
parent 48179 | 34fe70d22e9c |
child 49629 | b786280276dc |
permissions | -rw-r--r-- |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
1 |
/* |
49602 | 2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
3 |
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
4 |
* 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
|
5 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
6 |
* 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
|
7 |
* 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
|
8 |
* published by the Free Software Foundation. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
9 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
10 |
* 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
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
12 |
* 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
|
13 |
* 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
|
14 |
* accompanied this code). |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
15 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
16 |
* 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
|
17 |
* 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
|
18 |
* 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
|
19 |
* |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
20 |
* 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
|
21 |
* 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
|
22 |
* questions. |
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 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
26 |
#include "precompiled.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
27 |
#include "gc/shared/gcArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
28 |
#include "gc/serial/serialArguments.hpp" |
48179 | 29 |
#include "logging/log.hpp" |
48012
90bb2706e6b4
8191562: Missing include in gcArguments.cpp breaks minimal JVM build
rkennke
parents:
47996
diff
changeset
|
30 |
#include "memory/allocation.inline.hpp" |
90bb2706e6b4
8191562: Missing include in gcArguments.cpp breaks minimal JVM build
rkennke
parents:
47996
diff
changeset
|
31 |
#include "runtime/arguments.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
32 |
#include "runtime/globals.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
33 |
#include "runtime/globals_extension.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
34 |
#include "runtime/java.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
35 |
#include "runtime/os.hpp" |
47912 | 36 |
#include "utilities/defaultStream.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
37 |
#include "utilities/macros.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
38 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
39 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
40 |
#include "gc/parallel/parallelArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
41 |
#include "gc/cms/cmsArguments.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
42 |
#include "gc/g1/g1Arguments.hpp" |
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 |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
58 |
return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC; |
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 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
89 |
void GCArguments::initialize_flags() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
90 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
91 |
if (MinHeapFreeRatio == 100) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
92 |
// 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
|
93 |
FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
94 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
95 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
96 |
// If class unloading is disabled, also disable concurrent class unloading. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
97 |
if (!ClassUnloading) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
98 |
FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
99 |
FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); |
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 |
#endif // INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
102 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
103 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
104 |
jint GCArguments::initialize() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
105 |
assert(!is_initialized(), "GC arguments already initialized"); |
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 |
select_gc(); |
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 |
#if !INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
110 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
111 |
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
|
112 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
113 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
114 |
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
|
115 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
116 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
117 |
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
|
118 |
return JNI_ERR; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
119 |
#else |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
120 |
if (UseParallelGC || UseParallelOldGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
121 |
_instance = new ParallelArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
122 |
} else if (UseG1GC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
123 |
_instance = new G1Arguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
124 |
} else if (UseConcMarkSweepGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
125 |
_instance = new CMSArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
126 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
127 |
} else if (UseSerialGC) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
128 |
_instance = new SerialArguments(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
129 |
} else { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
130 |
ShouldNotReachHere(); |
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 |
return JNI_OK; |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
133 |
} |