11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "gc/shared/referenceProcessor.hpp"
29 #include "runtime/arguments.hpp"
30 #include "runtime/commandLineFlagRangeList.hpp"
31 #include "runtime/os_ext.hpp"
32 #include "utilities/defaultStream.hpp"
33 #include "utilities/macros.hpp"
34
35 class CommandLineFlagRange_int : public CommandLineFlagRange {
36 int _min;
37 int _max;
38
39 public:
40 CommandLineFlagRange_int(const char* name, int min, int max) : CommandLineFlagRange(name) {
41 _min=min, _max=max;
42 }
43
44 Flag::Error check_int(int value, bool verbose = true) {
45 if ((value < _min) || (value > _max)) {
46 if (verbose == true) {
47 jio_fprintf(defaultStream::error_stream(),
48 "intx %s=%d is outside the allowed range [ %d ... %d ]\n",
49 _name, value, _min, _max);
50 }
51 return Flag::OUT_OF_BOUNDS;
52 } else {
53 return Flag::SUCCESS;
54 }
55 }
56
57 void print(outputStream* st) {
58 st->print("[ %25d ... %25d ]", _min, _max);
59 }
60 };
61
62 class CommandLineFlagRange_intx : public CommandLineFlagRange {
63 intx _min;
64 intx _max;
65
66 public:
67 CommandLineFlagRange_intx(const char* name, intx min, intx max) : CommandLineFlagRange(name) {
68 _min=min, _max=max;
69 }
70
71 Flag::Error check_intx(intx value, bool verbose = true) {
72 if ((value < _min) || (value > _max)) {
73 if (verbose == true) {
74 jio_fprintf(defaultStream::error_stream(),
75 "intx %s="INTX_FORMAT" is outside the allowed range [ "INTX_FORMAT" ... "INTX_FORMAT" ]\n",
76 _name, value, _min, _max);
77 }
78 return Flag::OUT_OF_BOUNDS;
79 } else {
80 return Flag::SUCCESS;
81 }
82 }
83
84 void print(outputStream* st) {
85 st->print("[ "INTX_FORMAT_W(-25)" ... "INTX_FORMAT_W(25)" ]", _min, _max);
86 }
87 };
88
89 class CommandLineFlagRange_uint : public CommandLineFlagRange {
90 uint _min;
91 uint _max;
92
93 public:
94 CommandLineFlagRange_uint(const char* name, uint min, uint max) : CommandLineFlagRange(name) {
95 _min=min, _max=max;
96 }
97
98 Flag::Error check_uint(uint value, bool verbose = true) {
99 if ((value < _min) || (value > _max)) {
100 if (verbose == true) {
101 jio_fprintf(defaultStream::error_stream(),
102 "uintx %s=%u is outside the allowed range [ %u ... %u ]\n",
103 _name, value, _min, _max);
104 }
105 return Flag::OUT_OF_BOUNDS;
106 } else {
107 return Flag::SUCCESS;
108 }
109 }
110
111 void print(outputStream* st) {
112 st->print("[ %25u ... %25u ]", _min, _max);
113 }
114 };
115
116 class CommandLineFlagRange_uintx : public CommandLineFlagRange {
117 uintx _min;
118 uintx _max;
119
120 public:
121 CommandLineFlagRange_uintx(const char* name, uintx min, uintx max) : CommandLineFlagRange(name) {
122 _min=min, _max=max;
123 }
124
125 Flag::Error check_uintx(uintx value, bool verbose = true) {
126 if ((value < _min) || (value > _max)) {
127 if (verbose == true) {
128 jio_fprintf(defaultStream::error_stream(),
129 "uintx %s="UINTX_FORMAT" is outside the allowed range [ "UINTX_FORMAT" ... "UINTX_FORMAT" ]\n",
130 _name, value, _min, _max);
131 }
132 return Flag::OUT_OF_BOUNDS;
133 } else {
134 return Flag::SUCCESS;
135 }
136 }
137
138 void print(outputStream* st) {
139 st->print("[ "UINTX_FORMAT_W(-25)" ... "UINTX_FORMAT_W(25)" ]", _min, _max);
140 }
141 };
142
143 class CommandLineFlagRange_uint64_t : public CommandLineFlagRange {
144 uint64_t _min;
145 uint64_t _max;
146
147 public:
148 CommandLineFlagRange_uint64_t(const char* name, uint64_t min, uint64_t max) : CommandLineFlagRange(name) {
149 _min=min, _max=max;
150 }
151
152 Flag::Error check_uint64_t(uint64_t value, bool verbose = true) {
153 if ((value < _min) || (value > _max)) {
154 if (verbose == true) {
155 jio_fprintf(defaultStream::error_stream(),
156 "uint64_t %s="UINT64_FORMAT" is outside the allowed range [ "UINT64_FORMAT" ... "UINT64_FORMAT" ]\n",
157 _name, value, _min, _max);
158 }
159 return Flag::OUT_OF_BOUNDS;
160 } else {
161 return Flag::SUCCESS;
162 }
163 }
164
165 void print(outputStream* st) {
166 st->print("[ "UINT64_FORMAT_W(-25)" ... "UINT64_FORMAT_W(25)" ]", _min, _max);
167 }
168 };
169
170 class CommandLineFlagRange_size_t : public CommandLineFlagRange {
171 size_t _min;
172 size_t _max;
173
174 public:
175 CommandLineFlagRange_size_t(const char* name, size_t min, size_t max) : CommandLineFlagRange(name) {
176 _min=min, _max=max;
177 }
178
179 Flag::Error check_size_t(size_t value, bool verbose = true) {
180 if ((value < _min) || (value > _max)) {
181 if (verbose == true) {
182 jio_fprintf(defaultStream::error_stream(),
183 "size_t %s="SIZE_FORMAT" is outside the allowed range [ "SIZE_FORMAT" ... "SIZE_FORMAT" ]\n",
184 _name, value, _min, _max);
185 }
186 return Flag::OUT_OF_BOUNDS;
187 } else {
188 return Flag::SUCCESS;
189 }
190 }
191
192 void print(outputStream* st) {
193 st->print("[ "SIZE_FORMAT_W(-25)" ... "SIZE_FORMAT_W(25)" ]", _min, _max);
194 }
195 };
196
197 class CommandLineFlagRange_double : public CommandLineFlagRange {
198 double _min;
199 double _max;
200
201 public:
202 CommandLineFlagRange_double(const char* name, double min, double max) : CommandLineFlagRange(name) {
203 _min=min, _max=max;
204 }
205
206 Flag::Error check_double(double value, bool verbose = true) {
207 if ((value < _min) || (value > _max)) {
208 if (verbose == true) {
209 jio_fprintf(defaultStream::error_stream(),
210 "double %s=%f is outside the allowed range [ %f ... %f ]\n",
211 _name, value, _min, _max);
212 }
213 return Flag::OUT_OF_BOUNDS;
214 } else {
215 return Flag::SUCCESS;
216 }
217 }
218
219 void print(outputStream* st) {
220 st->print("[ %-25.3f ... %25.3f ]", _min, _max);
221 }
222 };
223
224 // No constraint emitting
225 void emit_range_no(...) { /* NOP */ }
226
227 // No constraint emitting if function argument is NOT provided
228 void emit_range_bool(const char* /*name*/) { /* NOP */ }
229 void emit_range_ccstr(const char* /*name*/) { /* NOP */ }
230 void emit_range_ccstrlist(const char* /*name*/) { /* NOP */ }
231 void emit_range_int(const char* /*name*/) { /* NOP */ }
232 void emit_range_intx(const char* /*name*/) { /* NOP */ }
233 void emit_range_uint(const char* /*name*/) { /* NOP */ }
234 void emit_range_uintx(const char* /*name*/) { /* NOP */ }
235 void emit_range_uint64_t(const char* /*name*/) { /* NOP */ }
236 void emit_range_size_t(const char* /*name*/) { /* NOP */ }
237 void emit_range_double(const char* /*name*/) { /* NOP */ }
238
239 // CommandLineFlagRange emitting code functions if function argument is provided
240 void emit_range_int(const char* name, int min, int max) {
241 CommandLineFlagRangeList::add(new CommandLineFlagRange_int(name, min, max));
242 }
243 void emit_range_intx(const char* name, intx min, intx max) {
244 CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, min, max));
245 }
246 void emit_range_uint(const char* name, uint min, uint max) {
247 CommandLineFlagRangeList::add(new CommandLineFlagRange_uint(name, min, max));
248 }
249 void emit_range_uintx(const char* name, uintx min, uintx max) {
250 CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, min, max));
251 }
252 void emit_range_uint64_t(const char* name, uint64_t min, uint64_t max) {
253 CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, min, max));
254 }
255 void emit_range_size_t(const char* name, size_t min, size_t max) {
256 CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, min, max));
257 }
258 void emit_range_double(const char* name, double min, double max) {
259 CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, min, max));
260 }
261
262 // Generate code to call emit_range_xxx function
263 #define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name
264 #define EMIT_RANGE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_range_##type(#name
265 #define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_range_##type(#name
266 #define EMIT_RANGE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_range_##type(#name
267 #define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_range_##type(#name
268 #define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_range_##type(#name
331
332 #if INCLUDE_ALL_GCS
333 emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
334 EMIT_RANGE_PD_DEVELOPER_FLAG,
335 EMIT_RANGE_PRODUCT_FLAG,
336 EMIT_RANGE_PD_PRODUCT_FLAG,
337 EMIT_RANGE_DIAGNOSTIC_FLAG,
338 EMIT_RANGE_EXPERIMENTAL_FLAG,
339 EMIT_RANGE_NOTPRODUCT_FLAG,
340 EMIT_RANGE_MANAGEABLE_FLAG,
341 EMIT_RANGE_PRODUCT_RW_FLAG,
342 EMIT_RANGE_CHECK,
343 IGNORE_CONSTRAINT));
344 #endif // INCLUDE_ALL_GCS
345 }
346
347 CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) {
348 CommandLineFlagRange* found = NULL;
349 for (int i=0; i<length(); i++) {
350 CommandLineFlagRange* range = at(i);
351 if (strcmp(range->_name, name) == 0) {
352 found = range;
353 break;
354 }
355 }
356 return found;
357 }
358
359 void CommandLineFlagRangeList::print(const char* name, outputStream* st, bool unspecified) {
360 CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
361 if (range != NULL) {
362 range->print(st);
363 } else if (unspecified == true) {
364 st->print("[ ... ]");
365 }
366 }
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "gc/shared/referenceProcessor.hpp"
29 #include "runtime/arguments.hpp"
30 #include "runtime/commandLineFlagRangeList.hpp"
31 #include "runtime/os.hpp"
32 #include "utilities/defaultStream.hpp"
33 #include "utilities/macros.hpp"
34
35 class CommandLineFlagRange_int : public CommandLineFlagRange {
36 int _min;
37 int _max;
38
39 public:
40 // the "name" argument must be a string literal
41 CommandLineFlagRange_int(const char* name, int min, int max) : CommandLineFlagRange(name) {
42 _min=min, _max=max;
43 }
44
45 Flag::Error check_int(int value, bool verbose = true) {
46 if ((value < _min) || (value > _max)) {
47 if (verbose == true) {
48 jio_fprintf(defaultStream::error_stream(),
49 "int %s=%d is outside the allowed range [ %d ... D ]\n",
50 name(), value, _min, _max);
51 }
52 return Flag::OUT_OF_BOUNDS;
53 } else {
54 return Flag::SUCCESS;
55 }
56 }
57
58 void print(outputStream* st) {
59 st->print("[ %-25d ... %25d ]", _min, _max);
60 }
61 };
62
63 class CommandLineFlagRange_intx : public CommandLineFlagRange {
64 intx _min;
65 intx _max;
66
67 public:
68 // the "name" argument must be a string literal
69 CommandLineFlagRange_intx(const char* name, intx min, intx max) : CommandLineFlagRange(name) {
70 _min=min, _max=max;
71 }
72
73 Flag::Error check_intx(intx value, bool verbose = true) {
74 if ((value < _min) || (value > _max)) {
75 if (verbose == true) {
76 jio_fprintf(defaultStream::error_stream(),
77 "intx %s=" INTX_FORMAT " is outside the allowed range [ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
78 name(), value, _min, _max);
79 }
80 return Flag::OUT_OF_BOUNDS;
81 } else {
82 return Flag::SUCCESS;
83 }
84 }
85
86 void print(outputStream* st) {
87 st->print("[ "INTX_FORMAT_W(-25)" ... "INTX_FORMAT_W(25)" ]", _min, _max);
88 }
89 };
90
91 class CommandLineFlagRange_uint : public CommandLineFlagRange {
92 uint _min;
93 uint _max;
94
95 public:
96 // the "name" argument must be a string literal
97 CommandLineFlagRange_uint(const char* name, uint min, uint max) : CommandLineFlagRange(name) {
98 _min=min, _max=max;
99 }
100
101 Flag::Error check_uint(uint value, bool verbose = true) {
102 if ((value < _min) || (value > _max)) {
103 if (verbose == true) {
104 jio_fprintf(defaultStream::error_stream(),
105 "uintx %s=%u is outside the allowed range [ %u ... %u ]\n",
106 name(), value, _min, _max);
107 }
108 return Flag::OUT_OF_BOUNDS;
109 } else {
110 return Flag::SUCCESS;
111 }
112 }
113
114 void print(outputStream* st) {
115 st->print("[ %-25u ... %25u ]", _min, _max);
116 }
117 };
118
119 class CommandLineFlagRange_uintx : public CommandLineFlagRange {
120 uintx _min;
121 uintx _max;
122
123 public:
124 // the "name" argument must be a string literal
125 CommandLineFlagRange_uintx(const char* name, uintx min, uintx max) : CommandLineFlagRange(name) {
126 _min=min, _max=max;
127 }
128
129 Flag::Error check_uintx(uintx value, bool verbose = true) {
130 if ((value < _min) || (value > _max)) {
131 if (verbose == true) {
132 jio_fprintf(defaultStream::error_stream(),
133 "uintx %s=" UINTX_FORMAT " is outside the allowed range [ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
134 name(), value, _min, _max);
135 }
136 return Flag::OUT_OF_BOUNDS;
137 } else {
138 return Flag::SUCCESS;
139 }
140 }
141
142 void print(outputStream* st) {
143 st->print("[ "UINTX_FORMAT_W(-25)" ... "UINTX_FORMAT_W(25)" ]", _min, _max);
144 }
145 };
146
147 class CommandLineFlagRange_uint64_t : public CommandLineFlagRange {
148 uint64_t _min;
149 uint64_t _max;
150
151 public:
152 // the "name" argument must be a string literal
153 CommandLineFlagRange_uint64_t(const char* name, uint64_t min, uint64_t max) : CommandLineFlagRange(name) {
154 _min=min, _max=max;
155 }
156
157 Flag::Error check_uint64_t(uint64_t value, bool verbose = true) {
158 if ((value < _min) || (value > _max)) {
159 if (verbose == true) {
160 jio_fprintf(defaultStream::error_stream(),
161 "uint64_t %s=" UINT64_FORMAT " is outside the allowed range [ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
162 name(), value, _min, _max);
163 }
164 return Flag::OUT_OF_BOUNDS;
165 } else {
166 return Flag::SUCCESS;
167 }
168 }
169
170 void print(outputStream* st) {
171 st->print("[ "UINT64_FORMAT_W(-25)" ... "UINT64_FORMAT_W(25)" ]", _min, _max);
172 }
173 };
174
175 class CommandLineFlagRange_size_t : public CommandLineFlagRange {
176 size_t _min;
177 size_t _max;
178
179 public:
180 // the "name" argument must be a string literal
181 CommandLineFlagRange_size_t(const char* name, size_t min, size_t max) : CommandLineFlagRange(name) {
182 _min=min, _max=max;
183 }
184
185 Flag::Error check_size_t(size_t value, bool verbose = true) {
186 if ((value < _min) || (value > _max)) {
187 if (verbose == true) {
188 jio_fprintf(defaultStream::error_stream(),
189 "size_t %s=" SIZE_FORMAT " is outside the allowed range [ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
190 name(), value, _min, _max);
191 }
192 return Flag::OUT_OF_BOUNDS;
193 } else {
194 return Flag::SUCCESS;
195 }
196 }
197
198 void print(outputStream* st) {
199 st->print("[ "SIZE_FORMAT_W(-25)" ... "SIZE_FORMAT_W(25)" ]", _min, _max);
200 }
201 };
202
203 class CommandLineFlagRange_double : public CommandLineFlagRange {
204 double _min;
205 double _max;
206
207 public:
208 // the "name" argument must be a string literal
209 CommandLineFlagRange_double(const char* name, double min, double max) : CommandLineFlagRange(name) {
210 _min=min, _max=max;
211 }
212
213 Flag::Error check_double(double value, bool verbose = true) {
214 if ((value < _min) || (value > _max)) {
215 if (verbose == true) {
216 jio_fprintf(defaultStream::error_stream(),
217 "double %s=%f is outside the allowed range [ %f ... %f ]\n",
218 name(), value, _min, _max);
219 }
220 return Flag::OUT_OF_BOUNDS;
221 } else {
222 return Flag::SUCCESS;
223 }
224 }
225
226 void print(outputStream* st) {
227 st->print("[ %-25.3f ... %25.3f ]", _min, _max);
228 }
229 };
230
231 // No constraint emitting
232 void emit_range_no(...) { /* NOP */ }
233
234 // No constraint emitting if function argument is NOT provided
235 void emit_range_bool(const char* /*name*/) { /* NOP */ }
236 void emit_range_ccstr(const char* /*name*/) { /* NOP */ }
237 void emit_range_ccstrlist(const char* /*name*/) { /* NOP */ }
238 void emit_range_int(const char* /*name*/) { /* NOP */ }
239 void emit_range_intx(const char* /*name*/) { /* NOP */ }
240 void emit_range_uint(const char* /*name*/) { /* NOP */ }
241 void emit_range_uintx(const char* /*name*/) { /* NOP */ }
242 void emit_range_uint64_t(const char* /*name*/) { /* NOP */ }
243 void emit_range_size_t(const char* /*name*/) { /* NOP */ }
244 void emit_range_double(const char* /*name*/) { /* NOP */ }
245
246 // CommandLineFlagRange emitting code functions if range arguments are provided
247 void emit_range_intx(const char* name, intx min, intx max) {
248 CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, min, max));
249 }
250 void emit_range_uintx(const char* name, uintx min, uintx max) {
251 CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, min, max));
252 }
253 void emit_range_uint64_t(const char* name, uint64_t min, uint64_t max) {
254 CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, min, max));
255 }
256 void emit_range_size_t(const char* name, size_t min, size_t max) {
257 CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, min, max));
258 }
259 void emit_range_double(const char* name, double min, double max) {
260 CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, min, max));
261 }
262
263 // Generate code to call emit_range_xxx function
264 #define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name
265 #define EMIT_RANGE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_range_##type(#name
266 #define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_range_##type(#name
267 #define EMIT_RANGE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_range_##type(#name
268 #define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_range_##type(#name
269 #define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_range_##type(#name
332
333 #if INCLUDE_ALL_GCS
334 emit_range_no(NULL G1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
335 EMIT_RANGE_PD_DEVELOPER_FLAG,
336 EMIT_RANGE_PRODUCT_FLAG,
337 EMIT_RANGE_PD_PRODUCT_FLAG,
338 EMIT_RANGE_DIAGNOSTIC_FLAG,
339 EMIT_RANGE_EXPERIMENTAL_FLAG,
340 EMIT_RANGE_NOTPRODUCT_FLAG,
341 EMIT_RANGE_MANAGEABLE_FLAG,
342 EMIT_RANGE_PRODUCT_RW_FLAG,
343 EMIT_RANGE_CHECK,
344 IGNORE_CONSTRAINT));
345 #endif // INCLUDE_ALL_GCS
346 }
347
348 CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) {
349 CommandLineFlagRange* found = NULL;
350 for (int i=0; i<length(); i++) {
351 CommandLineFlagRange* range = at(i);
352 if (strcmp(range->name(), name) == 0) {
353 found = range;
354 break;
355 }
356 }
357 return found;
358 }
359
360 void CommandLineFlagRangeList::print(const char* name, outputStream* st, bool unspecified) {
361 CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
362 if (range != NULL) {
363 range->print(st);
364 } else if (unspecified == true) {
365 st->print("[ ... ]");
366 }
367 }
|