author | sangheki |
Fri, 04 Dec 2015 15:24:14 -0800 | |
changeset 34661 | 9a1d11d88ea0 |
parent 34242 | e530decd7c63 |
child 36574 | adf1e92565a3 |
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" |
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 | 36 |
void CommandLineError::print(bool verbose, const char* msg, ...) { |
37 |
if (verbose) { |
|
38 |
va_list listPointer; |
|
39 |
va_start(listPointer, msg); |
|
40 |
jio_vfprintf(defaultStream::error_stream(), msg, listPointer); |
|
41 |
va_end(listPointer); |
|
42 |
} |
|
43 |
} |
|
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 | 57 |
CommandLineError::print(verbose, |
58 |
"int %s=%d is outside the allowed range " |
|
59 |
"[ %d ... %d ]\n", |
|
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 | 84 |
CommandLineError::print(verbose, |
85 |
"intx %s=" INTX_FORMAT " is outside the allowed range " |
|
86 |
"[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n", |
|
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 | 111 |
CommandLineError::print(verbose, |
112 |
"uint %s=%u is outside the allowed range " |
|
113 |
"[ %u ... %u ]\n", |
|
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 | 138 |
CommandLineError::print(verbose, |
139 |
"uintx %s=" UINTX_FORMAT " is outside the allowed range " |
|
140 |
"[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n", |
|
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 | 165 |
CommandLineError::print(verbose, |
166 |
"uint64_t %s=" UINT64_FORMAT " is outside the allowed range " |
|
167 |
"[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n", |
|
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 | 192 |
CommandLineError::print(verbose, |
193 |
"size_t %s=" SIZE_FORMAT " is outside the allowed range " |
|
194 |
"[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n", |
|
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 | 219 |
CommandLineError::print(verbose, |
220 |
"double %s=%f is outside the allowed range " |
|
221 |
"[ %f ... %f ]\n", |
|
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 |
} |
34661
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
253 |
void emit_range_uint(const char* name, uint min, uint max) { |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
254 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_uint(name, min, max)); |
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
255 |
} |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
256 |
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
|
257 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(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_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
|
260 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_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_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
|
263 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(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 |
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
|
266 |
CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, min, max)); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
267 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
268 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
269 |
// Generate code to call emit_range_xxx function |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
270 |
#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
|
271 |
#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
|
272 |
#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
|
273 |
#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
|
274 |
#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
|
275 |
#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
|
276 |
#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
|
277 |
#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
|
278 |
#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
|
279 |
#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
|
280 |
#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
|
281 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
282 |
// Generate func argument to pass into emit_range_xxx functions |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
283 |
#define EMIT_RANGE_CHECK(a, b) , a, b |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
284 |
|
34661
9a1d11d88ea0
8142341: GC: current flags need ranges to be implemented
sangheki
parents:
34242
diff
changeset
|
285 |
#define INITIAL_RANGES_SIZE 379 |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
286 |
GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL; |
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 |
// Check the ranges of all flags that have them |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
289 |
void CommandLineFlagRangeList::init(void) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
290 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
291 |
_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
|
292 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
293 |
emit_range_no(NULL RUNTIME_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
294 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
295 |
EMIT_RANGE_PRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
296 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
297 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
298 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
299 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
300 |
EMIT_RANGE_MANAGEABLE_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
301 |
EMIT_RANGE_PRODUCT_RW_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
302 |
EMIT_RANGE_LP64_PRODUCT_FLAG, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
303 |
EMIT_RANGE_CHECK, |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
304 |
IGNORE_CONSTRAINT) ); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
305 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
306 |
EMIT_RANGES_FOR_GLOBALS_EXT |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
307 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
308 |
emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 309 |
EMIT_RANGE_PRODUCT_FLAG, |
310 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
311 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
|
312 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
313 |
EMIT_RANGE_CHECK, |
|
314 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
315 |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
316 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
317 |
emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
318 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
319 |
EMIT_RANGE_PRODUCT_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
320 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
321 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
322 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
323 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
324 |
EMIT_RANGE_CHECK, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
325 |
IGNORE_CONSTRAINT)); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
326 |
#endif // INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32613
diff
changeset
|
327 |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
328 |
#ifdef COMPILER1 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
329 |
emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 330 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
331 |
EMIT_RANGE_PRODUCT_FLAG, |
|
332 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
|
333 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
334 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
335 |
EMIT_RANGE_CHECK, |
|
336 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
337 |
#endif // COMPILER1 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
338 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
339 |
#ifdef COMPILER2 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
340 |
emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 341 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
342 |
EMIT_RANGE_PRODUCT_FLAG, |
|
343 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
|
344 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
345 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
|
346 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
347 |
EMIT_RANGE_CHECK, |
|
348 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
349 |
#endif // COMPILER2 |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
350 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
351 |
#if INCLUDE_ALL_GCS |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
352 |
emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, |
32351 | 353 |
EMIT_RANGE_PD_DEVELOPER_FLAG, |
354 |
EMIT_RANGE_PRODUCT_FLAG, |
|
355 |
EMIT_RANGE_PD_PRODUCT_FLAG, |
|
356 |
EMIT_RANGE_DIAGNOSTIC_FLAG, |
|
357 |
EMIT_RANGE_EXPERIMENTAL_FLAG, |
|
358 |
EMIT_RANGE_NOTPRODUCT_FLAG, |
|
359 |
EMIT_RANGE_MANAGEABLE_FLAG, |
|
360 |
EMIT_RANGE_PRODUCT_RW_FLAG, |
|
361 |
EMIT_RANGE_CHECK, |
|
362 |
IGNORE_CONSTRAINT)); |
|
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
363 |
#endif // INCLUDE_ALL_GCS |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
364 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
365 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
366 |
CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
367 |
CommandLineFlagRange* found = NULL; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
368 |
for (int i=0; i<length(); i++) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
369 |
CommandLineFlagRange* range = at(i); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
370 |
if (strcmp(range->name(), name) == 0) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
371 |
found = range; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
372 |
break; |
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 |
return found; |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
376 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
377 |
|
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
378 |
void CommandLineFlagRangeList::print(const char* name, outputStream* st, bool unspecified) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
379 |
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
380 |
if (range != NULL) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
381 |
range->print(st); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
382 |
} else if (unspecified == true) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
383 |
st->print("[ ... ]"); |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
384 |
} |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
diff
changeset
|
385 |
} |
31995
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
386 |
|
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
387 |
bool CommandLineFlagRangeList::check_ranges() { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
388 |
// Check ranges. |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
389 |
bool status = true; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
390 |
for (int i=0; i<length(); i++) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
391 |
CommandLineFlagRange* range = at(i); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
392 |
const char* name = range->name(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
393 |
Flag* flag = Flag::find_flag(name, strlen(name), true, true); |
32351 | 394 |
// We must check for NULL here as lp64_product flags on 32 bit architecture |
395 |
// can generate range check (despite that they are declared as constants), |
|
396 |
// but they will not be returned by Flag::find_flag() |
|
31995
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
397 |
if (flag != NULL) { |
32351 | 398 |
if (flag->is_int()) { |
399 |
int value = flag->get_int(); |
|
400 |
if (range->check_int(value, true) != Flag::SUCCESS) status = false; |
|
401 |
} else if (flag->is_uint()) { |
|
402 |
uint value = flag->get_uint(); |
|
403 |
if (range->check_uint(value, true) != Flag::SUCCESS) status = false; |
|
404 |
} else if (flag->is_intx()) { |
|
31995
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
405 |
intx value = flag->get_intx(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
406 |
if (range->check_intx(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
407 |
} else if (flag->is_uintx()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
408 |
uintx value = flag->get_uintx(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
409 |
if (range->check_uintx(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
410 |
} else if (flag->is_uint64_t()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
411 |
uint64_t value = flag->get_uint64_t(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
412 |
if (range->check_uint64_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_size_t()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
414 |
size_t value = flag->get_size_t(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
415 |
if (range->check_size_t(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
416 |
} else if (flag->is_double()) { |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
417 |
double value = flag->get_double(); |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
418 |
if (range->check_double(value, true) != Flag::SUCCESS) status = false; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
419 |
} |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
420 |
} |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
421 |
} |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
422 |
return status; |
aa4049b4184a
8130459: Add additional validation after heap creation
sangheki
parents:
31592
diff
changeset
|
423 |
} |