< prev index next >

src/hotspot/share/gc/parallel/parallelArguments.cpp

Print this page
rev 52689 : 8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy
Summary: Consolidate code related to GC threads calculation into a single class


  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "gc/parallel/parallelArguments.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/shared/adaptiveSizePolicy.hpp"
  30 #include "gc/shared/collectorPolicy.hpp"
  31 #include "gc/shared/gcArguments.inline.hpp"

  32 #include "runtime/globals.hpp"
  33 #include "runtime/globals_extension.hpp"
  34 #include "runtime/java.hpp"
  35 #include "runtime/vm_version.hpp"
  36 #include "utilities/defaultStream.hpp"
  37 
  38 size_t ParallelArguments::conservative_max_heap_alignment() {
  39   return CollectorPolicy::compute_heap_alignment();
  40 }
  41 
  42 void ParallelArguments::initialize() {
  43   GCArguments::initialize();
  44   assert(UseParallelGC || UseParallelOldGC, "Error");
  45   // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
  46   if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
  47     FLAG_SET_DEFAULT(UseParallelOldGC, true);
  48   }
  49   FLAG_SET_DEFAULT(UseParallelGC, true);
  50 
  51   // If no heap maximum was requested explicitly, use some reasonable fraction
  52   // of the physical memory, up to a maximum of 1GB.
  53   FLAG_SET_DEFAULT(ParallelGCThreads,
  54                    VM_Version::parallel_worker_threads());
  55   if (ParallelGCThreads == 0) {
  56     jio_fprintf(defaultStream::error_stream(),
  57         "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
  58     vm_exit(1);
  59   }
  60 
  61   if (UseAdaptiveSizePolicy) {
  62     // We don't want to limit adaptive heap sizing's freedom to adjust the heap
  63     // unless the user actually sets these flags.
  64     if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
  65       FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
  66     }
  67     if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
  68       FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
  69     }
  70   }
  71 
  72   // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
  73   // SurvivorRatio has been set, reset their default values to SurvivorRatio +
  74   // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.




  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "gc/parallel/parallelArguments.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/shared/adaptiveSizePolicy.hpp"
  30 #include "gc/shared/collectorPolicy.hpp"
  31 #include "gc/shared/gcArguments.inline.hpp"
  32 #include "gc/shared/workerPolicy.hpp"
  33 #include "runtime/globals.hpp"
  34 #include "runtime/globals_extension.hpp"
  35 #include "runtime/java.hpp"

  36 #include "utilities/defaultStream.hpp"
  37 
  38 size_t ParallelArguments::conservative_max_heap_alignment() {
  39   return CollectorPolicy::compute_heap_alignment();
  40 }
  41 
  42 void ParallelArguments::initialize() {
  43   GCArguments::initialize();
  44   assert(UseParallelGC || UseParallelOldGC, "Error");
  45   // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
  46   if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
  47     FLAG_SET_DEFAULT(UseParallelOldGC, true);
  48   }
  49   FLAG_SET_DEFAULT(UseParallelGC, true);
  50 
  51   // If no heap maximum was requested explicitly, use some reasonable fraction
  52   // of the physical memory, up to a maximum of 1GB.
  53   FLAG_SET_DEFAULT(ParallelGCThreads,
  54                    WorkerPolicy::parallel_worker_threads());
  55   if (ParallelGCThreads == 0) {
  56     jio_fprintf(defaultStream::error_stream(),
  57         "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
  58     vm_exit(1);
  59   }
  60 
  61   if (UseAdaptiveSizePolicy) {
  62     // We don't want to limit adaptive heap sizing's freedom to adjust the heap
  63     // unless the user actually sets these flags.
  64     if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
  65       FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
  66     }
  67     if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
  68       FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
  69     }
  70   }
  71 
  72   // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
  73   // SurvivorRatio has been set, reset their default values to SurvivorRatio +
  74   // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.


< prev index next >