1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/runtime/globals.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,867 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "memory/allocation.inline.hpp" 1.30 +#include "oops/oop.inline.hpp" 1.31 +#include "runtime/arguments.hpp" 1.32 +#include "runtime/globals.hpp" 1.33 +#include "runtime/globals_extension.hpp" 1.34 +#include "utilities/ostream.hpp" 1.35 +#include "utilities/macros.hpp" 1.36 +#include "utilities/top.hpp" 1.37 +#include "trace/tracing.hpp" 1.38 +#if INCLUDE_ALL_GCS 1.39 +#include "gc_implementation/g1/g1_globals.hpp" 1.40 +#endif // INCLUDE_ALL_GCS 1.41 +#ifdef COMPILER1 1.42 +#include "c1/c1_globals.hpp" 1.43 +#endif 1.44 +#ifdef COMPILER2 1.45 +#include "opto/c2_globals.hpp" 1.46 +#endif 1.47 +#ifdef SHARK 1.48 +#include "shark/shark_globals.hpp" 1.49 +#endif 1.50 + 1.51 +PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 1.52 + 1.53 +RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \ 1.54 + MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \ 1.55 + MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \ 1.56 + MATERIALIZE_NOTPRODUCT_FLAG, \ 1.57 + MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \ 1.58 + MATERIALIZE_LP64_PRODUCT_FLAG) 1.59 + 1.60 +RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \ 1.61 + MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \ 1.62 + MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG) 1.63 + 1.64 +ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, \ 1.65 + MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \ 1.66 + MATERIALIZE_NOTPRODUCT_FLAG) 1.67 + 1.68 +MATERIALIZE_FLAGS_EXT 1.69 + 1.70 + 1.71 +static bool is_product_build() { 1.72 +#ifdef PRODUCT 1.73 + return true; 1.74 +#else 1.75 + return false; 1.76 +#endif 1.77 +} 1.78 + 1.79 +void Flag::check_writable() { 1.80 + if (is_constant_in_binary()) { 1.81 + fatal(err_msg("flag is constant: %s", _name)); 1.82 + } 1.83 +} 1.84 + 1.85 +bool Flag::is_bool() const { 1.86 + return strcmp(_type, "bool") == 0; 1.87 +} 1.88 + 1.89 +bool Flag::get_bool() const { 1.90 + return *((bool*) _addr); 1.91 +} 1.92 + 1.93 +void Flag::set_bool(bool value) { 1.94 + check_writable(); 1.95 + *((bool*) _addr) = value; 1.96 +} 1.97 + 1.98 +bool Flag::is_intx() const { 1.99 + return strcmp(_type, "intx") == 0; 1.100 +} 1.101 + 1.102 +intx Flag::get_intx() const { 1.103 + return *((intx*) _addr); 1.104 +} 1.105 + 1.106 +void Flag::set_intx(intx value) { 1.107 + check_writable(); 1.108 + *((intx*) _addr) = value; 1.109 +} 1.110 + 1.111 +bool Flag::is_uintx() const { 1.112 + return strcmp(_type, "uintx") == 0; 1.113 +} 1.114 + 1.115 +uintx Flag::get_uintx() const { 1.116 + return *((uintx*) _addr); 1.117 +} 1.118 + 1.119 +void Flag::set_uintx(uintx value) { 1.120 + check_writable(); 1.121 + *((uintx*) _addr) = value; 1.122 +} 1.123 + 1.124 +bool Flag::is_uint64_t() const { 1.125 + return strcmp(_type, "uint64_t") == 0; 1.126 +} 1.127 + 1.128 +uint64_t Flag::get_uint64_t() const { 1.129 + return *((uint64_t*) _addr); 1.130 +} 1.131 + 1.132 +void Flag::set_uint64_t(uint64_t value) { 1.133 + check_writable(); 1.134 + *((uint64_t*) _addr) = value; 1.135 +} 1.136 + 1.137 +bool Flag::is_double() const { 1.138 + return strcmp(_type, "double") == 0; 1.139 +} 1.140 + 1.141 +double Flag::get_double() const { 1.142 + return *((double*) _addr); 1.143 +} 1.144 + 1.145 +void Flag::set_double(double value) { 1.146 + check_writable(); 1.147 + *((double*) _addr) = value; 1.148 +} 1.149 + 1.150 +bool Flag::is_ccstr() const { 1.151 + return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0; 1.152 +} 1.153 + 1.154 +bool Flag::ccstr_accumulates() const { 1.155 + return strcmp(_type, "ccstrlist") == 0; 1.156 +} 1.157 + 1.158 +ccstr Flag::get_ccstr() const { 1.159 + return *((ccstr*) _addr); 1.160 +} 1.161 + 1.162 +void Flag::set_ccstr(ccstr value) { 1.163 + check_writable(); 1.164 + *((ccstr*) _addr) = value; 1.165 +} 1.166 + 1.167 + 1.168 +Flag::Flags Flag::get_origin() { 1.169 + return Flags(_flags & VALUE_ORIGIN_MASK); 1.170 +} 1.171 + 1.172 +void Flag::set_origin(Flags origin) { 1.173 + assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity"); 1.174 + _flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | origin); 1.175 +} 1.176 + 1.177 +bool Flag::is_default() { 1.178 + return (get_origin() == DEFAULT); 1.179 +} 1.180 + 1.181 +bool Flag::is_ergonomic() { 1.182 + return (get_origin() == ERGONOMIC); 1.183 +} 1.184 + 1.185 +bool Flag::is_command_line() { 1.186 + return (get_origin() == COMMAND_LINE); 1.187 +} 1.188 + 1.189 +bool Flag::is_product() const { 1.190 + return (_flags & KIND_PRODUCT) != 0; 1.191 +} 1.192 + 1.193 +bool Flag::is_manageable() const { 1.194 + return (_flags & KIND_MANAGEABLE) != 0; 1.195 +} 1.196 + 1.197 +bool Flag::is_diagnostic() const { 1.198 + return (_flags & KIND_DIAGNOSTIC) != 0; 1.199 +} 1.200 + 1.201 +bool Flag::is_experimental() const { 1.202 + return (_flags & KIND_EXPERIMENTAL) != 0; 1.203 +} 1.204 + 1.205 +bool Flag::is_notproduct() const { 1.206 + return (_flags & KIND_NOT_PRODUCT) != 0; 1.207 +} 1.208 + 1.209 +bool Flag::is_develop() const { 1.210 + return (_flags & KIND_DEVELOP) != 0; 1.211 +} 1.212 + 1.213 +bool Flag::is_read_write() const { 1.214 + return (_flags & KIND_READ_WRITE) != 0; 1.215 +} 1.216 + 1.217 +bool Flag::is_commercial() const { 1.218 + return (_flags & KIND_COMMERCIAL) != 0; 1.219 +} 1.220 + 1.221 +/** 1.222 + * Returns if this flag is a constant in the binary. Right now this is 1.223 + * true for notproduct and develop flags in product builds. 1.224 + */ 1.225 +bool Flag::is_constant_in_binary() const { 1.226 +#ifdef PRODUCT 1.227 + return is_notproduct() || is_develop(); 1.228 +#else 1.229 + return false; 1.230 +#endif 1.231 +} 1.232 + 1.233 +bool Flag::is_unlocker() const { 1.234 + return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 || 1.235 + strcmp(_name, "UnlockExperimentalVMOptions") == 0 || 1.236 + is_unlocker_ext(); 1.237 +} 1.238 + 1.239 +bool Flag::is_unlocked() const { 1.240 + if (is_diagnostic()) { 1.241 + return UnlockDiagnosticVMOptions; 1.242 + } 1.243 + if (is_experimental()) { 1.244 + return UnlockExperimentalVMOptions; 1.245 + } 1.246 + return is_unlocked_ext(); 1.247 +} 1.248 + 1.249 +// Get custom message for this locked flag, or return NULL if 1.250 +// none is available. 1.251 +void Flag::get_locked_message(char* buf, int buflen) const { 1.252 + buf[0] = '\0'; 1.253 + if (is_diagnostic() && !is_unlocked()) { 1.254 + jio_snprintf(buf, buflen, "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n", 1.255 + _name); 1.256 + return; 1.257 + } 1.258 + if (is_experimental() && !is_unlocked()) { 1.259 + jio_snprintf(buf, buflen, "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n", 1.260 + _name); 1.261 + return; 1.262 + } 1.263 + if (is_develop() && is_product_build()) { 1.264 + jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n", 1.265 + _name); 1.266 + return; 1.267 + } 1.268 + if (is_notproduct() && is_product_build()) { 1.269 + jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n", 1.270 + _name); 1.271 + return; 1.272 + } 1.273 + get_locked_message_ext(buf, buflen); 1.274 +} 1.275 + 1.276 +bool Flag::is_writeable() const { 1.277 + return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); 1.278 +} 1.279 + 1.280 +// All flags except "manageable" are assumed to be internal flags. 1.281 +// Long term, we need to define a mechanism to specify which flags 1.282 +// are external/stable and change this function accordingly. 1.283 +bool Flag::is_external() const { 1.284 + return is_manageable() || is_external_ext(); 1.285 +} 1.286 + 1.287 + 1.288 +// Length of format string (e.g. "%.1234s") for printing ccstr below 1.289 +#define FORMAT_BUFFER_LEN 16 1.290 + 1.291 +PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL 1.292 +void Flag::print_on(outputStream* st, bool withComments) { 1.293 + // Don't print notproduct and develop flags in a product build. 1.294 + if (is_constant_in_binary()) { 1.295 + return; 1.296 + } 1.297 + 1.298 + st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' ')); 1.299 + 1.300 + if (is_bool()) { 1.301 + st->print("%-16s", get_bool() ? "true" : "false"); 1.302 + } 1.303 + if (is_intx()) { 1.304 + st->print("%-16ld", get_intx()); 1.305 + } 1.306 + if (is_uintx()) { 1.307 + st->print("%-16lu", get_uintx()); 1.308 + } 1.309 + if (is_uint64_t()) { 1.310 + st->print("%-16lu", get_uint64_t()); 1.311 + } 1.312 + if (is_double()) { 1.313 + st->print("%-16f", get_double()); 1.314 + } 1.315 + if (is_ccstr()) { 1.316 + const char* cp = get_ccstr(); 1.317 + if (cp != NULL) { 1.318 + const char* eol; 1.319 + while ((eol = strchr(cp, '\n')) != NULL) { 1.320 + char format_buffer[FORMAT_BUFFER_LEN]; 1.321 + size_t llen = pointer_delta(eol, cp, sizeof(char)); 1.322 + jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, 1.323 + "%%." SIZE_FORMAT "s", llen); 1.324 +PRAGMA_DIAG_PUSH 1.325 +PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL 1.326 + st->print(format_buffer, cp); 1.327 +PRAGMA_DIAG_POP 1.328 + st->cr(); 1.329 + cp = eol+1; 1.330 + st->print("%5s %-35s += ", "", _name); 1.331 + } 1.332 + st->print("%-16s", cp); 1.333 + } 1.334 + else st->print("%-16s", ""); 1.335 + } 1.336 + 1.337 + st->print("%-20s", " "); 1.338 + print_kind(st); 1.339 + 1.340 + if (withComments) { 1.341 +#ifndef PRODUCT 1.342 + st->print("%s", _doc); 1.343 +#endif 1.344 + } 1.345 + st->cr(); 1.346 +} 1.347 + 1.348 +void Flag::print_kind(outputStream* st) { 1.349 + struct Data { 1.350 + int flag; 1.351 + const char* name; 1.352 + }; 1.353 + 1.354 + Data data[] = { 1.355 + { KIND_C1, "C1" }, 1.356 + { KIND_C2, "C2" }, 1.357 + { KIND_ARCH, "ARCH" }, 1.358 + { KIND_SHARK, "SHARK" }, 1.359 + { KIND_PLATFORM_DEPENDENT, "pd" }, 1.360 + { KIND_PRODUCT, "product" }, 1.361 + { KIND_MANAGEABLE, "manageable" }, 1.362 + { KIND_DIAGNOSTIC, "diagnostic" }, 1.363 + { KIND_EXPERIMENTAL, "experimental" }, 1.364 + { KIND_COMMERCIAL, "commercial" }, 1.365 + { KIND_NOT_PRODUCT, "notproduct" }, 1.366 + { KIND_DEVELOP, "develop" }, 1.367 + { KIND_LP64_PRODUCT, "lp64_product" }, 1.368 + { KIND_READ_WRITE, "rw" }, 1.369 + { -1, "" } 1.370 + }; 1.371 + 1.372 + if ((_flags & KIND_MASK) != 0) { 1.373 + st->print("{"); 1.374 + bool is_first = true; 1.375 + 1.376 + for (int i = 0; data[i].flag != -1; i++) { 1.377 + Data d = data[i]; 1.378 + if ((_flags & d.flag) != 0) { 1.379 + if (is_first) { 1.380 + is_first = false; 1.381 + } else { 1.382 + st->print(" "); 1.383 + } 1.384 + st->print("%s", d.name); 1.385 + } 1.386 + } 1.387 + 1.388 + st->print("}"); 1.389 + } 1.390 +} 1.391 + 1.392 +void Flag::print_as_flag(outputStream* st) { 1.393 + if (is_bool()) { 1.394 + st->print("-XX:%s%s", get_bool() ? "+" : "-", _name); 1.395 + } else if (is_intx()) { 1.396 + st->print("-XX:%s=" INTX_FORMAT, _name, get_intx()); 1.397 + } else if (is_uintx()) { 1.398 + st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx()); 1.399 + } else if (is_uint64_t()) { 1.400 + st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t()); 1.401 + } else if (is_double()) { 1.402 + st->print("-XX:%s=%f", _name, get_double()); 1.403 + } else if (is_ccstr()) { 1.404 + st->print("-XX:%s=", _name); 1.405 + const char* cp = get_ccstr(); 1.406 + if (cp != NULL) { 1.407 + // Need to turn embedded '\n's back into separate arguments 1.408 + // Not so efficient to print one character at a time, 1.409 + // but the choice is to do the transformation to a buffer 1.410 + // and print that. And this need not be efficient. 1.411 + for (; *cp != '\0'; cp += 1) { 1.412 + switch (*cp) { 1.413 + default: 1.414 + st->print("%c", *cp); 1.415 + break; 1.416 + case '\n': 1.417 + st->print(" -XX:%s=", _name); 1.418 + break; 1.419 + } 1.420 + } 1.421 + } 1.422 + } else { 1.423 + ShouldNotReachHere(); 1.424 + } 1.425 +} 1.426 + 1.427 +// 4991491 do not "optimize out" the was_set false values: omitting them 1.428 +// tickles a Microsoft compiler bug causing flagTable to be malformed 1.429 + 1.430 +#define NAME(name) NOT_PRODUCT(&name) PRODUCT_ONLY(&CONST_##name) 1.431 + 1.432 +#define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) }, 1.433 +#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) }, 1.434 +#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) }, 1.435 +#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) }, 1.436 +#define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) }, 1.437 +#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) }, 1.438 +#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) }, 1.439 +#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) }, 1.440 +#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) }, 1.441 + 1.442 +#ifdef _LP64 1.443 +#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) }, 1.444 +#else 1.445 +#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ 1.446 +#endif // _LP64 1.447 + 1.448 +#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) }, 1.449 +#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) }, 1.450 +#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) }, 1.451 +#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) }, 1.452 +#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) }, 1.453 +#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) }, 1.454 + 1.455 +#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) }, 1.456 +#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) }, 1.457 +#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) }, 1.458 +#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) }, 1.459 +#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) }, 1.460 +#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) }, 1.461 +#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) }, 1.462 + 1.463 +#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) }, 1.464 +#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) }, 1.465 +#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) }, 1.466 +#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) }, 1.467 +#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) }, 1.468 + 1.469 +#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) }, 1.470 +#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) }, 1.471 +#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) }, 1.472 +#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) }, 1.473 +#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) }, 1.474 +#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) }, 1.475 + 1.476 +static Flag flagTable[] = { 1.477 + 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) 1.478 + 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) 1.479 +#if INCLUDE_ALL_GCS 1.480 + 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) 1.481 +#endif // INCLUDE_ALL_GCS 1.482 +#ifdef COMPILER1 1.483 + 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) 1.484 +#endif 1.485 +#ifdef COMPILER2 1.486 + 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) 1.487 +#endif 1.488 +#ifdef SHARK 1.489 + 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) 1.490 +#endif 1.491 + ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, ARCH_PRODUCT_FLAG_STRUCT, ARCH_DIAGNOSTIC_FLAG_STRUCT, ARCH_EXPERIMENTAL_FLAG_STRUCT, ARCH_NOTPRODUCT_FLAG_STRUCT) 1.492 + FLAGTABLE_EXT 1.493 + {0, NULL, NULL} 1.494 +}; 1.495 + 1.496 +Flag* Flag::flags = flagTable; 1.497 +size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag)); 1.498 + 1.499 +inline bool str_equal(const char* s, const char* q, size_t len) { 1.500 + // s is null terminated, q is not! 1.501 + if (strlen(s) != (unsigned int) len) return false; 1.502 + return strncmp(s, q, len) == 0; 1.503 +} 1.504 + 1.505 +// Search the flag table for a named flag 1.506 +Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) { 1.507 + for (Flag* current = &flagTable[0]; current->_name != NULL; current++) { 1.508 + if (str_equal(current->_name, name, length)) { 1.509 + // Found a matching entry. 1.510 + // Don't report notproduct and develop flags in product builds. 1.511 + if (current->is_constant_in_binary()) { 1.512 + return (return_flag == true ? current : NULL); 1.513 + } 1.514 + // Report locked flags only if allowed. 1.515 + if (!(current->is_unlocked() || current->is_unlocker())) { 1.516 + if (!allow_locked) { 1.517 + // disable use of locked flags, e.g. diagnostic, experimental, 1.518 + // commercial... until they are explicitly unlocked 1.519 + return NULL; 1.520 + } 1.521 + } 1.522 + return current; 1.523 + } 1.524 + } 1.525 + // Flag name is not in the flag table 1.526 + return NULL; 1.527 +} 1.528 + 1.529 +// Compute string similarity based on Dice's coefficient 1.530 +static float str_similar(const char* str1, const char* str2, size_t len2) { 1.531 + int len1 = (int) strlen(str1); 1.532 + int total = len1 + (int) len2; 1.533 + 1.534 + int hit = 0; 1.535 + 1.536 + for (int i = 0; i < len1 -1; ++i) { 1.537 + for (int j = 0; j < (int) len2 -1; ++j) { 1.538 + if ((str1[i] == str2[j]) && (str1[i+1] == str2[j+1])) { 1.539 + ++hit; 1.540 + break; 1.541 + } 1.542 + } 1.543 + } 1.544 + 1.545 + return 2.0f * (float) hit / (float) total; 1.546 +} 1.547 + 1.548 +Flag* Flag::fuzzy_match(const char* name, size_t length, bool allow_locked) { 1.549 + float VMOptionsFuzzyMatchSimilarity = 0.7f; 1.550 + Flag* match = NULL; 1.551 + float score; 1.552 + float max_score = -1; 1.553 + 1.554 + for (Flag* current = &flagTable[0]; current->_name != NULL; current++) { 1.555 + score = str_similar(current->_name, name, length); 1.556 + if (score > max_score) { 1.557 + max_score = score; 1.558 + match = current; 1.559 + } 1.560 + } 1.561 + 1.562 + if (!(match->is_unlocked() || match->is_unlocker())) { 1.563 + if (!allow_locked) { 1.564 + return NULL; 1.565 + } 1.566 + } 1.567 + 1.568 + if (max_score < VMOptionsFuzzyMatchSimilarity) { 1.569 + return NULL; 1.570 + } 1.571 + 1.572 + return match; 1.573 +} 1.574 + 1.575 +// Returns the address of the index'th element 1.576 +static Flag* address_of_flag(CommandLineFlagWithType flag) { 1.577 + assert((size_t)flag < Flag::numFlags, "bad command line flag index"); 1.578 + return &Flag::flags[flag]; 1.579 +} 1.580 + 1.581 +bool CommandLineFlagsEx::is_default(CommandLineFlag flag) { 1.582 + assert((size_t)flag < Flag::numFlags, "bad command line flag index"); 1.583 + Flag* f = &Flag::flags[flag]; 1.584 + return f->is_default(); 1.585 +} 1.586 + 1.587 +bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) { 1.588 + assert((size_t)flag < Flag::numFlags, "bad command line flag index"); 1.589 + Flag* f = &Flag::flags[flag]; 1.590 + return f->is_ergonomic(); 1.591 +} 1.592 + 1.593 +bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) { 1.594 + assert((size_t)flag < Flag::numFlags, "bad command line flag index"); 1.595 + Flag* f = &Flag::flags[flag]; 1.596 + return f->is_command_line(); 1.597 +} 1.598 + 1.599 +bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) { 1.600 + Flag* result = Flag::find_flag((char*)name, strlen(name)); 1.601 + if (result == NULL) return false; 1.602 + *value = result->is_command_line(); 1.603 + return true; 1.604 +} 1.605 + 1.606 +template<class E, class T> 1.607 +static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin) 1.608 +{ 1.609 + E e; 1.610 + e.set_name(name); 1.611 + e.set_old_value(old_value); 1.612 + e.set_new_value(new_value); 1.613 + e.set_origin(origin); 1.614 + e.commit(); 1.615 +} 1.616 + 1.617 +bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { 1.618 + Flag* result = Flag::find_flag(name, len); 1.619 + if (result == NULL) return false; 1.620 + if (!result->is_bool()) return false; 1.621 + *value = result->get_bool(); 1.622 + return true; 1.623 +} 1.624 + 1.625 +bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) { 1.626 + Flag* result = Flag::find_flag(name, len); 1.627 + if (result == NULL) return false; 1.628 + if (!result->is_bool()) return false; 1.629 + bool old_value = result->get_bool(); 1.630 + trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin); 1.631 + result->set_bool(*value); 1.632 + *value = old_value; 1.633 + result->set_origin(origin); 1.634 + return true; 1.635 +} 1.636 + 1.637 +void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) { 1.638 + Flag* faddr = address_of_flag(flag); 1.639 + guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); 1.640 + trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin); 1.641 + faddr->set_bool(value); 1.642 + faddr->set_origin(origin); 1.643 +} 1.644 + 1.645 +bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { 1.646 + Flag* result = Flag::find_flag(name, len); 1.647 + if (result == NULL) return false; 1.648 + if (!result->is_intx()) return false; 1.649 + *value = result->get_intx(); 1.650 + return true; 1.651 +} 1.652 + 1.653 +bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) { 1.654 + Flag* result = Flag::find_flag(name, len); 1.655 + if (result == NULL) return false; 1.656 + if (!result->is_intx()) return false; 1.657 + intx old_value = result->get_intx(); 1.658 + trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin); 1.659 + result->set_intx(*value); 1.660 + *value = old_value; 1.661 + result->set_origin(origin); 1.662 + return true; 1.663 +} 1.664 + 1.665 +void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) { 1.666 + Flag* faddr = address_of_flag(flag); 1.667 + guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); 1.668 + trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin); 1.669 + faddr->set_intx(value); 1.670 + faddr->set_origin(origin); 1.671 +} 1.672 + 1.673 +bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { 1.674 + Flag* result = Flag::find_flag(name, len); 1.675 + if (result == NULL) return false; 1.676 + if (!result->is_uintx()) return false; 1.677 + *value = result->get_uintx(); 1.678 + return true; 1.679 +} 1.680 + 1.681 +bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) { 1.682 + Flag* result = Flag::find_flag(name, len); 1.683 + if (result == NULL) return false; 1.684 + if (!result->is_uintx()) return false; 1.685 + uintx old_value = result->get_uintx(); 1.686 + trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); 1.687 + result->set_uintx(*value); 1.688 + *value = old_value; 1.689 + result->set_origin(origin); 1.690 + return true; 1.691 +} 1.692 + 1.693 +void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) { 1.694 + Flag* faddr = address_of_flag(flag); 1.695 + guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); 1.696 + trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin); 1.697 + faddr->set_uintx(value); 1.698 + faddr->set_origin(origin); 1.699 +} 1.700 + 1.701 +bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { 1.702 + Flag* result = Flag::find_flag(name, len); 1.703 + if (result == NULL) return false; 1.704 + if (!result->is_uint64_t()) return false; 1.705 + *value = result->get_uint64_t(); 1.706 + return true; 1.707 +} 1.708 + 1.709 +bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) { 1.710 + Flag* result = Flag::find_flag(name, len); 1.711 + if (result == NULL) return false; 1.712 + if (!result->is_uint64_t()) return false; 1.713 + uint64_t old_value = result->get_uint64_t(); 1.714 + trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); 1.715 + result->set_uint64_t(*value); 1.716 + *value = old_value; 1.717 + result->set_origin(origin); 1.718 + return true; 1.719 +} 1.720 + 1.721 +void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) { 1.722 + Flag* faddr = address_of_flag(flag); 1.723 + guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); 1.724 + trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin); 1.725 + faddr->set_uint64_t(value); 1.726 + faddr->set_origin(origin); 1.727 +} 1.728 + 1.729 +bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { 1.730 + Flag* result = Flag::find_flag(name, len); 1.731 + if (result == NULL) return false; 1.732 + if (!result->is_double()) return false; 1.733 + *value = result->get_double(); 1.734 + return true; 1.735 +} 1.736 + 1.737 +bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) { 1.738 + Flag* result = Flag::find_flag(name, len); 1.739 + if (result == NULL) return false; 1.740 + if (!result->is_double()) return false; 1.741 + double old_value = result->get_double(); 1.742 + trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin); 1.743 + result->set_double(*value); 1.744 + *value = old_value; 1.745 + result->set_origin(origin); 1.746 + return true; 1.747 +} 1.748 + 1.749 +void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) { 1.750 + Flag* faddr = address_of_flag(flag); 1.751 + guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); 1.752 + trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin); 1.753 + faddr->set_double(value); 1.754 + faddr->set_origin(origin); 1.755 +} 1.756 + 1.757 +bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { 1.758 + Flag* result = Flag::find_flag(name, len); 1.759 + if (result == NULL) return false; 1.760 + if (!result->is_ccstr()) return false; 1.761 + *value = result->get_ccstr(); 1.762 + return true; 1.763 +} 1.764 + 1.765 +// Contract: Flag will make private copy of the incoming value. 1.766 +// Outgoing value is always malloc-ed, and caller MUST call free. 1.767 +bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) { 1.768 + Flag* result = Flag::find_flag(name, len); 1.769 + if (result == NULL) return false; 1.770 + if (!result->is_ccstr()) return false; 1.771 + ccstr old_value = result->get_ccstr(); 1.772 + trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin); 1.773 + char* new_value = NULL; 1.774 + if (*value != NULL) { 1.775 + new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal); 1.776 + strcpy(new_value, *value); 1.777 + } 1.778 + result->set_ccstr(new_value); 1.779 + if (result->is_default() && old_value != NULL) { 1.780 + // Prior value is NOT heap allocated, but was a literal constant. 1.781 + char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1, mtInternal); 1.782 + strcpy(old_value_to_free, old_value); 1.783 + old_value = old_value_to_free; 1.784 + } 1.785 + *value = old_value; 1.786 + result->set_origin(origin); 1.787 + return true; 1.788 +} 1.789 + 1.790 +// Contract: Flag will make private copy of the incoming value. 1.791 +void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) { 1.792 + Flag* faddr = address_of_flag(flag); 1.793 + guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); 1.794 + ccstr old_value = faddr->get_ccstr(); 1.795 + trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin); 1.796 + char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal); 1.797 + strcpy(new_value, value); 1.798 + faddr->set_ccstr(new_value); 1.799 + if (!faddr->is_default() && old_value != NULL) { 1.800 + // Prior value is heap allocated so free it. 1.801 + FREE_C_HEAP_ARRAY(char, old_value, mtInternal); 1.802 + } 1.803 + faddr->set_origin(origin); 1.804 +} 1.805 + 1.806 +extern "C" { 1.807 + static int compare_flags(const void* void_a, const void* void_b) { 1.808 + return strcmp((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name); 1.809 + } 1.810 +} 1.811 + 1.812 +void CommandLineFlags::printSetFlags(outputStream* out) { 1.813 + // Print which flags were set on the command line 1.814 + // note: this method is called before the thread structure is in place 1.815 + // which means resource allocation cannot be used. 1.816 + 1.817 + // The last entry is the null entry. 1.818 + const size_t length = Flag::numFlags - 1; 1.819 + 1.820 + // Sort 1.821 + Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal); 1.822 + for (size_t i = 0; i < length; i++) { 1.823 + array[i] = &flagTable[i]; 1.824 + } 1.825 + qsort(array, length, sizeof(Flag*), compare_flags); 1.826 + 1.827 + // Print 1.828 + for (size_t i = 0; i < length; i++) { 1.829 + if (array[i]->get_origin() /* naked field! */) { 1.830 + array[i]->print_as_flag(out); 1.831 + out->print(" "); 1.832 + } 1.833 + } 1.834 + out->cr(); 1.835 + FREE_C_HEAP_ARRAY(Flag*, array, mtInternal); 1.836 +} 1.837 + 1.838 +#ifndef PRODUCT 1.839 + 1.840 + 1.841 +void CommandLineFlags::verify() { 1.842 + assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict"); 1.843 +} 1.844 + 1.845 +#endif // PRODUCT 1.846 + 1.847 +void CommandLineFlags::printFlags(outputStream* out, bool withComments) { 1.848 + // Print the flags sorted by name 1.849 + // note: this method is called before the thread structure is in place 1.850 + // which means resource allocation cannot be used. 1.851 + 1.852 + // The last entry is the null entry. 1.853 + const size_t length = Flag::numFlags - 1; 1.854 + 1.855 + // Sort 1.856 + Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal); 1.857 + for (size_t i = 0; i < length; i++) { 1.858 + array[i] = &flagTable[i]; 1.859 + } 1.860 + qsort(array, length, sizeof(Flag*), compare_flags); 1.861 + 1.862 + // Print 1.863 + out->print_cr("[Global flags]"); 1.864 + for (size_t i = 0; i < length; i++) { 1.865 + if (array[i]->is_unlocked()) { 1.866 + array[i]->print_on(out, withComments); 1.867 + } 1.868 + } 1.869 + FREE_C_HEAP_ARRAY(Flag*, array, mtInternal); 1.870 +}