hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp
author coleenp
Wed, 28 Oct 2015 09:47:23 -0400
changeset 33611 9abd65805e19
parent 33230 23bb11a5cf4e
child 34231 adc744ac832a
permissions -rw-r--r--
8139203: Consistent naming for klass type predicates 8138923: Remove oop coupling with InstanceKlass subclasses Summary: Renamed oop_is_instance and friends, removed the functions in oop that dug down into InstanceKlass. Reviewed-by: jrose, lfoltan, stefank
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
/*
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    30
#include "runtime/commandLineFlagRangeList.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    31
#include "runtime/os.hpp"
33222
e0a340f4ab6e 8078556: Runtime: implement ranges (optionally constraints) for those flags that have them missing.
gziemski
parents: 33144
diff changeset
    32
#include "runtime/task.hpp"
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    33
#include "utilities/defaultStream.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    34
#include "utilities/macros.hpp"
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    35
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    36
void CommandLineError::print(bool verbose, const char* msg, ...) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    37
  if (verbose) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    38
    va_list listPointer;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    39
    va_start(listPointer, msg);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    40
    jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    41
    va_end(listPointer);
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    42
  }
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
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    45
class CommandLineFlagRange_int : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    46
  int _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    47
  int _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    48
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    49
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    50
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    51
  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
    52
    _min=min, _max=max;
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    55
  Flag::Error check_int(int value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    56
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    57
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    58
                              "int %s=%d is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    59
                              "[ %d ... %d ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    60
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    61
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    62
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    63
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    64
    }
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
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    68
    st->print("[ %-25d ... %25d ]", _min, _max);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    69
  }
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
class CommandLineFlagRange_intx : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    73
  intx _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    74
  intx _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    75
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    76
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    77
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    78
  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
    79
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    80
  }
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
  Flag::Error check_intx(intx value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    83
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    84
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    85
                              "intx %s=" INTX_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    86
                              "[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
    87
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    88
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    89
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    90
      return Flag::SUCCESS;
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
    94
  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
    95
    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
    96
  }
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
class CommandLineFlagRange_uint : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   100
  uint _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   101
  uint _max;
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
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   104
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   105
  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
   106
    _min=min, _max=max;
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
  Flag::Error check_uint(uint value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   110
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   111
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   112
                              "uint %s=%u is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   113
                              "[ %u ... %u ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   114
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   115
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   116
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   117
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   118
    }
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
  void print(outputStream* st) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   122
    st->print("[ %-25u ... %25u ]", _min, _max);
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
};
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
class CommandLineFlagRange_uintx : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   127
  uintx _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   128
  uintx _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   129
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   130
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   131
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   132
  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
   133
    _min=min, _max=max;
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
  Flag::Error check_uintx(uintx value, bool verbose = true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   137
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   138
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   139
                              "uintx %s=" UINTX_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   140
                              "[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   141
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   142
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   143
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   144
      return Flag::SUCCESS;
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
  }
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
  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
   149
    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
   150
  }
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
class CommandLineFlagRange_uint64_t : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   154
  uint64_t _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   155
  uint64_t _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   156
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   157
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   158
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   159
  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
   160
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   161
  }
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
  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
   164
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   165
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   166
                              "uint64_t %s=" UINT64_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   167
                              "[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   168
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   169
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   170
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   171
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   172
    }
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
  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
   176
    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
   177
  }
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
class CommandLineFlagRange_size_t : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   181
  size_t _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   182
  size_t _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   183
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   184
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   185
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   186
  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
   187
    _min=min, _max=max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   188
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   189
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   190
  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
   191
    if ((value < _min) || (value > _max)) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   192
      CommandLineError::print(verbose,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   193
                              "size_t %s=" SIZE_FORMAT " is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   194
                              "[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   195
                              name(), value, _min, _max);
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   196
      return Flag::OUT_OF_BOUNDS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   197
    } else {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   198
      return Flag::SUCCESS;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   199
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   200
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   201
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   202
  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
   203
    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
   204
  }
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
class CommandLineFlagRange_double : public CommandLineFlagRange {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   208
  double _min;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   209
  double _max;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   210
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   211
public:
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   212
  // the "name" argument must be a string literal
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   213
  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
   214
    _min=min, _max=max;
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_double(double 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
                              "double %s=%f is outside the allowed range "
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   221
                              "[ %f ... %f ]\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) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   230
    st->print("[ %-25.3f ... %25.3f ]", _min, _max);
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
// No constraint emitting
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   235
void emit_range_no(...)                         { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   236
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   237
// No constraint emitting if function argument is NOT provided
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   238
void emit_range_bool(const char* /*name*/)      { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   239
void emit_range_ccstr(const char* /*name*/)     { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   240
void emit_range_ccstrlist(const char* /*name*/) { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   241
void emit_range_int(const char* /*name*/)       { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   242
void emit_range_intx(const char* /*name*/)      { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   243
void emit_range_uint(const char* /*name*/)      { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   244
void emit_range_uintx(const char* /*name*/)     { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   245
void emit_range_uint64_t(const char* /*name*/)  { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   246
void emit_range_size_t(const char* /*name*/)    { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   247
void emit_range_double(const char* /*name*/)    { /* NOP */ }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   248
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   249
// CommandLineFlagRange emitting code functions if range arguments are provided
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   250
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
   251
  CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   252
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   253
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
   254
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   255
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   256
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
   257
  CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, min, max));
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
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
   260
  CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, min, max));
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   261
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   262
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
   263
  CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, min, max));
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
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   266
// Generate code to call emit_range_xxx function
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   267
#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
   268
#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
   269
#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
   270
#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
   271
#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
   272
#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
   273
#define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc)          ); emit_range_##type(#name
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   274
#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
   275
#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
   276
#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
   277
#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
   278
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   279
// Generate func argument to pass into emit_range_xxx functions
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   280
#define EMIT_RANGE_CHECK(a, b)                               , a, b
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   281
33222
e0a340f4ab6e 8078556: Runtime: implement ranges (optionally constraints) for those flags that have them missing.
gziemski
parents: 33144
diff changeset
   282
#define INITIAL_RANGES_SIZE 204
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   283
GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   284
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   285
// Check the ranges of all flags that have them
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   286
void CommandLineFlagRangeList::init(void) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   287
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   288
  _ranges = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagRange*>(INITIAL_RANGES_SIZE, true);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   289
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   290
  emit_range_no(NULL RUNTIME_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   291
                                   EMIT_RANGE_PD_DEVELOPER_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   292
                                   EMIT_RANGE_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   293
                                   EMIT_RANGE_PD_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   294
                                   EMIT_RANGE_DIAGNOSTIC_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   295
                                   EMIT_RANGE_EXPERIMENTAL_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   296
                                   EMIT_RANGE_NOTPRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   297
                                   EMIT_RANGE_MANAGEABLE_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   298
                                   EMIT_RANGE_PRODUCT_RW_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   299
                                   EMIT_RANGE_LP64_PRODUCT_FLAG,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   300
                                   EMIT_RANGE_CHECK,
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   301
                                   IGNORE_CONSTRAINT) );
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
  EMIT_RANGES_FOR_GLOBALS_EXT
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   304
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   305
  emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   306
                                EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   307
                                EMIT_RANGE_DIAGNOSTIC_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   308
                                EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   309
                                EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   310
                                EMIT_RANGE_CHECK,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   311
                                IGNORE_CONSTRAINT));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   312
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   313
#if INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   314
  emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   315
                                 EMIT_RANGE_PD_DEVELOPER_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   316
                                 EMIT_RANGE_PRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   317
                                 EMIT_RANGE_PD_PRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   318
                                 EMIT_RANGE_DIAGNOSTIC_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   319
                                 EMIT_RANGE_EXPERIMENTAL_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   320
                                 EMIT_RANGE_NOTPRODUCT_FLAG,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   321
                                 EMIT_RANGE_CHECK,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   322
                                 IGNORE_CONSTRAINT));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   323
#endif // INCLUDE_JVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32613
diff changeset
   324
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   325
#ifdef COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   326
  emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   327
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   328
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   329
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   330
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   331
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   332
                              EMIT_RANGE_CHECK,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   333
                              IGNORE_CONSTRAINT));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   334
#endif // COMPILER1
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   335
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   336
#ifdef COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   337
  emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   338
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   339
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   340
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   341
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   342
                              EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   343
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   344
                              EMIT_RANGE_CHECK,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   345
                              IGNORE_CONSTRAINT));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   346
#endif // COMPILER2
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   347
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   348
#if INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   349
  emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   350
                              EMIT_RANGE_PD_DEVELOPER_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   351
                              EMIT_RANGE_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   352
                              EMIT_RANGE_PD_PRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   353
                              EMIT_RANGE_DIAGNOSTIC_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   354
                              EMIT_RANGE_EXPERIMENTAL_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   355
                              EMIT_RANGE_NOTPRODUCT_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   356
                              EMIT_RANGE_MANAGEABLE_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   357
                              EMIT_RANGE_PRODUCT_RW_FLAG,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   358
                              EMIT_RANGE_CHECK,
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   359
                              IGNORE_CONSTRAINT));
31371
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   360
#endif // INCLUDE_ALL_GCS
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   361
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   362
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   363
CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   364
  CommandLineFlagRange* found = NULL;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   365
  for (int i=0; i<length(); i++) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   366
    CommandLineFlagRange* range = at(i);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   367
    if (strcmp(range->name(), name) == 0) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   368
      found = range;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   369
      break;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   370
    }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   371
  }
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   372
  return found;
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   373
}
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   374
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   375
void CommandLineFlagRangeList::print(const char* name, outputStream* st, bool unspecified) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   376
  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   377
  if (range != NULL) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   378
    range->print(st);
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   379
  } else if (unspecified == true) {
311143309e73 8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff changeset
   380
    st->print("[                           ...                           ]");
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
}
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   383
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   384
bool CommandLineFlagRangeList::check_ranges() {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   385
  // Check ranges.
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   386
  bool status = true;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   387
  for (int i=0; i<length(); i++) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   388
    CommandLineFlagRange* range = at(i);
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   389
    const char* name = range->name();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   390
    Flag* flag = Flag::find_flag(name, strlen(name), true, true);
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   391
    // 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
   392
    // can generate range check (despite that they are declared as constants),
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   393
    // but they will not be returned by Flag::find_flag()
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   394
    if (flag != NULL) {
32351
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   395
      if (flag->is_int()) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   396
        int value = flag->get_int();
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   397
        if (range->check_int(value, true) != Flag::SUCCESS) status = false;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   398
      } else if (flag->is_uint()) {
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   399
        uint value = flag->get_uint();
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   400
        if (range->check_uint(value, true) != Flag::SUCCESS) status = false;
1da9b960b3d4 8112746: Followup to JDK-8059557 (JEP 245)
gziemski
parents: 31995
diff changeset
   401
      } else if (flag->is_intx()) {
31995
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   402
        intx value = flag->get_intx();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   403
        if (range->check_intx(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   404
      } else if (flag->is_uintx()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   405
        uintx value = flag->get_uintx();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   406
        if (range->check_uintx(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   407
      } else if (flag->is_uint64_t()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   408
        uint64_t value = flag->get_uint64_t();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   409
        if (range->check_uint64_t(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   410
      } else if (flag->is_size_t()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   411
        size_t value = flag->get_size_t();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   412
        if (range->check_size_t(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   413
      } else if (flag->is_double()) {
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   414
        double value = flag->get_double();
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   415
        if (range->check_double(value, true) != Flag::SUCCESS) status = false;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   416
      }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   417
    }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   418
  }
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   419
  return status;
aa4049b4184a 8130459: Add additional validation after heap creation
sangheki
parents: 31592
diff changeset
   420
}