src/hotspot/share/runtime/commandLineFlagRangeList.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46742 hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp@24ec8a039c90
child 47765 b7c7428eaab9
child 55767 8e22715afabc
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
/*
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46499
diff changeset
     2
 * Copyright (c) 2015, 2017, 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"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    26
#include "classfile/stringTable.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    27
#include "classfile/symbolTable.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    28
#include "gc/shared/referenceProcessor.hpp"
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46499
diff changeset
    29
#include "prims/jvm.h"
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46560
diff changeset
    30
#include "oops/markOop.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    31
#include "runtime/arguments.hpp"
37208
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
    32
#include "runtime/commandLineFlagConstraintList.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    33
#include "runtime/commandLineFlagRangeList.hpp"
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46560
diff changeset
    34
#include "runtime/globals_extension.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    35
#include "runtime/os.hpp"
33222
e0a340f4ab6e 8078556: Runtime: implement ranges (optionally constraints) for those flags that have them missing.
gziemski
parents: 33144
diff changeset
    36
#include "runtime/task.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    37
#include "utilities/defaultStream.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    38
#include "utilities/macros.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    39
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    40
void CommandLineError::print(bool verbose, const char* msg, ...) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    41
  if (verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    42
    va_list listPointer;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    43
    va_start(listPointer, msg);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    44
    jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    45
    va_end(listPointer);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    46
  }
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    47
}
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    48
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    49
class CommandLineFlagRange_int : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    50
  int _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    51
  int _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    52
  const int* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    53
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    54
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    55
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    56
  CommandLineFlagRange_int(const char* name, const int* ptr, int min, int max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    57
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    58
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    59
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    60
    return check_int(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    61
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    62
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    63
  Flag::Error check_int(int value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    64
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    65
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    66
                              "int %s=%d is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    67
                              "[ %d ... %d ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    68
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    69
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    70
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    71
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    72
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    73
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    74
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    75
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    76
    st->print("[ %-25d ... %25d ]", _min, _max);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    77
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    78
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    79
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    80
class CommandLineFlagRange_intx : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    81
  intx _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    82
  intx _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    83
  const intx* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    84
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    85
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    86
  CommandLineFlagRange_intx(const char* name, const intx* ptr, intx min, intx max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    87
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    88
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    89
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
    90
    return check_intx(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    91
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    92
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    93
  Flag::Error check_intx(intx value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    94
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    95
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    96
                              "intx %s=" INTX_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    97
                              "[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    98
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    99
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   100
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   101
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   102
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   103
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   104
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   105
  void print(outputStream* st) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31371
diff changeset
   106
    st->print("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   107
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   108
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   109
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   110
class CommandLineFlagRange_uint : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   111
  uint _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   112
  uint _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   113
  const uint* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   114
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   115
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   116
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   117
  CommandLineFlagRange_uint(const char* name, const uint* ptr, uint min, uint max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   118
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   119
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   120
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   121
    return check_uint(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   122
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   123
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   124
  Flag::Error check_uint(uint value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   125
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   126
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   127
                              "uint %s=%u is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   128
                              "[ %u ... %u ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   129
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   130
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   131
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   132
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   133
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   134
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   135
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   136
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   137
    st->print("[ %-25u ... %25u ]", _min, _max);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   138
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   139
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   140
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   141
class CommandLineFlagRange_uintx : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   142
  uintx _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   143
  uintx _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   144
  const uintx* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   145
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   146
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   147
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   148
  CommandLineFlagRange_uintx(const char* name, const uintx* ptr, uintx min, uintx max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   149
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   150
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   151
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   152
    return check_uintx(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   153
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   154
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   155
  Flag::Error check_uintx(uintx value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   156
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   157
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   158
                              "uintx %s=" UINTX_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   159
                              "[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   160
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   161
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   162
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   163
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   164
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   165
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   166
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   167
  void print(outputStream* st) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31371
diff changeset
   168
    st->print("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   169
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   170
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   171
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   172
class CommandLineFlagRange_uint64_t : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   173
  uint64_t _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   174
  uint64_t _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   175
  const uint64_t* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   176
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   177
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   178
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   179
  CommandLineFlagRange_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   180
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   181
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   182
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   183
    return check_uint64_t(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   184
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   185
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   186
  Flag::Error check_uint64_t(uint64_t value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   187
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   188
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   189
                              "uint64_t %s=" UINT64_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   190
                              "[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   191
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   192
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   193
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   194
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   195
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   196
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   197
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   198
  void print(outputStream* st) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31371
diff changeset
   199
    st->print("[ " UINT64_FORMAT_W(-25) " ... " UINT64_FORMAT_W(25) " ]", _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   200
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   201
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   202
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   203
class CommandLineFlagRange_size_t : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   204
  size_t _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   205
  size_t _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   206
  const size_t* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   207
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   208
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   209
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   210
  CommandLineFlagRange_size_t(const char* name, const size_t* ptr, size_t min, size_t max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   211
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   212
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   213
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   214
    return check_size_t(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   215
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   216
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   217
  Flag::Error check_size_t(size_t value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   218
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   219
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   220
                              "size_t %s=" SIZE_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   221
                              "[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   222
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   223
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   224
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   225
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   226
    }
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
  void print(outputStream* st) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31371
diff changeset
   230
    st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   231
  }
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   234
class CommandLineFlagRange_double : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   235
  double _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   236
  double _max;
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   237
  const double* _ptr;
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   238
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   239
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   240
  // the "name" argument must be a string literal
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   241
  CommandLineFlagRange_double(const char* name, const double* ptr, double min, double max)
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   242
    : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   243
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   244
  Flag::Error check(bool verbose = true) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   245
    return check_double(*_ptr, verbose);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   246
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   247
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   248
  Flag::Error check_double(double value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   249
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   250
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   251
                              "double %s=%f is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   252
                              "[ %f ... %f ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   253
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   254
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   255
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   256
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   257
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   258
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   259
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   260
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   261
    st->print("[ %-25.3f ... %25.3f ]", _min, _max);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   262
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   263
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   264
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   265
// No constraint emitting
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   266
void emit_range_no(...)                         { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   267
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   268
// No constraint emitting if function argument is NOT provided
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   269
void emit_range_bool(const char* /*name*/, const bool* /*value*/)            { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   270
void emit_range_ccstr(const char* /*name*/, const ccstr* /*value*/)          { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   271
void emit_range_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/)  { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   272
void emit_range_int(const char* /*name*/, const int* /*value*/)              { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   273
void emit_range_intx(const char* /*name*/, const intx* /*value*/)            { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   274
void emit_range_uint(const char* /*name*/, const uint* /*value*/)            { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   275
void emit_range_uintx(const char* /*name*/, const uintx* /*value*/)          { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   276
void emit_range_uint64_t(const char* /*name*/, const uint64_t* /*value*/)    { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   277
void emit_range_size_t(const char* /*name*/, const size_t* /*value*/)        { /* NOP */ }
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   278
void emit_range_double(const char* /*name*/, const double* /*value*/)        { /* NOP */ }
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   279
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   280
// CommandLineFlagRange emitting code functions if range arguments are provided
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   281
void emit_range_int(const char* name, const int* ptr, int min, int max)       {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   282
  CommandLineFlagRangeList::add(new CommandLineFlagRange_int(name, ptr, min, max));
36574
adf1e92565a3 8145204: JVM can hang when ParGCArrayScanChunk=4294967296 and ParallelGC is used
sangheki
parents: 34661
diff changeset
   283
}
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   284
void emit_range_intx(const char* name, const intx* ptr, intx min, intx max) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   285
  CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, ptr, min, max));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   286
}
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   287
void emit_range_uint(const char* name, const uint* ptr, uint min, uint max) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   288
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uint(name, ptr, min, max));
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 34242
diff changeset
   289
}
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   290
void emit_range_uintx(const char* name, const uintx* ptr, uintx min, uintx max) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   291
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, ptr, min, max));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   292
}
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   293
void emit_range_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   294
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, ptr, min, max));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   295
}
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   296
void emit_range_size_t(const char* name, const size_t* ptr, size_t min, size_t max) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   297
  CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, ptr, min, max));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   298
}
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   299
void emit_range_double(const char* name, const double* ptr, double min, double max) {
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   300
  CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, ptr, min, max));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   301
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   302
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   303
// Generate code to call emit_range_xxx function
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   304
#define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc)      ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   305
#define EMIT_RANGE_COMMERCIAL_FLAG(type, name, value, doc)   ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   306
#define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc)   ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   307
#define EMIT_RANGE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   308
#define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc)   ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   309
#define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc)   ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   310
#define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc)          ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   311
#define EMIT_RANGE_PD_DIAGNOSTIC_FLAG(type, name, doc)       ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   312
#ifndef PRODUCT
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   313
#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc)    ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   314
#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc)        ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   315
#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc)   ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   316
#else
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   317
#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc)    ); emit_range_no(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   318
#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc)        ); emit_range_no(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   319
#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc)   ); emit_range_no(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   320
#endif
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   321
#ifdef _LP64
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   322
#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   323
#else
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   324
#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_no(#name,&name
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   325
#endif
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   326
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   327
// Generate func argument to pass into emit_range_xxx functions
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   328
#define EMIT_RANGE_CHECK(a, b)                               , a, b
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   329
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 34242
diff changeset
   330
#define INITIAL_RANGES_SIZE 379
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   331
GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   332
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   333
// Check the ranges of all flags that have them
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   334
void CommandLineFlagRangeList::init(void) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   335
37491
edf4cc53f5a3 8153039: Command line processing should use mtCommand or mtArguments rather than mtInternal for NMT
gziemski
parents: 37208
diff changeset
   336
  _ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagRange*>(INITIAL_RANGES_SIZE, true);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   337
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   338
  emit_range_no(NULL RUNTIME_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   339
                                   EMIT_RANGE_PD_DEVELOPER_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   340
                                   EMIT_RANGE_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   341
                                   EMIT_RANGE_PD_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   342
                                   EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   343
                                   EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   344
                                   EMIT_RANGE_EXPERIMENTAL_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   345
                                   EMIT_RANGE_NOTPRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   346
                                   EMIT_RANGE_MANAGEABLE_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   347
                                   EMIT_RANGE_PRODUCT_RW_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   348
                                   EMIT_RANGE_LP64_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   349
                                   EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   350
                                   IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   351
                                   IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   352
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   353
  EMIT_RANGES_FOR_GLOBALS_EXT
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   354
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   355
  emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   356
                                EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   357
                                EMIT_RANGE_DIAGNOSTIC_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   358
                                EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   359
                                EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   360
                                EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   361
                                IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   362
                                IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   363
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   364
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   365
  emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   366
                                 EMIT_RANGE_PD_DEVELOPER_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   367
                                 EMIT_RANGE_PRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   368
                                 EMIT_RANGE_PD_PRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   369
                                 EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   370
                                 EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   371
                                 EMIT_RANGE_EXPERIMENTAL_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   372
                                 EMIT_RANGE_NOTPRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   373
                                 EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   374
                                 IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   375
                                 IGNORE_WRITEABLE));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   376
#endif // INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   377
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   378
#ifdef COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   379
  emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   380
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   381
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   382
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   383
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   384
                              EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   385
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   386
                              EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   387
                              IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   388
                              IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   389
#endif // COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   390
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   391
#ifdef COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   392
  emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   393
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   394
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   395
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   396
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   397
                              EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   398
                              EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   399
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   400
                              EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   401
                              IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   402
                              IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   403
#endif // COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   404
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   405
#if INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   406
  emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   407
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   408
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   409
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   410
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   411
                              EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   412
                              EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   413
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   414
                              EMIT_RANGE_MANAGEABLE_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   415
                              EMIT_RANGE_PRODUCT_RW_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   416
                              EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   417
                              IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   418
                              IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   419
#endif // INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   420
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   421
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   422
CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   423
  CommandLineFlagRange* found = NULL;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   424
  for (int i=0; i<length(); i++) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   425
    CommandLineFlagRange* range = at(i);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   426
    if (strcmp(range->name(), name) == 0) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   427
      found = range;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   428
      break;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   429
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   430
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   431
  return found;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   432
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   433
37208
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   434
void CommandLineFlagRangeList::print(outputStream* st, const char* name, RangeStrFunc default_range_str_func) {
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   435
  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   436
  if (range != NULL) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   437
    range->print(st);
37208
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   438
  } else {
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   439
    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   440
    if (constraint != NULL) {
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   441
      assert(default_range_str_func!=NULL, "default_range_str_func must be provided");
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   442
      st->print("%s", default_range_str_func());
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   443
    } else {
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   444
      st->print("[                           ...                           ]");
aaf76eb8cfd4 8142510: -XX:+PrintFlagsRanges should print default range value for those flags that have constraint and an implicit range.
gziemski
parents: 36574
diff changeset
   445
    }
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   446
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   447
}
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   448
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   449
bool CommandLineFlagRangeList::check_ranges() {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   450
  // Check ranges.
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   451
  bool status = true;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   452
  for (int i=0; i<length(); i++) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   453
    CommandLineFlagRange* range = at(i);
46499
22e71ef4a16a 8180614: Skip range and constraint checks on non-existent flags
redestad
parents: 39117
diff changeset
   454
    if (range->check(true) != Flag::SUCCESS) status = false;
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   455
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   456
  return status;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   457
}