src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp
author gziemski
Mon, 23 Apr 2018 10:59:39 -0500
changeset 49857 31e07291ae29
parent 49734 src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.cpp@f946776e9354
permissions -rw-r--r--
8081519: Split globals.hpp to factor out the Flag class Summary: Factored out Flag out go globals, renamed to JVMFlag Reviewed-by: coleenp, dholmes, kvn
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
/*
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
     2
 * Copyright (c) 2015, 2018, 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"
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    28
#include "gc/shared/jvmFlagConstraintsGC.hpp"
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    29
#include "gc/shared/plab.hpp"
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    30
#include "gc/shared/threadLocalAllocBuffer.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    31
#include "runtime/arguments.hpp"
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    32
#include "runtime/flags/jvmFlagRangeList.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    33
#include "runtime/globals.hpp"
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    34
#include "runtime/globals_extension.hpp"
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
    35
#include "runtime/thread.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    36
#include "utilities/align.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    37
#include "utilities/defaultStream.hpp"
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    38
#include "utilities/macros.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    39
#if INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    40
#include "gc/cms/jvmFlagConstraintsCMS.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    41
#include "gc/g1/jvmFlagConstraintsG1.hpp"
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    42
#include "gc/parallel/jvmFlagConstraintsParallel.hpp"
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    43
#endif
31371
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
// As ParallelGCThreads differs among GC modes, we need constraint function.
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    60
JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    61
  JVMFlag::Error status = JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    62
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    63
#if INCLUDE_ALL_GCS
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    64
  status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    65
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    66
    return status;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    67
  }
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    68
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    69
  status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    70
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    71
    return status;
33144
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
#endif
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
    74
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    75
  return status;
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
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    78
// 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
    79
// we need constraint function.
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    80
JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    81
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    82
  // 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
    83
  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
    84
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    85
                            "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
    86
                            "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
    87
                            value, ParallelGCThreads);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    88
    return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    89
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    90
#endif
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    91
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    92
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
    93
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
    94
static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
    95
#if INCLUDE_ALL_GCS
37234
07d212151499 8153201: TestOptionsWithRanges fails with -XX:OldPLABSize=2147483648
sangheki
parents: 37233
diff changeset
    96
  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    97
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    98
                            "%s (" SIZE_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    99
                            "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
   100
                            name, value, PLAB::min_size());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   101
    return JVMFlag::VIOLATES_CONSTRAINT;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   102
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   103
#endif // INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   104
  return JVMFlag::SUCCESS;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   105
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   106
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   107
JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   108
#if INCLUDE_ALL_GCS
37234
07d212151499 8153201: TestOptionsWithRanges fails with -XX:OldPLABSize=2147483648
sangheki
parents: 37233
diff changeset
   109
  if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   110
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   111
                            "%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
   112
                            "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
   113
                            name, value, PLAB::max_size());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   114
    return JVMFlag::VIOLATES_CONSTRAINT;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   115
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   116
#endif // INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   117
  return JVMFlag::SUCCESS;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   118
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   119
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   120
static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   121
  JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose);
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   122
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   123
  if (status == JVMFlag::SUCCESS) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   124
    return MaxPLABSizeBounds(name, value, verbose);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   125
  }
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   126
  return status;
31995
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
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   129
JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   130
  return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   131
}
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   132
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   133
JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   134
  JVMFlag::Error status = JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   135
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   136
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   137
  if (UseConcMarkSweepGC) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   138
    return OldPLABSizeConstraintFuncCMS(value, verbose);
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   139
  } else {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   140
    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
   141
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   142
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   143
  return status;
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
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   146
JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   147
  if (value > MaxHeapFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   148
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   149
                            "MinHeapFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   150
                            "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   151
                            value, MaxHeapFreeRatio);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   152
    return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   153
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   154
    return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   155
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   156
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   157
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   158
JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   159
  if (value < MinHeapFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   160
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   161
                            "MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   162
                            "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   163
                            value, MinHeapFreeRatio);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   164
    return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   165
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   166
    return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   167
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   168
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   169
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   170
static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   171
  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
   172
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   173
                            "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
   174
                            "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
   175
                            "(" 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
   176
                            maxHeap, softRef);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   177
    return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   178
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   179
    return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   180
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   181
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   182
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   183
JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   184
  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
   185
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   186
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   187
JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   188
  if (value > MarkStackSizeMax) {
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   189
    CommandLineError::print(verbose,
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   190
                            "MarkStackSize (" SIZE_FORMAT ") must be "
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   191
                            "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n",
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   192
                            value, MarkStackSizeMax);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   193
    return JVMFlag::VIOLATES_CONSTRAINT;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   194
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   195
    return JVMFlag::SUCCESS;
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   196
  }
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   197
}
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   198
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   199
JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   200
  if (value > MaxMetaspaceFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   201
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   202
                            "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   203
                            "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   204
                            value, MaxMetaspaceFreeRatio);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   205
    return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   206
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   207
    return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   208
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   209
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   210
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   211
JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   212
  if (value < MinMetaspaceFreeRatio) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   213
    CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   214
                            "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   215
                            "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   216
                            value, MinMetaspaceFreeRatio);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   217
    return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   218
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   219
    return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   220
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   221
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   222
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   223
JVMFlag::Error InitialTenuringThresholdConstraintFunc(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
   224
#if INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   225
  JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   226
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   227
    return status;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   228
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   229
#endif
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   230
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   231
  return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   232
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   233
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   234
JVMFlag::Error MaxTenuringThresholdConstraintFunc(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
   235
#if INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   236
  JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   237
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   238
    return status;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   239
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   240
#endif
31371
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
  // 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
   243
  if ((value == 0) && (NeverTenure || !AlwaysTenure)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   244
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   245
                            "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
   246
                            "&& 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
   247
                            "AlwaysTenure=%s\n",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   248
                            NeverTenure ? "true" : "false",
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   249
                            AlwaysTenure ? "true" : "false");
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   250
    return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   251
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   252
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   253
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   254
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   255
JVMFlag::Error MaxGCPauseMillisConstraintFunc(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
   256
#if INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   257
  JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   258
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   259
    return status;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   260
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   261
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   262
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   263
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   264
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   265
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   266
JVMFlag::Error GCPauseIntervalMillisConstraintFunc(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
   267
#if INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   268
  JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   269
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   270
    return status;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   271
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   272
#endif
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   273
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   274
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   275
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   276
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   277
JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   278
  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
   279
  if (value > aligned_max) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   280
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   281
                            "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
   282
                            "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
   283
                            value, aligned_max);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   284
    return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   285
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   286
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   287
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   288
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   289
// To avoid an overflow by 'align_up(value, alignment)'.
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   290
static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   291
  size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   292
  if (value > aligned_max) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   293
    CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   294
                            "%s (" SIZE_FORMAT ") must be "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   295
                            "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
   296
                            name, value, aligned_max);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   297
    return JVMFlag::VIOLATES_CONSTRAINT;
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   298
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   299
  return JVMFlag::SUCCESS;
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   300
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   301
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   302
static JVMFlag::Error MaxSizeForHeapAlignment(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
   303
  size_t heap_alignment;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   304
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   305
#if INCLUDE_ALL_GCS
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   306
  if (UseG1GC) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   307
    // For G1 GC, we don't know until G1CollectorPolicy is created.
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   308
    heap_alignment = MaxSizeForHeapAlignmentG1();
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   309
  } else
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   310
#endif
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   311
  {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   312
    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
   313
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   314
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   315
  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
   316
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   317
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   318
JVMFlag::Error InitialHeapSizeConstraintFunc(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
   319
  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
   320
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   321
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   322
JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   323
  JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   324
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   325
  if (status == JVMFlag::SUCCESS) {
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   326
    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
   327
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   328
  return status;
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   329
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   330
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   331
JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   332
  // 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
   333
  // 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
   334
  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
   335
    CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   336
                            "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
   337
                            "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
   338
                            value, MaxHeapSize, max_uintx);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   339
    return JVMFlag::VIOLATES_CONSTRAINT;
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   340
  }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   341
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   342
  return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   343
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   344
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   345
JVMFlag::Error NewSizeConstraintFunc(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
   346
#if INCLUDE_ALL_GCS
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   347
  JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   348
  if (status != JVMFlag::SUCCESS) {
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   349
    return status;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   350
  }
49731
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   351
#endif
635838cb8b3a 8201168: Move GC command line constraint functions to GC specific files
stefank
parents: 49164
diff changeset
   352
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   353
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   354
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   355
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   356
JVMFlag::Error MinTLABSizeConstraintFunc(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
   357
  // 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
   358
  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
   359
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   360
                            "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
   361
                            "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
   362
                            value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   363
    return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   364
  }
37157
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   365
  if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   366
    CommandLineError::print(verbose,
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   367
                            "MinTLABSize (" SIZE_FORMAT ") must be "
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   368
                            "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
   369
                            value, ThreadLocalAllocBuffer::max_size() * HeapWordSize);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   370
    return JVMFlag::VIOLATES_CONSTRAINT;
37157
2a0fdb3e2a19 8152118: MinTLABSize should be less than TLAB max
sangheki
parents: 37054
diff changeset
   371
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   372
  return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   373
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   374
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   375
JVMFlag::Error TLABSizeConstraintFunc(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
   376
  // 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
   377
  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
   378
    if (value < MinTLABSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   379
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   380
                              "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
   381
                              "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
   382
                              value, MinTLABSize);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   383
      return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   384
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   385
    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
   386
      CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   387
                              "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
   388
                              "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
   389
                              value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   390
      return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   391
    }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   392
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   393
  return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   394
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   395
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   396
// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   397
// so AfterMemoryInit type is enough to check.
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   398
JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   399
  if (UseTLAB) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   400
    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
   401
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   402
    // 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
   403
    if (refill_waste_limit > (max_uintx - value)) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   404
      CommandLineError::print(verbose,
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   405
                              "TLABWasteIncrement (" UINTX_FORMAT ") must be "
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   406
                              "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
   407
                              value, (max_uintx - refill_waste_limit));
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   408
      return JVMFlag::VIOLATES_CONSTRAINT;
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   409
    }
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   410
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   411
  return JVMFlag::SUCCESS;
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   412
}
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 33144
diff changeset
   413
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   414
JVMFlag::Error SurvivorRatioConstraintFunc(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
   415
  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
   416
      (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   417
    CommandLineError::print(verbose,
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   418
                            "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
   419
                            "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
   420
                            value,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   421
                            (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   422
    return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   423
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   424
    return JVMFlag::SUCCESS;
33144
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
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   427
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   428
JVMFlag::Error MetaspaceSizeConstraintFunc(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
   429
  if (value > MaxMetaspaceSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   430
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   431
                            "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
   432
                            "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
   433
                            value, MaxMetaspaceSize);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   434
    return JVMFlag::VIOLATES_CONSTRAINT;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   435
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   436
    return JVMFlag::SUCCESS;
33144
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   437
  }
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   438
}
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   439
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   440
JVMFlag::Error MaxMetaspaceSizeConstraintFunc(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
   441
  if (value < MetaspaceSize) {
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   442
    CommandLineError::print(verbose,
c56850e328fc 8134995: [REDO] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents: 32613
diff changeset
   443
                            "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
   444
                            "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
   445
                            value, MaxMetaspaceSize);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   446
    return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   447
  } else {
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   448
    return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   449
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   450
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   451
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   452
JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   453
  if (value != 0) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   454
    if (!is_power_of_2(value)) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   455
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   456
                              "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   457
                              "power of 2\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   458
                              value);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   459
      return JVMFlag::VIOLATES_CONSTRAINT;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31371
diff changeset
   460
    }
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   461
    if (value < ObjectAlignmentInBytes) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   462
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   463
                              "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   464
                              "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   465
                              value, ObjectAlignmentInBytes);
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   466
      return JVMFlag::VIOLATES_CONSTRAINT;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   467
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   468
  }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 49734
diff changeset
   469
  return JVMFlag::SUCCESS;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   470
}