author | david |
Tue, 29 Sep 2015 11:02:08 +0200 | |
changeset 33105 | 294e48b4f704 |
parent 32613 | 73bec9f941d7 |
child 33144 | c56850e328fc |
child 33160 | c59f1676d27e |
permissions | -rw-r--r-- |
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" |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
32 |
#include "utilities/defaultStream.hpp" |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
33 |
#include "utilities/macros.hpp" |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
34 |
|
32351 | 35 |
void CommandLineError::print(bool verbose, const char* msg, ...) { |
36 |
if (verbose) { |
|
37 |
va_list listPointer; |
|
38 |
va_start(listPointer, msg); |
|
39 |
jio_vfprintf(defaultStream::error_stream(), msg, listPointer); |
|
40 |
va_end(listPointer); |
|
41 |
} |
|
42 |
} |
|
43 |
||
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
44 |
class CommandLineFlagRange_int : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
45 |
int _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
46 |
int _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
47 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
48 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
49 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
50 |
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
|
51 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
52 |
} |
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 |
Flag::Error check_int(int value, bool verbose = true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
55 |
if ((value < _min) || (value > _max)) { |
32351 | 56 |
CommandLineError::print(verbose, |
57 |
"int %s=%d is outside the allowed range " |
|
58 |
"[ %d ... %d ]\n", |
|
59 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
60 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
61 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
62 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
63 |
} |
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 |
void print(outputStream* st) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
67 |
st->print("[ %-25d ... %25d ]", _min, _max); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
68 |
} |
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 |
class CommandLineFlagRange_intx : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
72 |
intx _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
73 |
intx _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
74 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
75 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
76 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
77 |
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
|
78 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
79 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
80 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
81 |
Flag::Error check_intx(intx value, bool verbose = true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
82 |
if ((value < _min) || (value > _max)) { |
32351 | 83 |
CommandLineError::print(verbose, |
84 |
"intx %s=" INTX_FORMAT " is outside the allowed range " |
|
85 |
"[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n", |
|
86 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
87 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
88 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
89 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
90 |
} |
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 |
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
|
94 |
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
|
95 |
} |
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 |
class CommandLineFlagRange_uint : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
99 |
uint _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
100 |
uint _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
101 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
102 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
103 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
104 |
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
|
105 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
106 |
} |
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 |
Flag::Error check_uint(uint value, bool verbose = true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
109 |
if ((value < _min) || (value > _max)) { |
32351 | 110 |
CommandLineError::print(verbose, |
111 |
"uint %s=%u is outside the allowed range " |
|
112 |
"[ %u ... %u ]\n", |
|
113 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
114 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
115 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
116 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
117 |
} |
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 |
void print(outputStream* st) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
121 |
st->print("[ %-25u ... %25u ]", _min, _max); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
122 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
123 |
}; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
124 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
125 |
class CommandLineFlagRange_uintx : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
126 |
uintx _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
127 |
uintx _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
128 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
129 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
130 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
131 |
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
|
132 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
133 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
134 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
135 |
Flag::Error check_uintx(uintx value, bool verbose = true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
136 |
if ((value < _min) || (value > _max)) { |
32351 | 137 |
CommandLineError::print(verbose, |
138 |
"uintx %s=" UINTX_FORMAT " is outside the allowed range " |
|
139 |
"[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n", |
|
140 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
141 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
142 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
143 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
144 |
} |
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 |
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
|
148 |
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
|
149 |
} |
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 |
class CommandLineFlagRange_uint64_t : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
153 |
uint64_t _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
154 |
uint64_t _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
155 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
156 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
157 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
158 |
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
|
159 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
160 |
} |
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 |
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
|
163 |
if ((value < _min) || (value > _max)) { |
32351 | 164 |
CommandLineError::print(verbose, |
165 |
"uint64_t %s=" UINT64_FORMAT " is outside the allowed range " |
|
166 |
"[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n", |
|
167 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
168 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
169 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
170 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
171 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
172 |
} |
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 |
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
|
175 |
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
|
176 |
} |
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 |
class CommandLineFlagRange_size_t : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
180 |
size_t _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
181 |
size_t _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
182 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
183 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
184 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
185 |
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
|
186 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
187 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
188 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
189 |
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
|
190 |
if ((value < _min) || (value > _max)) { |
32351 | 191 |
CommandLineError::print(verbose, |
192 |
"size_t %s=" SIZE_FORMAT " is outside the allowed range " |
|
193 |
"[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n", |
|
194 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
195 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
196 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
197 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
198 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
199 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
200 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
201 |
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
|
202 |
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
|
203 |
} |
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 |
class CommandLineFlagRange_double : public CommandLineFlagRange { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
207 |
double _min; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
208 |
double _max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
209 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
210 |
public: |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
211 |
// the "name" argument must be a string literal |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
212 |
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
|
213 |
_min=min, _max=max; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
214 |
} |
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 |
Flag::Error check_double(double value, bool verbose = true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
217 |
if ((value < _min) || (value > _max)) { |
32351 | 218 |
CommandLineError::print(verbose, |
219 |
"double %s=%f is outside the allowed range " |
|
220 |
"[ %f ... %f ]\n", |
|
221 |
name(), value, _min, _max); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
222 |
return Flag::OUT_OF_BOUNDS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
223 |
} else { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
224 |
return Flag::SUCCESS; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
225 |
} |
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 |
void print(outputStream* st) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
229 |
st->print("[ %-25.3f ... %25.3f ]", _min, _max); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
230 |
} |
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 |
// No constraint emitting |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
234 |
void emit_range_no(...) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
235 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
236 |
// No constraint emitting if function argument is NOT provided |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
237 |
void emit_range_bool(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
238 |
void emit_range_ccstr(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
239 |
void emit_range_ccstrlist(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
240 |
void emit_range_int(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
241 |
void emit_range_intx(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
242 |
void emit_range_uint(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
243 |
void emit_range_uintx(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
244 |
void emit_range_uint64_t(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
245 |
void emit_range_size_t(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
246 |
void emit_range_double(const char* /*name*/) { /* NOP */ } |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
247 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
248 |
// CommandLineFlagRange emitting code functions if range arguments are provided |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
249 |
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
|
250 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, min, max)); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
251 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
252 |
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
|
253 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, min, max)); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
254 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
255 |
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
|
256 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, min, max)); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
257 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
258 |
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
|
259 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, min, max)); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
260 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
261 |
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
|
262 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, min, max)); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
263 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
264 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
265 |
// Generate code to call emit_range_xxx function |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
266 |
#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
|
267 |
#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
|
268 |
#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
|
269 |
#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
|
270 |
#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
|
271 |
#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
|
272 |
#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
|
273 |
#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
|
274 |
#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
|
275 |
#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
|
276 |
#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
|
277 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
278 |
// Generate func argument to pass into emit_range_xxx functions |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
279 |
#define EMIT_RANGE_CHECK(a, b) , a, b |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
280 |
|
32613
73bec9f941d7
8134972: [BACKOUT] GC: implement ranges (optionally constraints) for those flags that have them missing
sangheki
parents:
32601
diff
changeset
|
281 |
#define INITIAL_RANGES_SIZE 128 |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
282 |
GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
283 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
284 |
// Check the ranges of all flags that have them |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
285 |
void CommandLineFlagRangeList::init(void) { |
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 |
_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
|
288 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
289 |
emit_range_no(NULL RUNTIME_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
290 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
291 |
EMIT_RANGE_PRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
292 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
293 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
294 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
295 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
296 |
EMIT_RANGE_MANAGEABLE_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
297 |
EMIT_RANGE_PRODUCT_RW_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
298 |
EMIT_RANGE_LP64_PRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
299 |
EMIT_RANGE_CHECK, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
300 |
IGNORE_CONSTRAINT) ); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
301 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
302 |
EMIT_RANGES_FOR_GLOBALS_EXT |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
303 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
304 |
emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 305 |
EMIT_RANGE_PRODUCT_FLAG, |
306 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
307 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
|
308 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
309 |
EMIT_RANGE_CHECK, |
|
310 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
311 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
312 |
#ifdef COMPILER1 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
313 |
emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 314 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
315 |
EMIT_RANGE_PRODUCT_FLAG, |
|
316 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
|
317 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
318 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
319 |
EMIT_RANGE_CHECK, |
|
320 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
321 |
#endif // COMPILER1 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
322 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
323 |
#ifdef COMPILER2 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
324 |
emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 325 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
326 |
EMIT_RANGE_PRODUCT_FLAG, |
|
327 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
|
328 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
329 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
|
330 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
331 |
EMIT_RANGE_CHECK, |
|
332 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
333 |
#endif // COMPILER2 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
334 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
335 |
#if INCLUDE_ALL_GCS |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
336 |
emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 337 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
338 |
EMIT_RANGE_PRODUCT_FLAG, |
|
339 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
|
340 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
341 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
|
342 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
343 |
EMIT_RANGE_MANAGEABLE_FLAG, |
|
344 |
EMIT_RANGE_PRODUCT_RW_FLAG, |
|
345 |
EMIT_RANGE_CHECK, |
|
346 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
347 |
#endif // INCLUDE_ALL_GCS |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
348 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
349 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
350 |
CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
351 |
CommandLineFlagRange* found = NULL; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
352 |
for (int i=0; i<length(); i++) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
353 |
CommandLineFlagRange* range = at(i); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
354 |
if (strcmp(range->name(), name) == 0) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
355 |
found = range; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
356 |
break; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
357 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
358 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
359 |
return found; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
360 |
} |
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 |
void CommandLineFlagRangeList::print(const char* name, outputStream* st, bool unspecified) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
363 |
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
364 |
if (range != NULL) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
365 |
range->print(st); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
366 |
} else if (unspecified == true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
367 |
st->print("[ ... ]"); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
368 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
369 |
} |
31995
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
370 |
|
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
371 |
bool CommandLineFlagRangeList::check_ranges() { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
372 |
// Check ranges. |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
373 |
bool status = true; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
374 |
for (int i=0; i<length(); i++) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
375 |
CommandLineFlagRange* range = at(i); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
376 |
const char* name = range->name(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
377 |
Flag* flag = Flag::find_flag(name, strlen(name), true, true); |
32351 | 378 |
// We must check for NULL here as lp64_product flags on 32 bit architecture |
379 |
// can generate range check (despite that they are declared as constants), |
|
380 |
// but they will not be returned by Flag::find_flag() |
|
31995
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
381 |
if (flag != NULL) { |
32351 | 382 |
if (flag->is_int()) { |
383 |
int value = flag->get_int(); |
|
384 |
if (range->check_int(value, true) != Flag::SUCCESS) status = false; |
|
385 |
} else if (flag->is_uint()) { |
|
386 |
uint value = flag->get_uint(); |
|
387 |
if (range->check_uint(value, true) != Flag::SUCCESS) status = false; |
|
388 |
} else if (flag->is_intx()) { |
|
31995
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
389 |
intx value = flag->get_intx(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
390 |
if (range->check_intx(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
391 |
} else if (flag->is_uintx()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
392 |
uintx value = flag->get_uintx(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
393 |
if (range->check_uintx(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
394 |
} else if (flag->is_uint64_t()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
395 |
uint64_t value = flag->get_uint64_t(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
396 |
if (range->check_uint64_t(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
397 |
} else if (flag->is_size_t()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
398 |
size_t value = flag->get_size_t(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
399 |
if (range->check_size_t(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
400 |
} else if (flag->is_double()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
401 |
double value = flag->get_double(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
402 |
if (range->check_double(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
403 |
} |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
404 |
} |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
405 |
} |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
406 |
return status; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
407 |
} |