hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp
author stefank
Tue, 04 Jul 2017 15:58:10 +0200
changeset 46619 a3919f5e8d2b
parent 46618 d503911aa948
child 46625 edefffab74e2
permissions -rw-r--r--
8178499: Remove _ptr_ and _size_ infixes from align functions Reviewed-by: rehn, tschatzl
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"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    36
#include "utilities/defaultStream.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    37
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    38
#if INCLUDE_ALL_GCS
37264
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
    39
#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    40
#include "gc/g1/g1_globals.hpp"
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
    41
#include "gc/g1/heapRegionBounds.inline.hpp"
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
    42
#include "gc/shared/plab.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    43
#endif // INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    44
#ifdef COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    45
#include "c1/c1_globals.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    46
#endif // COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    47
#ifdef COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    48
#include "opto/c2_globals.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    49
#endif // COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    50
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    51
// 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
    52
// 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
    53
// 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
    54
// 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
    55
// 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
    56
// 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
    57
// 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
    58
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    59
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    60
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
    61
  // 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
    62
  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
    63
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    64
                            "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
    65
                            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
    66
                            threads, threshold);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    67
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    68
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    69
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    70
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    71
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    72
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    73
// 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
    74
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
    75
  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
    76
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    77
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    78
  // 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
    79
  // 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
    80
  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
    81
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    82
                            "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
    83
                            "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
    84
                            value, max_jint);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    85
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    86
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    87
  // 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
    88
  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
    89
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    90
                            "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
    91
                            "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
    92
                            value, (max_jint / 10));
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    93
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    94
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    95
  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
    96
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    97
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    98
}
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
// 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
   101
// we need constraint function.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   102
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
   103
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   104
  // 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
   105
  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
   106
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   107
                            "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
   108
                            "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
   109
                            value, ParallelGCThreads);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   110
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   111
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   112
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   113
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   114
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   115
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   116
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
   117
#if INCLUDE_ALL_GCS
37234
07d212151499 8153201: TestOptionsWithRanges fails with -XX:OldPLABSize=2147483648
sangheki
parents: 37233
diff changeset
   118
  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   119
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   120
                            "%s (" SIZE_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   121
                            "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
   122
                            name, value, PLAB::min_size());
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   123
    return Flag::VIOLATES_CONSTRAINT;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   124
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   125
#endif // INCLUDE_ALL_GCS
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   126
  return Flag::SUCCESS;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   127
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   128
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   129
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
   130
#if INCLUDE_ALL_GCS
37234
07d212151499 8153201: TestOptionsWithRanges fails with -XX:OldPLABSize=2147483648
sangheki
parents: 37233
diff changeset
   131
  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   132
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   133
                            "%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
   134
                            "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
   135
                            name, value, PLAB::max_size());
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   136
    return Flag::VIOLATES_CONSTRAINT;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   137
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   138
#endif // INCLUDE_ALL_GCS
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   139
  return Flag::SUCCESS;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   140
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   141
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   142
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
   143
  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
   144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   145
  if (status == Flag::SUCCESS) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   146
    return MaxPLABSizeBounds(name, value, verbose);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   147
  }
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   148
  return status;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   149
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   150
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   151
Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   152
  return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   153
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   154
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   155
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
   156
  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
   157
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   158
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   159
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   160
    if (value == 0) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   161
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   162
                              "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
   163
                              value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   164
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   165
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   166
    // 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
   167
    // 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
   168
    // 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
   169
    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
   170
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   171
    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
   172
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   173
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   174
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   175
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   176
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   177
Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   178
  if (value > MaxHeapFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   179
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   180
                            "MinHeapFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   181
                            "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   182
                            value, MaxHeapFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   183
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   184
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   185
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   186
  }
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
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   189
Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   190
  if (value < MinHeapFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   191
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   192
                            "MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   193
                            "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   194
                            value, MinHeapFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   195
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   196
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   197
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   198
  }
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
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   201
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
   202
  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
   203
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   204
                            "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
   205
                            "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
   206
                            "(" 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
   207
                            maxHeap, softRef);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   208
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   209
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   210
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   211
  }
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
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
   215
  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
   216
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   217
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   218
Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   219
  if (value > MaxMetaspaceFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   220
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   221
                            "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   222
                            "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   223
                            value, MaxMetaspaceFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   224
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   225
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   226
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   227
  }
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
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   230
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   231
  if (value < MinMetaspaceFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   232
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   233
                            "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   234
                            "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   235
                            value, MinMetaspaceFreeRatio);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   236
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   237
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   238
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   239
  }
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
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   242
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
   243
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   244
  // 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
   245
  if (UseParallelGC && (value > MaxTenuringThreshold)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   246
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   247
                              "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
   248
                              "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
   249
                              value, MaxTenuringThreshold);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   250
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   251
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   252
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   253
  return Flag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   254
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   255
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   256
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
   257
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   258
  // 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
   259
  // 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
   260
  if (UseParallelGC && (value < InitialTenuringThreshold)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   261
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   262
                            "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
   263
                            "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
   264
                            value, InitialTenuringThreshold);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   265
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   266
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   267
#endif
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   268
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   269
  // 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
   270
  if ((value == 0) && (NeverTenure || !AlwaysTenure)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   271
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   272
                            "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
   273
                            "&& 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
   274
                            "AlwaysTenure=%s\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   275
                            NeverTenure ? "true" : "false",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   276
                            AlwaysTenure ? "true" : "false");
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   277
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   278
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   279
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   280
}
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
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   283
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
   284
  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
   285
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   286
  // 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
   287
  // Minimum value is 1.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   288
  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
   289
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   290
                            "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
   291
                            "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
   292
                            value);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   293
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   294
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   295
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   296
  }
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
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   299
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
   300
  if (!UseG1GC) return Flag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   301
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   302
  // 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
   303
  // Minimum value is 1.
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   304
  if (FLAG_IS_CMDLINE(G1RSetSparseRegionEntries) && (value < 1)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   305
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   306
                            "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
   307
                            "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
   308
                            value);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   309
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   310
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   311
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   312
  }
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
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   315
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
   316
  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
   317
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   318
  // 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
   319
  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
   320
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   321
                            "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
   322
                            "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
   323
                            value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   324
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   325
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   326
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   327
  }
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
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   330
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
   331
  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
   332
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   333
  if (value > G1MaxNewSizePercent) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   334
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   335
                            "G1NewSizePercent (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   336
                            "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   337
                            value, G1MaxNewSizePercent);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   338
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   339
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   340
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   341
  }
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
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   344
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
   345
  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
   346
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   347
  if (value < G1NewSizePercent) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   348
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   349
                            "G1MaxNewSizePercent (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   350
                            "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   351
                            value, G1NewSizePercent);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   352
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   353
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   354
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   355
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   356
}
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   357
#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
   358
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   359
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
   360
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   361
  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
   362
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   363
                            "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
   364
                            "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
   365
                            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
   366
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   367
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   368
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   369
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   370
}
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   371
37233
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   372
Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   373
#if INCLUDE_ALL_GCS
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   374
  if (UseConcMarkSweepGC) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   375
    // ParGCCardsPerStrideChunk should be compared with card table size.
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   376
    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
   377
    CardTableModRefBS* bs = (CardTableModRefBS*)GenCollectedHeap::heap()->rem_set()->bs();
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   378
    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
   379
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   380
    if ((size_t)value > card_table_size) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   381
      CommandLineError::print(verbose,
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   382
                              "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
   383
                              "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
   384
                              value, card_table_size);
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   385
      return Flag::VIOLATES_CONSTRAINT;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   386
    }
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
    // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   389
    // 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
   390
    // 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
   391
    uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   392
    uintx ergo_max = max_uintx / n_strides;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   393
    if ((uintx)value > ergo_max) {
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   394
      CommandLineError::print(verbose,
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   395
                              "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   396
                              "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
   397
                              value, ergo_max);
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   398
      return Flag::VIOLATES_CONSTRAINT;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   399
    }
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
#endif
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   402
  return Flag::SUCCESS;
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   403
}
e8e674469545 8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
sangheki
parents: 37157
diff changeset
   404
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   405
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
   406
  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
   407
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   408
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   409
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   410
    if (value > CMSOldPLABMax) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   411
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   412
                              "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
   413
                              "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
   414
                              value, CMSOldPLABMax);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   415
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   416
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   417
    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
   418
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   419
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   420
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   421
}
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
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
   424
  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
   425
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   426
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   427
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   428
    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
   429
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   430
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   431
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   432
}
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
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
   435
  if (value > MarkStackSizeMax) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   436
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   437
                            "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
   438
                            "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
   439
                            value, MarkStackSizeMax);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   440
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   441
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   442
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   443
  }
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
37433
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   446
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
   447
#if INCLUDE_ALL_GCS
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   448
  if (UseConcMarkSweepGC) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   449
    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
   450
    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
   451
    if (value > ergo_max) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   452
      CommandLineError::print(verbose,
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   453
                              "%s (" SIZE_FORMAT ") must be "
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   454
                              "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
   455
                              "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
   456
                              name, value, ergo_max);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   457
      return Flag::VIOLATES_CONSTRAINT;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   458
    }
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
#endif
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   461
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   462
  return Flag::SUCCESS;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   463
}
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
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
   466
  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
   467
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   468
#if INCLUDE_ALL_GCS
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   469
  if (status == Flag::SUCCESS && UseConcMarkSweepGC) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   470
    // 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
   471
    // 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
   472
    // 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
   473
    // 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
   474
    if (value % HeapWordSize != 0) {
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   475
      CommandLineError::print(verbose,
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   476
                              "CMSRescanMultiple (" SIZE_FORMAT ") must be "
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   477
                              "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
   478
                              value, HeapWordSize);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   479
      status = Flag::VIOLATES_CONSTRAINT;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   480
    }
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
#endif
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   483
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   484
  return status;
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   485
}
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
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
   488
  return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose);
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   489
}
f8fd0bcc60af 8152182: Possible overflow in initialzation of _rescan_task_size and _marking_task_size
sangheki
parents: 37264
diff changeset
   490
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   491
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
   492
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   493
  if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   494
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   495
                            "CMSPrecleanDenominator (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   496
                            "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   497
                            value, CMSPrecleanNumerator);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   498
    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
   499
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   500
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   501
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   502
}
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
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
   505
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   506
  if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   507
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   508
                            "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
   509
                            "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
   510
                            value, CMSPrecleanDenominator);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   511
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   512
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   513
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   514
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   515
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   516
37054
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   517
Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) {
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   518
#if INCLUDE_ALL_GCS
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   519
  if (UseConcMarkSweepGC) {
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   520
    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
   521
    if (value > max_uintx - max_capacity) {
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   522
    CommandLineError::print(verbose,
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   523
                            "CMSSamplingGrain (" UINTX_FORMAT ") must be "
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   524
                            "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
   525
                            value, max_uintx - max_capacity);
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   526
    return Flag::VIOLATES_CONSTRAINT;
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   527
    }
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
#endif
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   530
  return Flag::SUCCESS;
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   531
}
31d83caf01e8 8145312: CMS: There is insufficient memory with CMSSamplingGrain=1
sangheki
parents: 35203
diff changeset
   532
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   533
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
   534
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   535
  if (UseConcMarkSweepGC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   536
    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
   537
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   538
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   539
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   540
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   541
37264
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   542
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
   543
#if INCLUDE_ALL_GCS
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   544
  // Skip for current default value.
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   545
  if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) {
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   546
    // 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
   547
    ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen();
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   548
    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
   549
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   550
    if (value > bitmap_size) {
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   551
      CommandLineError::print(verbose,
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   552
                              "CMSBitMapYieldQuantum (" SIZE_FORMAT ") must "
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   553
                              "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
   554
                              "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
   555
                              value, bitmap_size);
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   556
      return Flag::VIOLATES_CONSTRAINT;
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   557
    }
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
#endif
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   560
  return Flag::SUCCESS;
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   561
}
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37234
diff changeset
   562
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   563
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
   564
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   565
  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
   566
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   567
                            "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
   568
                            "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
   569
                            value, GCPauseIntervalMillis);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   570
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   571
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   572
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   573
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   574
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   575
}
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
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
   578
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   579
  if (UseG1GC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   580
    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
   581
      if (value < 1) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   582
        CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   583
                                "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
   584
                                "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
   585
                                value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   586
        return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   587
      }
38012
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   588
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   589
      if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   590
        CommandLineError::print(verbose,
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   591
                                "GCPauseIntervalMillis cannot be set "
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   592
                                "without setting MaxGCPauseMillis\n");
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   593
        return Flag::VIOLATES_CONSTRAINT;
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   594
      }
69916710bfed 8154745: Move default G1 pause time target setup to argument parsing
mgerdin
parents: 37433
diff changeset
   595
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   596
      if (value <= MaxGCPauseMillis) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   597
        CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   598
                                "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
   599
                                "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
   600
                                value, MaxGCPauseMillis);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   601
        return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   602
      }
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
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   606
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   607
}
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
Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   610
  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
   611
  if (value > aligned_max) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   612
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   613
                            "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
   614
                            "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
   615
                            value, aligned_max);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   616
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   617
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   618
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   619
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   620
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   621
// 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
   622
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
   623
  size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   624
  if (value > aligned_max) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   625
    CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   626
                            "%s (" SIZE_FORMAT ") must be "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   627
                            "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
   628
                            name, value, aligned_max);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   629
    return Flag::VIOLATES_CONSTRAINT;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   630
  }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   631
  return Flag::SUCCESS;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   632
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   633
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   634
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
   635
  // 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
   636
  size_t heap_alignment;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   637
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   638
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   639
  if (UseG1GC) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   640
    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
   641
  } else
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   642
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   643
  {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   644
    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
   645
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   646
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   647
  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
   648
}
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
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
   651
  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
   652
}
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
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
   655
  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
   656
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   657
  if (status == Flag::SUCCESS) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   658
    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
   659
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   660
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   661
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   662
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   663
Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   664
  // 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
   665
  // 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
   666
  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
   667
    CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   668
                            "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
   669
                            "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
   670
                            value, MaxHeapSize, max_uintx);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   671
    return Flag::VIOLATES_CONSTRAINT;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   672
  }
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
  return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   675
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   676
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   677
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
   678
#ifdef _LP64
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   679
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   680
  // 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
   681
  // 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
   682
  // 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
   683
  // 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
   684
  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
   685
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   686
                            "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
   687
                            value);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   688
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   689
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   690
#endif // INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   691
#endif // _LP64
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   692
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   693
}
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
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
   696
  // 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
   697
  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
   698
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   699
                            "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
   700
                            "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
   701
                            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
   702
    return Flag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   703
  }
37157
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   704
  if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   705
    CommandLineError::print(verbose,
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   706
                            "MinTLABSize (" SIZE_FORMAT ") must be "
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   707
                            "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
   708
                            value, ThreadLocalAllocBuffer::max_size() * HeapWordSize);
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   709
    return Flag::VIOLATES_CONSTRAINT;
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   710
  }
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   711
  return Flag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   712
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   713
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   714
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
   715
  // 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
   716
  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
   717
    if (value < MinTLABSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   718
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   719
                              "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
   720
                              "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
   721
                              value, MinTLABSize);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   722
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   723
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   724
    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
   725
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   726
                              "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
   727
                              "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
   728
                              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
   729
      return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   730
    }
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
  return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   733
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   734
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   735
// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   736
// so AfterMemoryInit type is enough to check.
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   737
Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   738
  if (UseTLAB) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   739
    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
   740
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   741
    // 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
   742
    if (refill_waste_limit > (max_uintx - value)) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   743
      CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   744
                              "TLABWasteIncrement (" UINTX_FORMAT ") must be "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   745
                              "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
   746
                              value, (max_uintx - refill_waste_limit));
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   747
      return Flag::VIOLATES_CONSTRAINT;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   748
    }
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
  return Flag::SUCCESS;
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   751
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   752
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   753
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
   754
  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
   755
      (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   756
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   757
                            "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
   758
                            "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
   759
                            value,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   760
                            (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
   761
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   762
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   763
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   764
  }
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
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
   768
  if (value > MaxMetaspaceSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   769
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   770
                            "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
   771
                            "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
   772
                            value, MaxMetaspaceSize);
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   773
    return Flag::VIOLATES_CONSTRAINT;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   774
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   775
    return Flag::SUCCESS;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   776
  }
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
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
   780
  if (value < MetaspaceSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   781
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   782
                            "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
   783
                            "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
   784
                            value, MaxMetaspaceSize);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   785
    return Flag::VIOLATES_CONSTRAINT;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   786
  } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   787
    return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   788
  }
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
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   791
Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   792
  if (value != 0) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   793
    if (!is_power_of_2(value)) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   794
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   795
                              "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   796
                              "power of 2\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   797
                              value);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   798
      return Flag::VIOLATES_CONSTRAINT;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   799
    }
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   800
    if (value < ObjectAlignmentInBytes) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   801
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   802
                              "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   803
                              "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   804
                              value, ObjectAlignmentInBytes);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   805
      return Flag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   806
    }
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
  return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   809
}