src/share/vm/runtime/globals.cpp

Thu, 26 Sep 2013 12:07:53 -0700

author
twisti
date
Thu, 26 Sep 2013 12:07:53 -0700
changeset 5790
72b7e96c1922
parent 5628
f98f5d48f511
child 6123
396564992823
permissions
-rw-r--r--

8024545: make develop and notproduct flag values available in product builds
Reviewed-by: dholmes, kvn

duke@435 1 /*
kmo@4586 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "memory/allocation.inline.hpp"
stefank@2314 27 #include "oops/oop.inline.hpp"
stefank@2314 28 #include "runtime/arguments.hpp"
stefank@2314 29 #include "runtime/globals.hpp"
stefank@2314 30 #include "runtime/globals_extension.hpp"
stefank@2314 31 #include "utilities/ostream.hpp"
jprovino@4542 32 #include "utilities/macros.hpp"
stefank@2314 33 #include "utilities/top.hpp"
jprovino@4542 34 #if INCLUDE_ALL_GCS
stefank@2314 35 #include "gc_implementation/g1/g1_globals.hpp"
jprovino@4542 36 #endif // INCLUDE_ALL_GCS
stefank@2314 37 #ifdef COMPILER1
stefank@2314 38 #include "c1/c1_globals.hpp"
stefank@2314 39 #endif
stefank@2314 40 #ifdef COMPILER2
stefank@2314 41 #include "opto/c2_globals.hpp"
stefank@2314 42 #endif
stefank@2314 43 #ifdef SHARK
stefank@2314 44 #include "shark/shark_globals.hpp"
stefank@2314 45 #endif
duke@435 46
duke@435 47 RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
duke@435 48 MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
phh@3287 49 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
phh@3287 50 MATERIALIZE_NOTPRODUCT_FLAG, \
coleenp@548 51 MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \
coleenp@548 52 MATERIALIZE_LP64_PRODUCT_FLAG)
duke@435 53
duke@435 54 RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
duke@435 55 MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
duke@435 56 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
duke@435 57
twisti@4020 58 ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, \
twisti@4020 59 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
twisti@4020 60 MATERIALIZE_NOTPRODUCT_FLAG)
twisti@4020 61
phh@3303 62 MATERIALIZE_FLAGS_EXT
phh@3303 63
phh@3303 64
twisti@5790 65 void Flag::check_writable() {
twisti@5790 66 if (is_constant_in_binary()) {
twisti@5790 67 fatal(err_msg("flag is constant: %s", _name));
twisti@5790 68 }
twisti@5790 69 }
twisti@5790 70
twisti@5790 71 bool Flag::is_bool() const {
twisti@5790 72 return strcmp(_type, "bool") == 0;
twisti@5790 73 }
twisti@5790 74
twisti@5790 75 bool Flag::get_bool() const {
twisti@5790 76 return *((bool*) _addr);
twisti@5790 77 }
twisti@5790 78
twisti@5790 79 void Flag::set_bool(bool value) {
twisti@5790 80 check_writable();
twisti@5790 81 *((bool*) _addr) = value;
twisti@5790 82 }
twisti@5790 83
twisti@5790 84 bool Flag::is_intx() const {
twisti@5790 85 return strcmp(_type, "intx") == 0;
twisti@5790 86 }
twisti@5790 87
twisti@5790 88 intx Flag::get_intx() const {
twisti@5790 89 return *((intx*) _addr);
twisti@5790 90 }
twisti@5790 91
twisti@5790 92 void Flag::set_intx(intx value) {
twisti@5790 93 check_writable();
twisti@5790 94 *((intx*) _addr) = value;
twisti@5790 95 }
twisti@5790 96
twisti@5790 97 bool Flag::is_uintx() const {
twisti@5790 98 return strcmp(_type, "uintx") == 0;
twisti@5790 99 }
twisti@5790 100
twisti@5790 101 uintx Flag::get_uintx() const {
twisti@5790 102 return *((uintx*) _addr);
twisti@5790 103 }
twisti@5790 104
twisti@5790 105 void Flag::set_uintx(uintx value) {
twisti@5790 106 check_writable();
twisti@5790 107 *((uintx*) _addr) = value;
twisti@5790 108 }
twisti@5790 109
twisti@5790 110 bool Flag::is_uint64_t() const {
twisti@5790 111 return strcmp(_type, "uint64_t") == 0;
twisti@5790 112 }
twisti@5790 113
twisti@5790 114 uint64_t Flag::get_uint64_t() const {
twisti@5790 115 return *((uint64_t*) _addr);
twisti@5790 116 }
twisti@5790 117
twisti@5790 118 void Flag::set_uint64_t(uint64_t value) {
twisti@5790 119 check_writable();
twisti@5790 120 *((uint64_t*) _addr) = value;
twisti@5790 121 }
twisti@5790 122
twisti@5790 123 bool Flag::is_double() const {
twisti@5790 124 return strcmp(_type, "double") == 0;
twisti@5790 125 }
twisti@5790 126
twisti@5790 127 double Flag::get_double() const {
twisti@5790 128 return *((double*) _addr);
twisti@5790 129 }
twisti@5790 130
twisti@5790 131 void Flag::set_double(double value) {
twisti@5790 132 check_writable();
twisti@5790 133 *((double*) _addr) = value;
twisti@5790 134 }
twisti@5790 135
twisti@5790 136 bool Flag::is_ccstr() const {
twisti@5790 137 return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0;
twisti@5790 138 }
twisti@5790 139
twisti@5790 140 bool Flag::ccstr_accumulates() const {
twisti@5790 141 return strcmp(_type, "ccstrlist") == 0;
twisti@5790 142 }
twisti@5790 143
twisti@5790 144 ccstr Flag::get_ccstr() const {
twisti@5790 145 return *((ccstr*) _addr);
twisti@5790 146 }
twisti@5790 147
twisti@5790 148 void Flag::set_ccstr(ccstr value) {
twisti@5790 149 check_writable();
twisti@5790 150 *((ccstr*) _addr) = value;
twisti@5790 151 }
twisti@5790 152
twisti@5790 153
twisti@5790 154 Flag::Flags Flag::get_origin() {
twisti@5790 155 return Flags(_flags & VALUE_ORIGIN_MASK);
twisti@5790 156 }
twisti@5790 157
twisti@5790 158 void Flag::set_origin(Flags origin) {
twisti@5790 159 assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");
twisti@5790 160 _flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | origin);
twisti@5790 161 }
twisti@5790 162
twisti@5790 163 bool Flag::is_default() {
twisti@5790 164 return (get_origin() == DEFAULT);
twisti@5790 165 }
twisti@5790 166
twisti@5790 167 bool Flag::is_ergonomic() {
twisti@5790 168 return (get_origin() == ERGONOMIC);
twisti@5790 169 }
twisti@5790 170
twisti@5790 171 bool Flag::is_command_line() {
twisti@5790 172 return (get_origin() == COMMAND_LINE);
twisti@5790 173 }
twisti@5790 174
twisti@5790 175 bool Flag::is_product() const {
twisti@5790 176 return (_flags & KIND_PRODUCT) != 0;
twisti@5790 177 }
twisti@5790 178
twisti@5790 179 bool Flag::is_manageable() const {
twisti@5790 180 return (_flags & KIND_MANAGEABLE) != 0;
twisti@5790 181 }
twisti@5790 182
twisti@5790 183 bool Flag::is_diagnostic() const {
twisti@5790 184 return (_flags & KIND_DIAGNOSTIC) != 0;
twisti@5790 185 }
twisti@5790 186
twisti@5790 187 bool Flag::is_experimental() const {
twisti@5790 188 return (_flags & KIND_EXPERIMENTAL) != 0;
twisti@5790 189 }
twisti@5790 190
twisti@5790 191 bool Flag::is_notproduct() const {
twisti@5790 192 return (_flags & KIND_NOT_PRODUCT) != 0;
twisti@5790 193 }
twisti@5790 194
twisti@5790 195 bool Flag::is_develop() const {
twisti@5790 196 return (_flags & KIND_DEVELOP) != 0;
twisti@5790 197 }
twisti@5790 198
twisti@5790 199 bool Flag::is_read_write() const {
twisti@5790 200 return (_flags & KIND_READ_WRITE) != 0;
twisti@5790 201 }
twisti@5790 202
twisti@5790 203 bool Flag::is_commercial() const {
twisti@5790 204 return (_flags & KIND_COMMERCIAL) != 0;
twisti@5790 205 }
twisti@5790 206
twisti@5790 207 /**
twisti@5790 208 * Returns if this flag is a constant in the binary. Right now this is
twisti@5790 209 * true for notproduct and develop flags in product builds.
twisti@5790 210 */
twisti@5790 211 bool Flag::is_constant_in_binary() const {
twisti@5790 212 #ifdef PRODUCT
twisti@5790 213 return is_notproduct() || is_develop();
twisti@5790 214 #else
twisti@5790 215 return false;
twisti@5790 216 #endif
twisti@5790 217 }
twisti@5790 218
duke@435 219 bool Flag::is_unlocker() const {
twisti@5790 220 return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 ||
twisti@5790 221 strcmp(_name, "UnlockExperimentalVMOptions") == 0 ||
phh@3303 222 is_unlocker_ext();
duke@435 223 }
duke@435 224
duke@435 225 bool Flag::is_unlocked() const {
twisti@5790 226 if (is_diagnostic()) {
duke@435 227 return UnlockDiagnosticVMOptions;
twisti@5790 228 }
twisti@5790 229 if (is_experimental()) {
ysr@785 230 return UnlockExperimentalVMOptions;
duke@435 231 }
twisti@5790 232 return is_unlocked_ext();
duke@435 233 }
duke@435 234
jmelvin@3650 235 // Get custom message for this locked flag, or return NULL if
jmelvin@3650 236 // none is available.
jmelvin@3650 237 void Flag::get_locked_message(char* buf, int buflen) const {
jmelvin@3650 238 get_locked_message_ext(buf, buflen);
jmelvin@3650 239 }
jmelvin@3650 240
duke@435 241 bool Flag::is_writeable() const {
twisti@5790 242 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext();
duke@435 243 }
duke@435 244
phh@3342 245 // All flags except "manageable" are assumed to be internal flags.
duke@435 246 // Long term, we need to define a mechanism to specify which flags
duke@435 247 // are external/stable and change this function accordingly.
duke@435 248 bool Flag::is_external() const {
twisti@5790 249 return is_manageable() || is_external_ext();
duke@435 250 }
duke@435 251
phh@3342 252
duke@435 253 // Length of format string (e.g. "%.1234s") for printing ccstr below
duke@435 254 #define FORMAT_BUFFER_LEN 16
duke@435 255
ikrylov@2123 256 void Flag::print_on(outputStream* st, bool withComments) {
twisti@5790 257 // Don't print notproduct and develop flags in a product build.
twisti@5790 258 if (is_constant_in_binary()) {
twisti@5790 259 return;
twisti@5790 260 }
ikrylov@2123 261
twisti@5790 262 st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' '));
twisti@5790 263
twisti@5790 264 if (is_bool()) {
twisti@5790 265 st->print("%-16s", get_bool() ? "true" : "false");
twisti@5790 266 }
twisti@5790 267 if (is_intx()) {
twisti@5790 268 st->print("%-16ld", get_intx());
twisti@5790 269 }
twisti@5790 270 if (is_uintx()) {
twisti@5790 271 st->print("%-16lu", get_uintx());
twisti@5790 272 }
twisti@5790 273 if (is_uint64_t()) {
twisti@5790 274 st->print("%-16lu", get_uint64_t());
twisti@5790 275 }
twisti@5790 276 if (is_double()) {
twisti@5790 277 st->print("%-16f", get_double());
twisti@5790 278 }
duke@435 279 if (is_ccstr()) {
twisti@5790 280 const char* cp = get_ccstr();
twisti@5790 281 if (cp != NULL) {
twisti@5790 282 const char* eol;
twisti@5790 283 while ((eol = strchr(cp, '\n')) != NULL) {
twisti@5790 284 char format_buffer[FORMAT_BUFFER_LEN];
twisti@5790 285 size_t llen = pointer_delta(eol, cp, sizeof(char));
twisti@5790 286 jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
twisti@5790 287 "%%." SIZE_FORMAT "s", llen);
twisti@5790 288 st->print(format_buffer, cp);
twisti@5790 289 st->cr();
twisti@5790 290 cp = eol+1;
twisti@5790 291 st->print("%5s %-35s += ", "", _name);
twisti@5790 292 }
twisti@5790 293 st->print("%-16s", cp);
twisti@5790 294 }
twisti@5790 295 else st->print("%-16s", "");
duke@435 296 }
twisti@5790 297
twisti@5790 298 st->print("%-20");
twisti@5790 299 print_kind(st);
twisti@5790 300
ikrylov@2123 301 if (withComments) {
ikrylov@2123 302 #ifndef PRODUCT
twisti@5790 303 st->print("%s", _doc);
ikrylov@2123 304 #endif
ikrylov@2123 305 }
duke@435 306 st->cr();
duke@435 307 }
duke@435 308
twisti@5790 309 void Flag::print_kind(outputStream* st) {
twisti@5790 310 struct Data {
twisti@5790 311 int flag;
twisti@5790 312 const char* name;
twisti@5790 313 };
twisti@5790 314
twisti@5790 315 Data data[] = {
twisti@5790 316 { KIND_C1, "C1" },
twisti@5790 317 { KIND_C2, "C2" },
twisti@5790 318 { KIND_ARCH, "ARCH" },
twisti@5790 319 { KIND_SHARK, "SHARK" },
twisti@5790 320 { KIND_PLATFORM_DEPENDENT, "pd" },
twisti@5790 321 { KIND_PRODUCT, "product" },
twisti@5790 322 { KIND_MANAGEABLE, "manageable" },
twisti@5790 323 { KIND_DIAGNOSTIC, "diagnostic" },
twisti@5790 324 { KIND_NOT_PRODUCT, "notproduct" },
twisti@5790 325 { KIND_DEVELOP, "develop" },
twisti@5790 326 { KIND_LP64_PRODUCT, "lp64_product" },
twisti@5790 327 { KIND_READ_WRITE, "rw" },
twisti@5790 328 { -1, "" }
twisti@5790 329 };
twisti@5790 330
twisti@5790 331 if ((_flags & KIND_MASK) != 0) {
twisti@5790 332 st->print("{");
twisti@5790 333 bool is_first = true;
twisti@5790 334
twisti@5790 335 for (int i = 0; data[i].flag != -1; i++) {
twisti@5790 336 Data d = data[i];
twisti@5790 337 if ((_flags & d.flag) != 0) {
twisti@5790 338 if (is_first) {
twisti@5790 339 is_first = false;
twisti@5790 340 } else {
twisti@5790 341 st->print(" ");
twisti@5790 342 }
twisti@5790 343 st->print(d.name);
twisti@5790 344 }
twisti@5790 345 }
twisti@5790 346
twisti@5790 347 st->print("}");
twisti@5790 348 }
twisti@5790 349 }
twisti@5790 350
duke@435 351 void Flag::print_as_flag(outputStream* st) {
duke@435 352 if (is_bool()) {
twisti@5790 353 st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
duke@435 354 } else if (is_intx()) {
twisti@5790 355 st->print("-XX:%s=" INTX_FORMAT, _name, get_intx());
duke@435 356 } else if (is_uintx()) {
twisti@5790 357 st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx());
phh@1502 358 } else if (is_uint64_t()) {
twisti@5790 359 st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t());
brutisso@3752 360 } else if (is_double()) {
twisti@5790 361 st->print("-XX:%s=%f", _name, get_double());
duke@435 362 } else if (is_ccstr()) {
twisti@5790 363 st->print("-XX:%s=", _name);
never@538 364 const char* cp = get_ccstr();
never@538 365 if (cp != NULL) {
never@538 366 // Need to turn embedded '\n's back into separate arguments
never@538 367 // Not so efficient to print one character at a time,
never@538 368 // but the choice is to do the transformation to a buffer
never@538 369 // and print that. And this need not be efficient.
never@538 370 for (; *cp != '\0'; cp += 1) {
never@538 371 switch (*cp) {
never@538 372 default:
never@538 373 st->print("%c", *cp);
never@538 374 break;
never@538 375 case '\n':
twisti@5790 376 st->print(" -XX:%s=", _name);
never@538 377 break;
never@538 378 }
duke@435 379 }
duke@435 380 }
duke@435 381 } else {
duke@435 382 ShouldNotReachHere();
duke@435 383 }
duke@435 384 }
duke@435 385
duke@435 386 // 4991491 do not "optimize out" the was_set false values: omitting them
duke@435 387 // tickles a Microsoft compiler bug causing flagTable to be malformed
duke@435 388
twisti@5790 389 #define NAME(name) NOT_PRODUCT(&name) PRODUCT_ONLY(&CONST_##name)
duke@435 390
twisti@5790 391 #define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) },
twisti@5790 392 #define RUNTIME_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 393 #define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) },
twisti@5790 394 #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) },
twisti@5790 395 #define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) },
twisti@5790 396 #define RUNTIME_PRODUCT_RW_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_READ_WRITE) },
twisti@5790 397 #define RUNTIME_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DEVELOP) },
twisti@5790 398 #define RUNTIME_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 399 #define RUNTIME_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_NOT_PRODUCT) },
duke@435 400
coleenp@548 401 #ifdef _LP64
twisti@5790 402 #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_LP64_PRODUCT) },
coleenp@548 403 #else
twisti@5790 404 #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
coleenp@548 405 #endif // _LP64
coleenp@548 406
twisti@5790 407 #define C1_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT) },
twisti@5790 408 #define C1_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 409 #define C1_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC) },
twisti@5790 410 #define C1_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP) },
twisti@5790 411 #define C1_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 412 #define C1_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_NOT_PRODUCT) },
duke@435 413
twisti@5790 414 #define C2_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT) },
twisti@5790 415 #define C2_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 416 #define C2_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC) },
twisti@5790 417 #define C2_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_EXPERIMENTAL) },
twisti@5790 418 #define C2_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP) },
twisti@5790 419 #define C2_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 420 #define C2_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_NOT_PRODUCT) },
duke@435 421
twisti@5790 422 #define ARCH_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_PRODUCT) },
twisti@5790 423 #define ARCH_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_DIAGNOSTIC) },
twisti@5790 424 #define ARCH_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_EXPERIMENTAL) },
twisti@5790 425 #define ARCH_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_DEVELOP) },
twisti@5790 426 #define ARCH_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_NOT_PRODUCT) },
twisti@4020 427
twisti@5790 428 #define SHARK_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT) },
twisti@5790 429 #define SHARK_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 430 #define SHARK_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DIAGNOSTIC) },
twisti@5790 431 #define SHARK_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP) },
twisti@5790 432 #define SHARK_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
twisti@5790 433 #define SHARK_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_NOT_PRODUCT) },
duke@435 434
duke@435 435 static Flag flagTable[] = {
phh@3287 436 RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT, RUNTIME_LP64_PRODUCT_FLAG_STRUCT)
duke@435 437 RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT)
jprovino@4542 438 #if INCLUDE_ALL_GCS
ysr@785 439 G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT)
jprovino@4542 440 #endif // INCLUDE_ALL_GCS
duke@435 441 #ifdef COMPILER1
roland@5628 442 C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, C1_PD_DEVELOP_FLAG_STRUCT, C1_PRODUCT_FLAG_STRUCT, C1_PD_PRODUCT_FLAG_STRUCT, C1_DIAGNOSTIC_FLAG_STRUCT, C1_NOTPRODUCT_FLAG_STRUCT)
duke@435 443 #endif
duke@435 444 #ifdef COMPILER2
never@1515 445 C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, C2_PD_DEVELOP_FLAG_STRUCT, C2_PRODUCT_FLAG_STRUCT, C2_PD_PRODUCT_FLAG_STRUCT, C2_DIAGNOSTIC_FLAG_STRUCT, C2_EXPERIMENTAL_FLAG_STRUCT, C2_NOTPRODUCT_FLAG_STRUCT)
duke@435 446 #endif
twisti@2047 447 #ifdef SHARK
twisti@2047 448 SHARK_FLAGS(SHARK_DEVELOP_FLAG_STRUCT, SHARK_PD_DEVELOP_FLAG_STRUCT, SHARK_PRODUCT_FLAG_STRUCT, SHARK_PD_PRODUCT_FLAG_STRUCT, SHARK_DIAGNOSTIC_FLAG_STRUCT, SHARK_NOTPRODUCT_FLAG_STRUCT)
twisti@2047 449 #endif
twisti@4020 450 ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, ARCH_PRODUCT_FLAG_STRUCT, ARCH_DIAGNOSTIC_FLAG_STRUCT, ARCH_EXPERIMENTAL_FLAG_STRUCT, ARCH_NOTPRODUCT_FLAG_STRUCT)
phh@3303 451 FLAGTABLE_EXT
duke@435 452 {0, NULL, NULL}
duke@435 453 };
duke@435 454
duke@435 455 Flag* Flag::flags = flagTable;
duke@435 456 size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag));
duke@435 457
tamao@5343 458 inline bool str_equal(const char* s, const char* q, size_t len) {
duke@435 459 // s is null terminated, q is not!
duke@435 460 if (strlen(s) != (unsigned int) len) return false;
duke@435 461 return strncmp(s, q, len) == 0;
duke@435 462 }
duke@435 463
jmelvin@3650 464 // Search the flag table for a named flag
tamao@5343 465 Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) {
twisti@5790 466 for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
twisti@5790 467 if (str_equal(current->_name, name, length)) {
twisti@5790 468 // Found a matching entry.
twisti@5790 469 // Don't report notproduct and develop flags in product builds.
twisti@5790 470 if (current->is_constant_in_binary()) {
twisti@5790 471 return NULL;
twisti@5790 472 }
twisti@5790 473 // Report locked flags only if allowed.
duke@435 474 if (!(current->is_unlocked() || current->is_unlocker())) {
jmelvin@3650 475 if (!allow_locked) {
jmelvin@3650 476 // disable use of locked flags, e.g. diagnostic, experimental,
jmelvin@3650 477 // commercial... until they are explicitly unlocked
jmelvin@3650 478 return NULL;
jmelvin@3650 479 }
duke@435 480 }
duke@435 481 return current;
duke@435 482 }
duke@435 483 }
jmelvin@3650 484 // Flag name is not in the flag table
duke@435 485 return NULL;
duke@435 486 }
duke@435 487
tamao@5343 488 // Compute string similarity based on Dice's coefficient
tamao@5343 489 static float str_similar(const char* str1, const char* str2, size_t len2) {
tamao@5343 490 int len1 = (int) strlen(str1);
tamao@5343 491 int total = len1 + (int) len2;
tamao@5343 492
tamao@5343 493 int hit = 0;
tamao@5343 494
tamao@5343 495 for (int i = 0; i < len1 -1; ++i) {
tamao@5343 496 for (int j = 0; j < (int) len2 -1; ++j) {
tamao@5343 497 if ((str1[i] == str2[j]) && (str1[i+1] == str2[j+1])) {
tamao@5343 498 ++hit;
tamao@5343 499 break;
tamao@5343 500 }
tamao@5343 501 }
tamao@5343 502 }
tamao@5343 503
tamao@5343 504 return 2.0f * (float) hit / (float) total;
tamao@5343 505 }
tamao@5343 506
tamao@5343 507 Flag* Flag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
tamao@5343 508 float VMOptionsFuzzyMatchSimilarity = 0.7f;
tamao@5343 509 Flag* match = NULL;
tamao@5343 510 float score;
tamao@5343 511 float max_score = -1;
tamao@5343 512
twisti@5790 513 for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
twisti@5790 514 score = str_similar(current->_name, name, length);
tamao@5343 515 if (score > max_score) {
tamao@5343 516 max_score = score;
tamao@5343 517 match = current;
tamao@5343 518 }
tamao@5343 519 }
tamao@5343 520
tamao@5343 521 if (!(match->is_unlocked() || match->is_unlocker())) {
tamao@5343 522 if (!allow_locked) {
tamao@5343 523 return NULL;
tamao@5343 524 }
tamao@5343 525 }
tamao@5343 526
tamao@5343 527 if (max_score < VMOptionsFuzzyMatchSimilarity) {
tamao@5343 528 return NULL;
tamao@5343 529 }
tamao@5343 530
tamao@5343 531 return match;
tamao@5343 532 }
tamao@5343 533
duke@435 534 // Returns the address of the index'th element
duke@435 535 static Flag* address_of_flag(CommandLineFlagWithType flag) {
duke@435 536 assert((size_t)flag < Flag::numFlags, "bad command line flag index");
duke@435 537 return &Flag::flags[flag];
duke@435 538 }
duke@435 539
duke@435 540 bool CommandLineFlagsEx::is_default(CommandLineFlag flag) {
duke@435 541 assert((size_t)flag < Flag::numFlags, "bad command line flag index");
duke@435 542 Flag* f = &Flag::flags[flag];
twisti@5790 543 return f->is_default();
duke@435 544 }
duke@435 545
jmasa@448 546 bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) {
jmasa@448 547 assert((size_t)flag < Flag::numFlags, "bad command line flag index");
jmasa@448 548 Flag* f = &Flag::flags[flag];
twisti@5790 549 return f->is_ergonomic();
jmasa@448 550 }
jmasa@448 551
jmasa@448 552 bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
jmasa@448 553 assert((size_t)flag < Flag::numFlags, "bad command line flag index");
jmasa@448 554 Flag* f = &Flag::flags[flag];
twisti@5790 555 return f->is_command_line();
jmasa@448 556 }
jmasa@448 557
duke@435 558 bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
duke@435 559 Flag* result = Flag::find_flag((char*)name, strlen(name));
duke@435 560 if (result == NULL) return false;
twisti@5790 561 *value = result->is_command_line();
duke@435 562 return true;
duke@435 563 }
duke@435 564
duke@435 565 bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) {
duke@435 566 Flag* result = Flag::find_flag(name, len);
duke@435 567 if (result == NULL) return false;
duke@435 568 if (!result->is_bool()) return false;
duke@435 569 *value = result->get_bool();
duke@435 570 return true;
duke@435 571 }
duke@435 572
twisti@5790 573 bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) {
duke@435 574 Flag* result = Flag::find_flag(name, len);
duke@435 575 if (result == NULL) return false;
duke@435 576 if (!result->is_bool()) return false;
duke@435 577 bool old_value = result->get_bool();
duke@435 578 result->set_bool(*value);
duke@435 579 *value = old_value;
twisti@5790 580 result->set_origin(origin);
duke@435 581 return true;
duke@435 582 }
duke@435 583
twisti@5790 584 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
duke@435 585 Flag* faddr = address_of_flag(flag);
duke@435 586 guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
duke@435 587 faddr->set_bool(value);
twisti@5790 588 faddr->set_origin(origin);
duke@435 589 }
duke@435 590
duke@435 591 bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) {
duke@435 592 Flag* result = Flag::find_flag(name, len);
duke@435 593 if (result == NULL) return false;
duke@435 594 if (!result->is_intx()) return false;
duke@435 595 *value = result->get_intx();
duke@435 596 return true;
duke@435 597 }
duke@435 598
twisti@5790 599 bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) {
duke@435 600 Flag* result = Flag::find_flag(name, len);
duke@435 601 if (result == NULL) return false;
duke@435 602 if (!result->is_intx()) return false;
duke@435 603 intx old_value = result->get_intx();
duke@435 604 result->set_intx(*value);
duke@435 605 *value = old_value;
twisti@5790 606 result->set_origin(origin);
duke@435 607 return true;
duke@435 608 }
duke@435 609
twisti@5790 610 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
duke@435 611 Flag* faddr = address_of_flag(flag);
duke@435 612 guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
duke@435 613 faddr->set_intx(value);
twisti@5790 614 faddr->set_origin(origin);
duke@435 615 }
duke@435 616
duke@435 617 bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) {
duke@435 618 Flag* result = Flag::find_flag(name, len);
duke@435 619 if (result == NULL) return false;
duke@435 620 if (!result->is_uintx()) return false;
duke@435 621 *value = result->get_uintx();
duke@435 622 return true;
duke@435 623 }
duke@435 624
twisti@5790 625 bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) {
duke@435 626 Flag* result = Flag::find_flag(name, len);
duke@435 627 if (result == NULL) return false;
duke@435 628 if (!result->is_uintx()) return false;
duke@435 629 uintx old_value = result->get_uintx();
duke@435 630 result->set_uintx(*value);
duke@435 631 *value = old_value;
twisti@5790 632 result->set_origin(origin);
duke@435 633 return true;
duke@435 634 }
duke@435 635
twisti@5790 636 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
duke@435 637 Flag* faddr = address_of_flag(flag);
duke@435 638 guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
duke@435 639 faddr->set_uintx(value);
twisti@5790 640 faddr->set_origin(origin);
duke@435 641 }
duke@435 642
phh@1499 643 bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) {
phh@1499 644 Flag* result = Flag::find_flag(name, len);
phh@1499 645 if (result == NULL) return false;
phh@1499 646 if (!result->is_uint64_t()) return false;
phh@1499 647 *value = result->get_uint64_t();
phh@1499 648 return true;
phh@1499 649 }
phh@1499 650
twisti@5790 651 bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) {
phh@1499 652 Flag* result = Flag::find_flag(name, len);
phh@1499 653 if (result == NULL) return false;
phh@1499 654 if (!result->is_uint64_t()) return false;
phh@1499 655 uint64_t old_value = result->get_uint64_t();
phh@1499 656 result->set_uint64_t(*value);
phh@1499 657 *value = old_value;
twisti@5790 658 result->set_origin(origin);
phh@1499 659 return true;
phh@1499 660 }
phh@1499 661
twisti@5790 662 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
phh@1499 663 Flag* faddr = address_of_flag(flag);
phh@1499 664 guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
phh@1499 665 faddr->set_uint64_t(value);
twisti@5790 666 faddr->set_origin(origin);
phh@1499 667 }
phh@1499 668
duke@435 669 bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) {
duke@435 670 Flag* result = Flag::find_flag(name, len);
duke@435 671 if (result == NULL) return false;
duke@435 672 if (!result->is_double()) return false;
duke@435 673 *value = result->get_double();
duke@435 674 return true;
duke@435 675 }
duke@435 676
twisti@5790 677 bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) {
duke@435 678 Flag* result = Flag::find_flag(name, len);
duke@435 679 if (result == NULL) return false;
duke@435 680 if (!result->is_double()) return false;
duke@435 681 double old_value = result->get_double();
duke@435 682 result->set_double(*value);
duke@435 683 *value = old_value;
twisti@5790 684 result->set_origin(origin);
duke@435 685 return true;
duke@435 686 }
duke@435 687
twisti@5790 688 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
duke@435 689 Flag* faddr = address_of_flag(flag);
duke@435 690 guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
duke@435 691 faddr->set_double(value);
twisti@5790 692 faddr->set_origin(origin);
duke@435 693 }
duke@435 694
duke@435 695 bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) {
duke@435 696 Flag* result = Flag::find_flag(name, len);
duke@435 697 if (result == NULL) return false;
duke@435 698 if (!result->is_ccstr()) return false;
duke@435 699 *value = result->get_ccstr();
duke@435 700 return true;
duke@435 701 }
duke@435 702
duke@435 703 // Contract: Flag will make private copy of the incoming value.
duke@435 704 // Outgoing value is always malloc-ed, and caller MUST call free.
twisti@5790 705 bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) {
duke@435 706 Flag* result = Flag::find_flag(name, len);
duke@435 707 if (result == NULL) return false;
duke@435 708 if (!result->is_ccstr()) return false;
duke@435 709 ccstr old_value = result->get_ccstr();
never@805 710 char* new_value = NULL;
never@805 711 if (*value != NULL) {
zgu@3900 712 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
never@805 713 strcpy(new_value, *value);
never@805 714 }
duke@435 715 result->set_ccstr(new_value);
twisti@5790 716 if (result->is_default() && old_value != NULL) {
duke@435 717 // Prior value is NOT heap allocated, but was a literal constant.
zgu@3900 718 char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1, mtInternal);
duke@435 719 strcpy(old_value_to_free, old_value);
duke@435 720 old_value = old_value_to_free;
duke@435 721 }
duke@435 722 *value = old_value;
twisti@5790 723 result->set_origin(origin);
duke@435 724 return true;
duke@435 725 }
duke@435 726
duke@435 727 // Contract: Flag will make private copy of the incoming value.
twisti@5790 728 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
duke@435 729 Flag* faddr = address_of_flag(flag);
duke@435 730 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
duke@435 731 ccstr old_value = faddr->get_ccstr();
zgu@3900 732 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
duke@435 733 strcpy(new_value, value);
duke@435 734 faddr->set_ccstr(new_value);
twisti@5790 735 if (!faddr->is_default() && old_value != NULL) {
duke@435 736 // Prior value is heap allocated so free it.
zgu@3900 737 FREE_C_HEAP_ARRAY(char, old_value, mtInternal);
duke@435 738 }
twisti@5790 739 faddr->set_origin(origin);
duke@435 740 }
duke@435 741
duke@435 742 extern "C" {
duke@435 743 static int compare_flags(const void* void_a, const void* void_b) {
twisti@5790 744 return strcmp((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name);
duke@435 745 }
duke@435 746 }
duke@435 747
fparain@3402 748 void CommandLineFlags::printSetFlags(outputStream* out) {
duke@435 749 // Print which flags were set on the command line
duke@435 750 // note: this method is called before the thread structure is in place
duke@435 751 // which means resource allocation cannot be used.
duke@435 752
twisti@5790 753 // The last entry is the null entry.
twisti@5790 754 const size_t length = Flag::numFlags - 1;
duke@435 755
duke@435 756 // Sort
zgu@3900 757 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
twisti@5790 758 for (size_t i = 0; i < length; i++) {
twisti@5790 759 array[i] = &flagTable[i];
duke@435 760 }
duke@435 761 qsort(array, length, sizeof(Flag*), compare_flags);
duke@435 762
duke@435 763 // Print
twisti@5790 764 for (size_t i = 0; i < length; i++) {
twisti@5790 765 if (array[i]->get_origin() /* naked field! */) {
fparain@3402 766 array[i]->print_as_flag(out);
fparain@3402 767 out->print(" ");
duke@435 768 }
duke@435 769 }
fparain@3402 770 out->cr();
zgu@3900 771 FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
duke@435 772 }
duke@435 773
duke@435 774 #ifndef PRODUCT
duke@435 775
duke@435 776
duke@435 777 void CommandLineFlags::verify() {
duke@435 778 assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict");
duke@435 779 }
duke@435 780
kvn@1585 781 #endif // PRODUCT
kvn@1585 782
fparain@3402 783 void CommandLineFlags::printFlags(outputStream* out, bool withComments) {
duke@435 784 // Print the flags sorted by name
duke@435 785 // note: this method is called before the thread structure is in place
duke@435 786 // which means resource allocation cannot be used.
duke@435 787
twisti@5790 788 // The last entry is the null entry.
twisti@5790 789 const size_t length = Flag::numFlags - 1;
duke@435 790
duke@435 791 // Sort
zgu@3900 792 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
twisti@5790 793 for (size_t i = 0; i < length; i++) {
twisti@5790 794 array[i] = &flagTable[i];
duke@435 795 }
duke@435 796 qsort(array, length, sizeof(Flag*), compare_flags);
duke@435 797
duke@435 798 // Print
fparain@3402 799 out->print_cr("[Global flags]");
twisti@5790 800 for (size_t i = 0; i < length; i++) {
duke@435 801 if (array[i]->is_unlocked()) {
fparain@3402 802 array[i]->print_on(out, withComments);
duke@435 803 }
duke@435 804 }
zgu@3900 805 FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
duke@435 806 }

mercurial