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/parallel/parallelArguments.hpp" 27 #include "gc/parallel/parallelScavengeHeap.hpp" 28 #include "gc/shared/adaptiveSizePolicy.hpp" 29 #include "gc/shared/collectorPolicy.hpp" 30 #include "gc/shared/gcArguments.inline.hpp" 31 #include "runtime/globals.hpp" 32 #include "runtime/globals_extension.hpp" 33 #include "runtime/java.hpp" 34 #include "runtime/vm_version.hpp" 35 #include "utilities/defaultStream.hpp" 36 37 size_t ParallelArguments::conservative_max_heap_alignment() { 38 return CollectorPolicy::compute_heap_alignment(); 39 } 40 41 void ParallelArguments::initialize() { 42 GCArguments::initialize(); 43 assert(UseParallelGC || UseParallelOldGC, "Error"); 44 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file). 45 if (FLAG_IS_DEFAULT(UseParallelOldGC)) { 46 FLAG_SET_DEFAULT(UseParallelOldGC, true); 47 } 48 FLAG_SET_DEFAULT(UseParallelGC, true); 49 50 // If no heap maximum was requested explicitly, use some reasonable fraction 51 // of the physical memory, up to a maximum of 1GB. 52 FLAG_SET_DEFAULT(ParallelGCThreads, 53 Abstract_VM_Version::parallel_worker_threads()); 54 if (ParallelGCThreads == 0) { 55 jio_fprintf(defaultStream::error_stream(), 56 "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n"); 57 vm_exit(1); 58 } 59 60 if (UseAdaptiveSizePolicy) { 61 // We don't want to limit adaptive heap sizing's freedom to adjust the heap 62 // unless the user actually sets these flags. 63 if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) { 64 FLAG_SET_DEFAULT(MinHeapFreeRatio, 0); 65 } 66 if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) { 67 FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100); 68 } 69 } 70 71 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the 72 // SurvivorRatio has been set, reset their default values to SurvivorRatio + 73 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger. 74 // See CR 6362902 for details. 75 if (!FLAG_IS_DEFAULT(SurvivorRatio)) { 76 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) { 77 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2); 78 } 79 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) { 80 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2); 81 } 82 } 83 84 if (UseParallelOldGC) { 85 // Par compact uses lower default values since they are treated as 86 // minimums. These are different defaults because of the different 87 // interpretation and are not ergonomically set. 88 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) { 89 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1); 90 } 91 } 92 } 93 94 CollectedHeap* ParallelArguments::create_heap() { 95 return create_heap_with_policy<ParallelScavengeHeap, GenerationSizer>(); 96 }