author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49629 | b786280276dc |
child 49911 | 358be4680d12 |
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/g1/g1Arguments.hpp" |
47913 | 28 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
29 |
#include "gc/g1/g1CollectorPolicy.hpp" |
|
48179 | 30 |
#include "gc/g1/g1HeapVerifier.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
31 |
#include "gc/g1/heapRegion.hpp" |
47913 | 32 |
#include "gc/shared/gcArguments.inline.hpp" |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
33 |
#include "runtime/globals.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
34 |
#include "runtime/globals_extension.hpp" |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
35 |
#include "runtime/vm_version.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 |
size_t G1Arguments::conservative_max_heap_alignment() { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
38 |
return HeapRegion::max_region_size(); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
39 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
40 |
|
49602 | 41 |
void G1Arguments::initialize_verification_types() { |
42 |
if (strlen(VerifyGCType) > 0) { |
|
43 |
const char delimiter[] = " ,\n"; |
|
44 |
size_t length = strlen(VerifyGCType); |
|
45 |
char* type_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal); |
|
46 |
strncpy(type_list, VerifyGCType, length + 1); |
|
47 |
char* token = strtok(type_list, delimiter); |
|
48 |
while (token != NULL) { |
|
49 |
parse_verification_type(token); |
|
50 |
token = strtok(NULL, delimiter); |
|
51 |
} |
|
52 |
FREE_C_HEAP_ARRAY(char, type_list); |
|
53 |
} |
|
54 |
} |
|
55 |
||
56 |
void G1Arguments::parse_verification_type(const char* type) { |
|
57 |
if (strcmp(type, "young-only") == 0) { |
|
58 |
G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyYoungOnly); |
|
59 |
} else if (strcmp(type, "initial-mark") == 0) { |
|
60 |
G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyInitialMark); |
|
61 |
} else if (strcmp(type, "mixed") == 0) { |
|
62 |
G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyMixed); |
|
63 |
} else if (strcmp(type, "remark") == 0) { |
|
64 |
G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyRemark); |
|
65 |
} else if (strcmp(type, "cleanup") == 0) { |
|
66 |
G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyCleanup); |
|
67 |
} else if (strcmp(type, "full") == 0) { |
|
68 |
G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyFull); |
|
69 |
} else { |
|
70 |
log_warning(gc, verify)("VerifyGCType: '%s' is unknown. Available types are: " |
|
71 |
"young-only, initial-mark, mixed, remark, cleanup and full", type); |
|
72 |
} |
|
73 |
} |
|
74 |
||
49629
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
49602
diff
changeset
|
75 |
void G1Arguments::initialize() { |
b786280276dc
8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents:
49602
diff
changeset
|
76 |
GCArguments::initialize(); |
47901
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
77 |
assert(UseG1GC, "Error"); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
78 |
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads()); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
79 |
if (ParallelGCThreads == 0) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
80 |
assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0."); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
81 |
vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
82 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
83 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
84 |
#if INCLUDE_ALL_GCS |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
85 |
if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
86 |
FLAG_SET_ERGO(uint, G1ConcRefinementThreads, ParallelGCThreads); |
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 |
#endif |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
89 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
90 |
// MarkStackSize will be set (if it hasn't been set by the user) |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
91 |
// when concurrent marking is initialized. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
92 |
// Its value will be based upon the number of parallel marking threads. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
93 |
// But we do set the maximum mark stack size here. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
94 |
if (FLAG_IS_DEFAULT(MarkStackSizeMax)) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
95 |
FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
96 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
97 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
98 |
if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
99 |
// In G1, we want the default GC overhead goal to be higher than |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
100 |
// it is for PS, or the heap might be expanded too aggressively. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
101 |
// We set it here to ~8%. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
102 |
FLAG_SET_DEFAULT(GCTimeRatio, 12); |
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 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
105 |
// Below, we might need to calculate the pause time interval based on |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
106 |
// the pause target. When we do so we are going to give G1 maximum |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
107 |
// flexibility and allow it to do pauses when it needs to. So, we'll |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
108 |
// arrange that the pause interval to be pause time target + 1 to |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
109 |
// ensure that a) the pause time target is maximized with respect to |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
110 |
// the pause interval and b) we maintain the invariant that pause |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
111 |
// time target < pause interval. If the user does not want this |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
112 |
// maximum flexibility, they will have to set the pause interval |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
113 |
// explicitly. |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
114 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
115 |
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
116 |
// The default pause time target in G1 is 200ms |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
117 |
FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
118 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
119 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
120 |
// Then, if the interval parameter was not set, set it according to |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
121 |
// the pause time target (this will also deal with the case when the |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
122 |
// pause time target is the default value). |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
123 |
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
124 |
FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
125 |
} |
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
126 |
|
4c42aa431f40
8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff
changeset
|
127 |
log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); |
48145 | 128 |
|
129 |
#ifdef COMPILER2 |
|
130 |
// Enable loop strip mining to offer better pause time guarantees |
|
131 |
if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) { |
|
132 |
FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true); |
|
48316
4d28288c9f9e
8192908: -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
roland
parents:
48179
diff
changeset
|
133 |
if (FLAG_IS_DEFAULT(LoopStripMiningIter)) { |
4d28288c9f9e
8192908: -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
roland
parents:
48179
diff
changeset
|
134 |
FLAG_SET_DEFAULT(LoopStripMiningIter, 1000); |
4d28288c9f9e
8192908: -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
roland
parents:
48179
diff
changeset
|
135 |
} |
48145 | 136 |
} |
137 |
#endif |
|
47913 | 138 |
|
49602 | 139 |
initialize_verification_types(); |
48179 | 140 |
} |
141 |
||
47913 | 142 |
CollectedHeap* G1Arguments::create_heap() { |
143 |
return create_heap_with_policy<G1CollectedHeap, G1CollectorPolicy>(); |
|
144 |
} |