hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp
author zmajo
Fri, 28 Apr 2017 09:50:47 +0200
changeset 46422 6ecc7cc67619
parent 39117 59fa99a45873
child 46499 22e71ef4a16a
permissions -rw-r--r--
8179019: Correct range checks for command-line options ArraycopySrcPrefetchDistance and ArraycopyDstPrefetchDistance Summary: Update constraint for the command-line options. Change stubs to use register values instead of immediates. Reviewed-by: 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
/*
36574
adf1e92565a3 8145204: JVM can hang when ParGCArrayScanChunk=4294967296 and ParallelGC is used
sangheki
parents: 34661
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     4
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     7
 * published by the Free Software Foundation.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     8
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    13
 * accompanied this code).
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    14
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    18
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    21
 * questions.
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    22
 *
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    23
 */
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    24
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    25
#include "precompiled.hpp"
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"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    29
#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
    30
#include "runtime/commandLineFlagConstraintList.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    31
#include "runtime/commandLineFlagRangeList.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    32
#include "runtime/os.hpp"
33222
e0a340f4ab6e 8078556: Runtime: implement ranges (optionally constraints) for those flags that have them missing.
gziemski
parents: 33144
diff changeset
    33
#include "runtime/task.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    34
#include "utilities/defaultStream.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    35
#include "utilities/macros.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    36
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    37
void CommandLineError::print(bool verbose, const char* msg, ...) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    38
  if (verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    39
    va_list listPointer;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    40
    va_start(listPointer, msg);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    41
    jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    42
    va_end(listPointer);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    43
  }
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    44
}
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    45
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    46
class CommandLineFlagRange_int : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    47
  int _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    48
  int _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    49
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    50
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    51
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    52
  CommandLineFlagRange_int(const char* name, int min, int max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    53
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    54
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    55
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    56
  Flag::Error check_int(int value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    57
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    58
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    59
                              "int %s=%d is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    60
                              "[ %d ... %d ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    61
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    62
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    63
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    64
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    65
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    66
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    67
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    68
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    69
    st->print("[ %-25d ... %25d ]", _min, _max);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    70
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    71
};
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
class CommandLineFlagRange_intx : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    74
  intx _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    75
  intx _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    76
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    77
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    78
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    79
  CommandLineFlagRange_intx(const char* name, intx min, intx max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    80
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    81
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    82
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    83
  Flag::Error check_intx(intx value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    84
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    85
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    86
                              "intx %s=" INTX_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    87
                              "[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    88
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    89
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    90
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    91
      return Flag::SUCCESS;
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
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    94
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    95
  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
    96
    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
    97
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    98
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    99
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   100
class CommandLineFlagRange_uint : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   101
  uint _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   102
  uint _max;
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
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   105
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   106
  CommandLineFlagRange_uint(const char* name, uint min, uint max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   107
    _min=min, _max=max;
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
  Flag::Error check_uint(uint value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   111
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   112
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   113
                              "uint %s=%u is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   114
                              "[ %u ... %u ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   115
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   116
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   117
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   118
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   119
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   120
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   121
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   122
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   123
    st->print("[ %-25u ... %25u ]", _min, _max);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   124
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   125
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   126
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   127
class CommandLineFlagRange_uintx : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   128
  uintx _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   129
  uintx _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   130
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   131
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   132
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   133
  CommandLineFlagRange_uintx(const char* name, uintx min, uintx max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   134
    _min=min, _max=max;
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   137
  Flag::Error check_uintx(uintx value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   138
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   139
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   140
                              "uintx %s=" UINTX_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   141
                              "[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   142
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   143
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   144
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   145
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   146
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   147
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   148
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   149
  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
   150
    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
   151
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   152
};
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
class CommandLineFlagRange_uint64_t : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   155
  uint64_t _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   156
  uint64_t _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   157
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   158
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   159
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   160
  CommandLineFlagRange_uint64_t(const char* name, uint64_t min, uint64_t max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   161
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   162
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   163
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   164
  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
   165
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   166
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   167
                              "uint64_t %s=" UINT64_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   168
                              "[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   169
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   170
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   171
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   172
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   173
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   174
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   175
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   176
  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
   177
    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
   178
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   179
};
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   180
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   181
class CommandLineFlagRange_size_t : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   182
  size_t _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   183
  size_t _max;
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
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   186
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   187
  CommandLineFlagRange_size_t(const char* name, size_t min, size_t max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   188
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   189
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   190
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   191
  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
   192
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   193
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   194
                              "size_t %s=" SIZE_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   195
                              "[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   196
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   197
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   198
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   199
      return Flag::SUCCESS;
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
  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
   204
    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
   205
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   206
};
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
class CommandLineFlagRange_double : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   209
  double _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   210
  double _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   211
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   212
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   213
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   214
  CommandLineFlagRange_double(const char* name, double min, double max) : CommandLineFlagRange(name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   215
    _min=min, _max=max;
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   218
  Flag::Error check_double(double value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   219
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   220
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   221
                              "double %s=%f is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   222
                              "[ %f ... %f ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   223
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   224
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   225
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   226
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   227
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   228
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   229
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   230
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   231
    st->print("[ %-25.3f ... %25.3f ]", _min, _max);
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   235
// No constraint emitting
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   236
void emit_range_no(...)                         { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   237
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   238
// No constraint emitting if function argument is NOT provided
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   239
void emit_range_bool(const char* /*name*/)      { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   240
void emit_range_ccstr(const char* /*name*/)     { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   241
void emit_range_ccstrlist(const char* /*name*/) { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   242
void emit_range_int(const char* /*name*/)       { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   243
void emit_range_intx(const char* /*name*/)      { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   244
void emit_range_uint(const char* /*name*/)      { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   245
void emit_range_uintx(const char* /*name*/)     { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   246
void emit_range_uint64_t(const char* /*name*/)  { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   247
void emit_range_size_t(const char* /*name*/)    { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   248
void emit_range_double(const char* /*name*/)    { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   249
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   250
// CommandLineFlagRange emitting code functions if range arguments are provided
36574
adf1e92565a3 8145204: JVM can hang when ParGCArrayScanChunk=4294967296 and ParallelGC is used
sangheki
parents: 34661
diff changeset
   251
void emit_range_int(const char* name, int min, int max)       {
adf1e92565a3 8145204: JVM can hang when ParGCArrayScanChunk=4294967296 and ParallelGC is used
sangheki
parents: 34661
diff changeset
   252
  CommandLineFlagRangeList::add(new CommandLineFlagRange_int(name, min, max));
adf1e92565a3 8145204: JVM can hang when ParGCArrayScanChunk=4294967296 and ParallelGC is used
sangheki
parents: 34661
diff changeset
   253
}
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   254
void emit_range_intx(const char* name, intx min, intx max) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   255
  CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   256
}
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 34242
diff changeset
   257
void emit_range_uint(const char* name, uint min, uint max) {
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 34242
diff changeset
   258
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uint(name, min, max));
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 34242
diff changeset
   259
}
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   260
void emit_range_uintx(const char* name, uintx min, uintx max) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   261
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, 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
void emit_range_uint64_t(const char* name, uint64_t min, uint64_t max) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   264
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   265
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   266
void emit_range_size_t(const char* name, size_t min, size_t max) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   267
  CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   268
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   269
void emit_range_double(const char* name, double min, double max) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   270
  CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   271
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   272
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   273
// Generate code to call emit_range_xxx function
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   274
#define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc)      ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   275
#define EMIT_RANGE_COMMERCIAL_FLAG(type, name, value, doc)   ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   276
#define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc)   ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   277
#define EMIT_RANGE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   278
#define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc)   ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   279
#define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc)   ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   280
#define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc)          ); emit_range_##type(#name
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   281
#define EMIT_RANGE_PD_DIAGNOSTIC_FLAG(type, name, doc)       ); emit_range_##type(#name
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   282
#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc)    ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   283
#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc)        ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   284
#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc)   ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   285
#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   286
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   287
// Generate func argument to pass into emit_range_xxx functions
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   288
#define EMIT_RANGE_CHECK(a, b)                               , a, b
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   289
34661
9a1d11d88ea0 8142341: GC: current flags need ranges to be implemented
sangheki
parents: 34242
diff changeset
   290
#define INITIAL_RANGES_SIZE 379
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   291
GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   292
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   293
// Check the ranges of all flags that have them
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   294
void CommandLineFlagRangeList::init(void) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   295
37491
edf4cc53f5a3 8153039: Command line processing should use mtCommand or mtArguments rather than mtInternal for NMT
gziemski
parents: 37208
diff changeset
   296
  _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
   297
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   298
  emit_range_no(NULL RUNTIME_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   299
                                   EMIT_RANGE_PD_DEVELOPER_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   300
                                   EMIT_RANGE_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   301
                                   EMIT_RANGE_PD_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   302
                                   EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   303
                                   EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   304
                                   EMIT_RANGE_EXPERIMENTAL_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   305
                                   EMIT_RANGE_NOTPRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   306
                                   EMIT_RANGE_MANAGEABLE_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   307
                                   EMIT_RANGE_PRODUCT_RW_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   308
                                   EMIT_RANGE_LP64_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   309
                                   EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   310
                                   IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   311
                                   IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   312
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   313
  EMIT_RANGES_FOR_GLOBALS_EXT
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   314
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   315
  emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   316
                                EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   317
                                EMIT_RANGE_DIAGNOSTIC_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   318
                                EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   319
                                EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   320
                                EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   321
                                IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   322
                                IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   323
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   324
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   325
  emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   326
                                 EMIT_RANGE_PD_DEVELOPER_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   327
                                 EMIT_RANGE_PRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   328
                                 EMIT_RANGE_PD_PRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   329
                                 EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   330
                                 EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   331
                                 EMIT_RANGE_EXPERIMENTAL_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   332
                                 EMIT_RANGE_NOTPRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   333
                                 EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   334
                                 IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   335
                                 IGNORE_WRITEABLE));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   336
#endif // INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   337
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   338
#ifdef COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   339
  emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   340
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   341
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   342
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   343
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   344
                              EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   345
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   346
                              EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   347
                              IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   348
                              IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   349
#endif // COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   350
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   351
#ifdef COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   352
  emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   353
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   354
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   355
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   356
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   357
                              EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
32351
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
#endif // COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   364
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   365
#if INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   366
  emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   367
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   368
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   369
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   370
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
39117
59fa99a45873 8150900: Implement diagnostic_pd
csahu
parents: 38273
diff changeset
   371
                              EMIT_RANGE_PD_DIAGNOSTIC_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   372
                              EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   373
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   374
                              EMIT_RANGE_MANAGEABLE_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   375
                              EMIT_RANGE_PRODUCT_RW_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   376
                              EMIT_RANGE_CHECK,
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   377
                              IGNORE_CONSTRAINT,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents: 37491
diff changeset
   378
                              IGNORE_WRITEABLE));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   379
#endif // INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   380
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   381
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   382
CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   383
  CommandLineFlagRange* found = NULL;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   384
  for (int i=0; i<length(); i++) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   385
    CommandLineFlagRange* range = at(i);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   386
    if (strcmp(range->name(), name) == 0) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   387
      found = range;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   388
      break;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   389
    }
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
  return found;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   392
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   393
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
   394
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
   395
  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   396
  if (range != NULL) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   397
    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
   398
  } 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
   399
    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
   400
    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
   401
      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
   402
      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
   403
    } 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
   404
      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
   405
    }
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   406
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   407
}
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   408
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   409
bool CommandLineFlagRangeList::check_ranges() {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   410
  // Check ranges.
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   411
  bool status = true;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   412
  for (int i=0; i<length(); i++) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   413
    CommandLineFlagRange* range = at(i);
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   414
    const char* name = range->name();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   415
    Flag* flag = Flag::find_flag(name, strlen(name), true, true);
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   416
    // We must check for NULL here as lp64_product flags on 32 bit architecture
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   417
    // can generate range check (despite that they are declared as constants),
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   418
    // but they will not be returned by Flag::find_flag()
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   419
    if (flag != NULL) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   420
      if (flag->is_int()) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   421
        int value = flag->get_int();
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   422
        if (range->check_int(value, true) != Flag::SUCCESS) status = false;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   423
      } else if (flag->is_uint()) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   424
        uint value = flag->get_uint();
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   425
        if (range->check_uint(value, true) != Flag::SUCCESS) status = false;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   426
      } else if (flag->is_intx()) {
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   427
        intx value = flag->get_intx();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   428
        if (range->check_intx(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   429
      } else if (flag->is_uintx()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   430
        uintx value = flag->get_uintx();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   431
        if (range->check_uintx(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   432
      } else if (flag->is_uint64_t()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   433
        uint64_t value = flag->get_uint64_t();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   434
        if (range->check_uint64_t(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   435
      } else if (flag->is_size_t()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   436
        size_t value = flag->get_size_t();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   437
        if (range->check_size_t(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   438
      } else if (flag->is_double()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   439
        double value = flag->get_double();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   440
        if (range->check_double(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   441
      }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   442
    }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   443
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   444
  return status;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   445
}