hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
author stefank
Wed, 05 Jul 2017 11:33:17 +0200
changeset 46625 edefffab74e2
parent 46619 a3919f5e8d2b
permissions -rw-r--r--
8183552: Move align functions to align.hpp Reviewed-by: stuefe, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     1
/*
37054
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     4
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     7
 * published by the Free Software Foundation.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     8
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    13
 * accompanied this code).
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    14
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    18
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    21
 * questions.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    22
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    23
 */
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    24
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    25
#include "precompiled.hpp"
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    26
#include "gc/shared/collectedHeap.hpp"
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    27
#include "gc/shared/collectorPolicy.hpp"
37054
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
    28
#include "gc/shared/genCollectedHeap.hpp"
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    29
#include "gc/shared/threadLocalAllocBuffer.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    30
#include "runtime/arguments.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    31
#include "runtime/commandLineFlagConstraintsGC.hpp"
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    32
#include "runtime/commandLineFlagRangeList.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    33
#include "runtime/globals.hpp"
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    34
#include "runtime/globals_extension.hpp"
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
    35
#include "runtime/thread.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    36
#include "utilities/align.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    37
#include "utilities/defaultStream.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    38
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    39
#if INCLUDE_ALL_GCS
37264
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
    40
#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    41
#include "gc/g1/g1_globals.hpp"
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
    42
#include "gc/g1/heapRegionBounds.inline.hpp"
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
    43
#include "gc/shared/plab.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    44
#endif // INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    45
#ifdef COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    46
#include "c1/c1_globals.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    47
#endif // COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    48
#ifdef COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    49
#include "opto/c2_globals.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    50
#endif // COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    51
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    52
// Some flags that have default values that indicate that the
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    53
// JVM should automatically determine an appropriate value
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    54
// for that flag.  In those cases it is only appropriate for the
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    55
// constraint checking to be done if the user has specified the
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    56
// value(s) of the flag(s) on the command line.  In the constraint
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    57
// checking functions,  FLAG_IS_CMDLINE() is used to check if
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    58
// the flag has been set by the user and so should be checked.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    59
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    60
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    61
static Flag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    62
  // CMSWorkQueueDrainThreshold is verified to be less than max_juint
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    63
  if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    64
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    65
                            "ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold ("
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    66
                            UINTX_FORMAT ") is too large\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    67
                            threads, threshold);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    68
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    69
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    70
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    71
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    72
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    73
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    74
// As ParallelGCThreads differs among GC modes, we need constraint function.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    75
Flag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    76
  Flag::Error status = Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    77
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    78
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    79
  // Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    80
  // So can't exceed with "max_jint"
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    81
  if (UseParallelGC && (value > (uint)max_jint)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    82
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    83
                            "ParallelGCThreads (" UINT32_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    84
                            "less than or equal to " UINT32_FORMAT " for Parallel GC\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    85
                            value, max_jint);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    86
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    87
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    88
  // To avoid overflow at ParScanClosure::do_oop_work.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    89
  if (UseConcMarkSweepGC && (value > (max_jint / 10))) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    90
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    91
                            "ParallelGCThreads (" UINT32_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    92
                            "less than or equal to " UINT32_FORMAT " for CMS GC\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    93
                            value, (max_jint / 10));
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    94
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    95
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    96
  status = ParallelGCThreadsAndCMSWorkQueueDrainThreshold(value, CMSWorkQueueDrainThreshold, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    97
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    98
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    99
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   100
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   101
// As ConcGCThreads should be smaller than ParallelGCThreads,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   102
// we need constraint function.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   103
Flag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   104
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   105
  // CMS and G1 GCs use ConcGCThreads.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   106
  if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   107
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   108
                            "ConcGCThreads (" UINT32_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   109
                            "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   110
                            value, ParallelGCThreads);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   111
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   112
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   113
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   114
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   115
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   116
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   117
static Flag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   118
#if INCLUDE_ALL_GCS
37234
07d212151499 8153201: TestOptionsWithRanges fails with -XX:OldPLABSize=2147483648
sangheki
parents: 37233
diff changeset
   119
  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   120
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   121
                            "%s (" SIZE_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   122
                            "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   123
                            name, value, PLAB::min_size());
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   124
    return Flag::VIOLATES_CONSTRAINT;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   125
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   126
#endif // INCLUDE_ALL_GCS
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   127
  return Flag::SUCCESS;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   128
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   129
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   130
static Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   131
#if INCLUDE_ALL_GCS
37234
07d212151499 8153201: TestOptionsWithRanges fails with -XX:OldPLABSize=2147483648
sangheki
parents: 37233
diff changeset
   132
  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   133
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   134
                            "%s (" SIZE_FORMAT ") must be "
32601
c5df671276bd 8078555: GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32351
diff changeset
   135
                            "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
32610
bf513f9f3fb9 8134856: Incorrect use of PLAB::min_size() in MaxPLABSizeBounds
tschatzl
parents: 32601
diff changeset
   136
                            name, value, PLAB::max_size());
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   137
    return Flag::VIOLATES_CONSTRAINT;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   138
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   139
#endif // INCLUDE_ALL_GCS
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   140
  return Flag::SUCCESS;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   141
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   142
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   143
static Flag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   144
  Flag::Error status = MinPLABSizeBounds(name, value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   145
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   146
  if (status == Flag::SUCCESS) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   147
    return MaxPLABSizeBounds(name, value, verbose);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   148
  }
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   149
  return status;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   150
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   151
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   152
Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   153
  return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   154
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   155
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   156
Flag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   157
  Flag::Error status = Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   158
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   159
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   160
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   161
    if (value == 0) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   162
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   163
                              "OldPLABSize (" SIZE_FORMAT ") must be greater than 0",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   164
                              value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   165
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   166
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   167
    // For CMS, OldPLABSize is the number of free blocks of a given size that are used when
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   168
    // replenishing the local per-worker free list caches.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   169
    // For more details, please refer to Arguments::set_cms_and_parnew_gc_flags().
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   170
    status = MaxPLABSizeBounds("OldPLABSize", value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   171
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   172
    status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   173
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   174
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   175
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   176
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   177
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   178
Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   179
  if (value > MaxHeapFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   180
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   181
                            "MinHeapFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   182
                            "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   183
                            value, MaxHeapFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   184
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   185
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   186
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   187
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   188
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   189
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   190
Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   191
  if (value < MinHeapFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   192
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   193
                            "MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   194
                            "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   195
                            value, MinHeapFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   196
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   197
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   198
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   199
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   200
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   201
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   202
static Flag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   203
  if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   204
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   205
                            "Desired lifetime of SoftReferences cannot be expressed correctly. "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   206
                            "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   207
                            "(" INTX_FORMAT ") is too large\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   208
                            maxHeap, softRef);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   209
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   210
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   211
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   212
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   213
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   214
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   215
Flag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   216
  return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   217
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   218
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   219
Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   220
  if (value > MaxMetaspaceFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   221
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   222
                            "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   223
                            "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   224
                            value, MaxMetaspaceFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   225
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   226
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   227
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   228
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   229
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   230
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   231
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   232
  if (value < MinMetaspaceFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   233
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   234
                            "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   235
                            "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   236
                            value, MinMetaspaceFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   237
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   238
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   239
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   240
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   241
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   242
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   243
Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   244
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   245
  // InitialTenuringThreshold is only used for ParallelGC.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   246
  if (UseParallelGC && (value > MaxTenuringThreshold)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   247
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   248
                              "InitialTenuringThreshold (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   249
                              "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   250
                              value, MaxTenuringThreshold);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   251
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   252
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   253
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   254
  return Flag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   255
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   256
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   257
Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   258
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   259
  // As only ParallelGC uses InitialTenuringThreshold,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   260
  // we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   261
  if (UseParallelGC && (value < InitialTenuringThreshold)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   262
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   263
                            "MaxTenuringThreshold (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   264
                            "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   265
                            value, InitialTenuringThreshold);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   266
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   267
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   268
#endif
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   269
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   270
  // MaxTenuringThreshold=0 means NeverTenure=false && AlwaysTenure=true
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   271
  if ((value == 0) && (NeverTenure || !AlwaysTenure)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   272
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   273
                            "MaxTenuringThreshold (0) should match to NeverTenure=false "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   274
                            "&& AlwaysTenure=true. But we have NeverTenure=%s "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   275
                            "AlwaysTenure=%s\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   276
                            NeverTenure ? "true" : "false",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   277
                            AlwaysTenure ? "true" : "false");
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   278
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   279
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   280
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   281
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   282
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   283
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   284
Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   285
  if (!UseG1GC) return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   286
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   287
  // Default value of G1RSetRegionEntries=0 means will be set ergonomically.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   288
  // Minimum value is 1.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   289
  if (FLAG_IS_CMDLINE(G1RSetRegionEntries) && (value < 1)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   290
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   291
                            "G1RSetRegionEntries (" INTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   292
                            "greater than or equal to 1\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   293
                            value);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   294
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   295
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   296
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   297
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   298
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   299
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   300
Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   301
  if (!UseG1GC) return Flag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   302
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   303
  // Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   304
  // Minimum value is 1.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   305
  if (FLAG_IS_CMDLINE(G1RSetSparseRegionEntries) && (value < 1)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   306
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   307
                            "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   308
                            "greater than or equal to 1\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   309
                            value);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   310
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   311
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   312
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   313
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   314
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   315
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   316
Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   317
  if (!UseG1GC) return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   318
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   319
  // Default value of G1HeapRegionSize=0 means will be set ergonomically.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   320
  if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   321
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   322
                            "G1HeapRegionSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   323
                            "greater than or equal to ergonomic heap region minimum size\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   324
                            value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   325
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   326
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   327
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   328
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   329
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   330
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   331
Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   332
  if (!UseG1GC) return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   333
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   334
  if (value > G1MaxNewSizePercent) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   335
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   336
                            "G1NewSizePercent (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   337
                            "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   338
                            value, G1MaxNewSizePercent);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   339
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   340
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   341
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   342
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   343
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   344
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   345
Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   346
  if (!UseG1GC) return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   347
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   348
  if (value < G1NewSizePercent) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   349
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   350
                            "G1MaxNewSizePercent (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   351
                            "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   352
                            value, G1NewSizePercent);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   353
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   354
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   355
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   356
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   357
}
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   358
#endif // INCLUDE_ALL_GCS
32613
73bec9f941d7 8134972: [BACKOUT] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32610
diff changeset
   359
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   360
Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   361
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   362
  if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   363
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   364
                            "ParGCStridesPerThread (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   365
                            "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   366
                            value, ((uintx)max_jint / (uintx)ParallelGCThreads));
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   367
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   368
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   369
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   370
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   371
}
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   372
37233
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   373
Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   374
#if INCLUDE_ALL_GCS
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   375
  if (UseConcMarkSweepGC) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   376
    // ParGCCardsPerStrideChunk should be compared with card table size.
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   377
    size_t heap_size = Universe::heap()->reserved_region().word_size();
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   378
    CardTableModRefBS* bs = (CardTableModRefBS*)GenCollectedHeap::heap()->rem_set()->bs();
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   379
    size_t card_table_size = bs->cards_required(heap_size) - 1; // Valid card table size
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   380
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   381
    if ((size_t)value > card_table_size) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   382
      CommandLineError::print(verbose,
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   383
                              "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   384
                              "must be less than or equal to card table size (" SIZE_FORMAT ")\n",
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   385
                              value, card_table_size);
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   386
      return Flag::VIOLATES_CONSTRAINT;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   387
    }
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   388
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   389
    // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   390
    // from CardTableModRefBSForCTRS::process_stride(). Note that ParGCStridesPerThread is already checked
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   391
    // not to make an overflow with ParallelGCThreads from its constraint function.
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   392
    uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   393
    uintx ergo_max = max_uintx / n_strides;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   394
    if ((uintx)value > ergo_max) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   395
      CommandLineError::print(verbose,
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   396
                              "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   397
                              "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   398
                              value, ergo_max);
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   399
      return Flag::VIOLATES_CONSTRAINT;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   400
    }
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   401
  }
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   402
#endif
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   403
  return Flag::SUCCESS;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   404
}
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   405
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   406
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   407
  Flag::Error status = Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   408
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   409
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   410
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   411
    if (value > CMSOldPLABMax) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   412
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   413
                              "CMSOldPLABMin (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   414
                              "less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   415
                              value, CMSOldPLABMax);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   416
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   417
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   418
    status = MaxPLABSizeBounds("CMSOldPLABMin", value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   419
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   420
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   421
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   422
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   423
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   424
Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   425
  Flag::Error status = Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   426
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   427
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   428
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   429
    status = MaxPLABSizeBounds("CMSOldPLABMax", value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   430
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   431
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   432
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   433
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   434
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   435
Flag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   436
  if (value > MarkStackSizeMax) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   437
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   438
                            "MarkStackSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   439
                            "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   440
                            value, MarkStackSizeMax);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   441
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   442
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   443
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   444
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   445
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   446
37433
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   447
static Flag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value, bool verbose) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   448
#if INCLUDE_ALL_GCS
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   449
  if (UseConcMarkSweepGC) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   450
    ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen();
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   451
    const size_t ergo_max = cms->cmsSpace()->max_flag_size_for_task_size();
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   452
    if (value > ergo_max) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   453
      CommandLineError::print(verbose,
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   454
                              "%s (" SIZE_FORMAT ") must be "
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   455
                              "less than or equal to ergonomic maximum (" SIZE_FORMAT ") "
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   456
                              "which is based on the maximum size of the old generation of the Java heap\n",
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   457
                              name, value, ergo_max);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   458
      return Flag::VIOLATES_CONSTRAINT;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   459
    }
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   460
  }
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   461
#endif
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   462
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   463
  return Flag::SUCCESS;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   464
}
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   465
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   466
Flag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   467
  Flag::Error status = CMSReservedAreaConstraintFunc("CMSRescanMultiple", value, verbose);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   468
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   469
#if INCLUDE_ALL_GCS
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   470
  if (status == Flag::SUCCESS && UseConcMarkSweepGC) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   471
    // CMSParRemarkTask::do_dirty_card_rescan_tasks requires CompactibleFreeListSpace::rescan_task_size()
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   472
    // to be aligned to CardTableModRefBS::card_size * BitsPerWord.
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   473
    // Note that rescan_task_size() will be aligned if CMSRescanMultiple is a multiple of 'HeapWordSize'
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   474
    // because rescan_task_size() is CardTableModRefBS::card_size / HeapWordSize * BitsPerWord.
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   475
    if (value % HeapWordSize != 0) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   476
      CommandLineError::print(verbose,
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   477
                              "CMSRescanMultiple (" SIZE_FORMAT ") must be "
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   478
                              "a multiple of " SIZE_FORMAT "\n",
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   479
                              value, HeapWordSize);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   480
      status = Flag::VIOLATES_CONSTRAINT;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   481
    }
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   482
  }
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   483
#endif
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   484
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   485
  return status;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   486
}
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   487
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   488
Flag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   489
  return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   490
}
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   491
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   492
Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   493
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   494
  if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   495
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   496
                            "CMSPrecleanDenominator (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   497
                            "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   498
                            value, CMSPrecleanNumerator);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   499
    return Flag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   500
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   501
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   502
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   503
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   504
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   505
Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   506
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   507
  if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   508
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   509
                            "CMSPrecleanNumerator (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   510
                            "less than CMSPrecleanDenominator (" UINTX_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   511
                            value, CMSPrecleanDenominator);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   512
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   513
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   514
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   515
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   516
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   517
37054
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   518
Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) {
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   519
#if INCLUDE_ALL_GCS
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   520
  if (UseConcMarkSweepGC) {
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   521
    size_t max_capacity = GenCollectedHeap::heap()->young_gen()->max_capacity();
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   522
    if (value > max_uintx - max_capacity) {
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   523
    CommandLineError::print(verbose,
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   524
                            "CMSSamplingGrain (" UINTX_FORMAT ") must be "
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   525
                            "less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n",
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   526
                            value, max_uintx - max_capacity);
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   527
    return Flag::VIOLATES_CONSTRAINT;
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   528
    }
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   529
  }
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   530
#endif
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   531
  return Flag::SUCCESS;
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   532
}
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   533
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   534
Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   535
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   536
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   537
    return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(ParallelGCThreads, value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   538
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   539
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   540
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   541
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   542
37264
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   543
Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) {
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   544
#if INCLUDE_ALL_GCS
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   545
  // Skip for current default value.
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   546
  if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) {
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   547
    // CMSBitMapYieldQuantum should be compared with mark bitmap size.
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   548
    ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen();
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   549
    size_t bitmap_size = cms->collector()->markBitMap()->sizeInWords();
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   550
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   551
    if (value > bitmap_size) {
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   552
      CommandLineError::print(verbose,
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   553
                              "CMSBitMapYieldQuantum (" SIZE_FORMAT ") must "
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   554
                              "be less than or equal to bitmap size (" SIZE_FORMAT ") "
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   555
                              "whose size corresponds to the size of old generation of the Java heap\n",
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   556
                              value, bitmap_size);
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   557
      return Flag::VIOLATES_CONSTRAINT;
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   558
    }
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   559
  }
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   560
#endif
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   561
  return Flag::SUCCESS;
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   562
}
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   563
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   564
Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   565
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   566
  if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   567
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   568
                            "MaxGCPauseMillis (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   569
                            "less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   570
                            value, GCPauseIntervalMillis);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   571
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   572
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   573
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   574
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   575
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   576
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   577
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   578
Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   579
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   580
  if (UseG1GC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   581
    if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   582
      if (value < 1) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   583
        CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   584
                                "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   585
                                "greater than or equal to 1\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   586
                                value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   587
        return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   588
      }
38012
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   589
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   590
      if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   591
        CommandLineError::print(verbose,
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   592
                                "GCPauseIntervalMillis cannot be set "
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   593
                                "without setting MaxGCPauseMillis\n");
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   594
        return Flag::VIOLATES_CONSTRAINT;
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   595
      }
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   596
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   597
      if (value <= MaxGCPauseMillis) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   598
        CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   599
                                "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   600
                                "greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   601
                                value, MaxGCPauseMillis);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   602
        return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   603
      }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   604
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   605
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   606
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   607
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   608
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   609
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   610
Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   611
  size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words());
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   612
  if (value > aligned_max) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   613
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   614
                            "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   615
                            "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   616
                            value, aligned_max);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   617
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   618
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   619
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   620
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   621
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   622
// To avoid an overflow by 'align_up(value, alignment)'.
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   623
static Flag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   624
  size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   625
  if (value > aligned_max) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   626
    CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   627
                            "%s (" SIZE_FORMAT ") must be "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   628
                            "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   629
                            name, value, aligned_max);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   630
    return Flag::VIOLATES_CONSTRAINT;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   631
  }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   632
  return Flag::SUCCESS;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   633
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   634
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   635
static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   636
  // For G1 GC, we don't know until G1CollectorPolicy is created.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   637
  size_t heap_alignment;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   638
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   639
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   640
  if (UseG1GC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   641
    heap_alignment = HeapRegionBounds::max_size();
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   642
  } else
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   643
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   644
  {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   645
    heap_alignment = CollectorPolicy::compute_heap_alignment();
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   646
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   647
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   648
  return MaxSizeForAlignment(name, value, heap_alignment, verbose);
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   649
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   650
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   651
Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   652
  return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   653
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   654
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   655
Flag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   656
  Flag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   657
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   658
  if (status == Flag::SUCCESS) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   659
    status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   660
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   661
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   662
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   663
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   664
Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   665
  // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value.
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   666
  // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx.
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   667
  if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   668
    CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   669
                            "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   670
                            "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n",
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   671
                            value, MaxHeapSize, max_uintx);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   672
    return Flag::VIOLATES_CONSTRAINT;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   673
  }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   674
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   675
  return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   676
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   677
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   678
Flag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   679
#ifdef _LP64
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   680
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   681
  // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   682
  // when the value to be assigned exceeds uint range.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   683
  // i.e. result of '(uint)(NewSize / region size(1~32MB))'
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   684
  // So maximum of NewSize should be 'max_juint * 1M'
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   685
  if (UseG1GC && (value > (max_juint * 1 * M))) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   686
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   687
                            "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   688
                            value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   689
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   690
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   691
#endif // INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   692
#endif // _LP64
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   693
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   694
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   695
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   696
Flag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   697
  // At least, alignment reserve area is needed.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   698
  if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   699
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   700
                            "MinTLABSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   701
                            "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   702
                            value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   703
    return Flag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   704
  }
37157
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   705
  if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   706
    CommandLineError::print(verbose,
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   707
                            "MinTLABSize (" SIZE_FORMAT ") must be "
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   708
                            "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n",
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   709
                            value, ThreadLocalAllocBuffer::max_size() * HeapWordSize);
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   710
    return Flag::VIOLATES_CONSTRAINT;
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   711
  }
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   712
  return Flag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   713
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   714
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   715
Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   716
  // Skip for default value of zero which means set ergonomically.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   717
  if (FLAG_IS_CMDLINE(TLABSize)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   718
    if (value < MinTLABSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   719
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   720
                              "TLABSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   721
                              "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   722
                              value, MinTLABSize);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   723
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   724
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   725
    if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   726
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   727
                              "TLABSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   728
                              "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   729
                              value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   730
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   731
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   732
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   733
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   734
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   735
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   736
// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   737
// so AfterMemoryInit type is enough to check.
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   738
Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   739
  if (UseTLAB) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   740
    size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   741
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   742
    // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   743
    if (refill_waste_limit > (max_uintx - value)) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   744
      CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   745
                              "TLABWasteIncrement (" UINTX_FORMAT ") must be "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   746
                              "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   747
                              value, (max_uintx - refill_waste_limit));
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   748
      return Flag::VIOLATES_CONSTRAINT;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   749
    }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   750
  }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   751
  return Flag::SUCCESS;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   752
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   753
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   754
Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   755
  if (FLAG_IS_CMDLINE(SurvivorRatio) &&
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   756
      (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   757
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   758
                            "SurvivorRatio (" UINTX_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   759
                            "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   760
                            value,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   761
                            (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   762
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   763
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   764
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   765
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   766
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   767
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   768
Flag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   769
  if (value > MaxMetaspaceSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   770
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   771
                            "MetaspaceSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   772
                            "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   773
                            value, MaxMetaspaceSize);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   774
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   775
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   776
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   777
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   778
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   779
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   780
Flag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   781
  if (value < MetaspaceSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   782
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   783
                            "MaxMetaspaceSize (" SIZE_FORMAT ") must be "
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   784
                            "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   785
                            value, MaxMetaspaceSize);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   786
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   787
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   788
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   789
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   790
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   791
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   792
Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   793
  if (value != 0) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   794
    if (!is_power_of_2(value)) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   795
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   796
                              "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   797
                              "power of 2\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   798
                              value);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   799
      return Flag::VIOLATES_CONSTRAINT;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   800
    }
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   801
    if (value < ObjectAlignmentInBytes) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   802
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   803
                              "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   804
                              "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   805
                              value, ObjectAlignmentInBytes);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   806
      return Flag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   807
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   808
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   809
  return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   810
}