1 /*
   2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
   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 "runtime/flags/jvmFlagRangeList.hpp"
  27 #include "runtime/globals.hpp"
  28 #include "utilities/globalDefinitions.hpp"
  29 
  30 JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) {
  31   // Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter.
  32   // So can't exceed with "max_jint"
  33 
  34   if (UseParallelGC && (value > (uint)max_jint)) {
  35     CommandLineError::print(verbose,
  36                             "ParallelGCThreads (" UINT32_FORMAT ") must be "
  37                             "less than or equal to " UINT32_FORMAT " for Parallel GC\n",
  38                             value, max_jint);
  39     return JVMFlag::VIOLATES_CONSTRAINT;
  40   }
  41   return JVMFlag::SUCCESS;
  42 }
  43 
  44 JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) {
  45   // InitialTenuringThreshold is only used for ParallelGC.
  46   if (UseParallelGC && (value > MaxTenuringThreshold)) {
  47       CommandLineError::print(verbose,
  48                               "InitialTenuringThreshold (" UINTX_FORMAT ") must be "
  49                               "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
  50                               value, MaxTenuringThreshold);
  51       return JVMFlag::VIOLATES_CONSTRAINT;
  52   }
  53   return JVMFlag::SUCCESS;
  54 }
  55 
  56 JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) {
  57   // As only ParallelGC uses InitialTenuringThreshold,
  58   // we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold.
  59   if (UseParallelGC && (value < InitialTenuringThreshold)) {
  60     CommandLineError::print(verbose,
  61                             "MaxTenuringThreshold (" UINTX_FORMAT ") must be "
  62                             "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
  63                             value, InitialTenuringThreshold);
  64     return JVMFlag::VIOLATES_CONSTRAINT;
  65   }
  66 
  67   return JVMFlag::SUCCESS;
  68 }