1 /* 2 * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/g1/g1Arguments.hpp" 27 #include "gc/g1/g1CollectedHeap.inline.hpp" 28 #include "gc/g1/g1CollectorPolicy.hpp" 29 #include "gc/g1/g1HeapVerifier.hpp" 30 #include "gc/g1/heapRegion.hpp" 31 #include "gc/shared/gcArguments.inline.hpp" 32 #include "runtime/globals.hpp" 33 #include "runtime/globals_extension.hpp" 34 #include "runtime/vm_version.hpp" 35 36 size_t G1Arguments::conservative_max_heap_alignment() { 37 return HeapRegion::max_region_size(); 38 } 39 40 void G1Arguments::initialize_flags() { 41 GCArguments::initialize_flags(); 42 assert(UseG1GC, "Error"); 43 #if defined(COMPILER1) || INCLUDE_JVMCI 44 FastTLABRefill = false; 45 #endif 46 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads()); 47 if (ParallelGCThreads == 0) { 48 assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0."); 49 vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL); 50 } 51 52 #if INCLUDE_ALL_GCS 53 if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) { 54 FLAG_SET_ERGO(uint, G1ConcRefinementThreads, ParallelGCThreads); 55 } 56 #endif 57 58 // MarkStackSize will be set (if it hasn't been set by the user) 59 // when concurrent marking is initialized. 60 // Its value will be based upon the number of parallel marking threads. 61 // But we do set the maximum mark stack size here. 62 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) { 63 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE); 64 } 65 66 if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) { 67 // In G1, we want the default GC overhead goal to be higher than 68 // it is for PS, or the heap might be expanded too aggressively. 69 // We set it here to ~8%. 70 FLAG_SET_DEFAULT(GCTimeRatio, 12); 71 } 72 73 // Below, we might need to calculate the pause time interval based on 74 // the pause target. When we do so we are going to give G1 maximum 75 // flexibility and allow it to do pauses when it needs to. So, we'll 76 // arrange that the pause interval to be pause time target + 1 to 77 // ensure that a) the pause time target is maximized with respect to 78 // the pause interval and b) we maintain the invariant that pause 79 // time target < pause interval. If the user does not want this 80 // maximum flexibility, they will have to set the pause interval 81 // explicitly. 82 83 if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { 84 // The default pause time target in G1 is 200ms 85 FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); 86 } 87 88 // Then, if the interval parameter was not set, set it according to 89 // the pause time target (this will also deal with the case when the 90 // pause time target is the default value). 91 if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { 92 FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); 93 } 94 95 log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); 96 } 97 98 void G1Arguments::parse_verification_type(const char* type) { 99 G1CollectedHeap::heap()->verifier()->parse_verification_type(type); 100 } 101 102 CollectedHeap* G1Arguments::create_heap() { 103 return create_heap_with_policy<G1CollectedHeap, G1CollectorPolicy>(); 104 }