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