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/heapRegion.hpp" 30 #include "gc/shared/gcArguments.inline.hpp" 31 #include "runtime/globals.hpp" 32 #include "runtime/globals_extension.hpp" 33 #include "runtime/vm_version.hpp" 34 35 size_t G1Arguments::conservative_max_heap_alignment() { 36 return HeapRegion::max_region_size(); 37 } 38 39 void G1Arguments::initialize_flags() { 40 GCArguments::initialize_flags(); 41 assert(UseG1GC, "Error"); 42 #if defined(COMPILER1) || INCLUDE_JVMCI 43 FastTLABRefill = false; 44 #endif 45 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads()); 46 if (ParallelGCThreads == 0) { 47 assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0."); 48 vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL); 49 } 50 51 #if INCLUDE_ALL_GCS 52 if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) { 53 FLAG_SET_ERGO(uint, G1ConcRefinementThreads, ParallelGCThreads); 54 } 55 #endif 56 57 // MarkStackSize will be set (if it hasn't been set by the user) 58 // when concurrent marking is initialized. 59 // Its value will be based upon the number of parallel marking threads. 60 // But we do set the maximum mark stack size here. 61 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) { 62 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE); 63 } 64 65 if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) { 66 // In G1, we want the default GC overhead goal to be higher than 67 // it is for PS, or the heap might be expanded too aggressively. 68 // We set it here to ~8%. 69 FLAG_SET_DEFAULT(GCTimeRatio, 12); 70 } 71 72 // Below, we might need to calculate the pause time interval based on 73 // the pause target. When we do so we are going to give G1 maximum 74 // flexibility and allow it to do pauses when it needs to. So, we'll 75 // arrange that the pause interval to be pause time target + 1 to 76 // ensure that a) the pause time target is maximized with respect to 77 // the pause interval and b) we maintain the invariant that pause 78 // time target < pause interval. If the user does not want this 79 // maximum flexibility, they will have to set the pause interval 80 // explicitly. 81 82 if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { 83 // The default pause time target in G1 is 200ms 84 FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); 85 } 86 87 // Then, if the interval parameter was not set, set it according to 88 // the pause time target (this will also deal with the case when the 89 // pause time target is the default value). 90 if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { 91 FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); 92 } 93 94 log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); 95 } 96 97 CollectedHeap* G1Arguments::create_heap() { 98 return create_heap_with_policy<G1CollectedHeap, G1CollectorPolicy>(); 99 }