2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2013-02-10 22:35:38 -08:00
|
|
|
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "memory/allocation.inline.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "runtime/arguments.hpp"
|
|
|
|
#include "runtime/globals.hpp"
|
|
|
|
#include "runtime/globals_extension.hpp"
|
|
|
|
#include "utilities/ostream.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/top.hpp"
|
2014-01-23 08:12:12 +01:00
|
|
|
#include "trace/tracing.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "gc_implementation/g1/g1_globals.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifdef COMPILER1
|
|
|
|
#include "c1/c1_globals.hpp"
|
|
|
|
#endif
|
|
|
|
#ifdef COMPILER2
|
|
|
|
#include "opto/c2_globals.hpp"
|
|
|
|
#endif
|
|
|
|
#ifdef SHARK
|
|
|
|
#include "shark/shark_globals.hpp"
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
|
|
|
|
MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
|
2011-11-30 12:48:52 -05:00
|
|
|
MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
|
|
|
|
MATERIALIZE_NOTPRODUCT_FLAG, \
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \
|
|
|
|
MATERIALIZE_LP64_PRODUCT_FLAG)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
|
|
|
|
MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
|
|
|
|
MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
|
|
|
|
|
2012-08-27 15:17:17 -07:00
|
|
|
ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, \
|
|
|
|
MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
|
|
|
|
MATERIALIZE_NOTPRODUCT_FLAG)
|
|
|
|
|
2011-12-05 12:50:00 -05:00
|
|
|
MATERIALIZE_FLAGS_EXT
|
|
|
|
|
|
|
|
|
2014-01-16 10:51:16 -08:00
|
|
|
static bool is_product_build() {
|
|
|
|
#ifdef PRODUCT
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void Flag::check_writable() {
|
|
|
|
if (is_constant_in_binary()) {
|
|
|
|
fatal(err_msg("flag is constant: %s", _name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_bool() const {
|
|
|
|
return strcmp(_type, "bool") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::get_bool() const {
|
|
|
|
return *((bool*) _addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_bool(bool value) {
|
|
|
|
check_writable();
|
|
|
|
*((bool*) _addr) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_intx() const {
|
|
|
|
return strcmp(_type, "intx") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
intx Flag::get_intx() const {
|
|
|
|
return *((intx*) _addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_intx(intx value) {
|
|
|
|
check_writable();
|
|
|
|
*((intx*) _addr) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_uintx() const {
|
|
|
|
return strcmp(_type, "uintx") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uintx Flag::get_uintx() const {
|
|
|
|
return *((uintx*) _addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_uintx(uintx value) {
|
|
|
|
check_writable();
|
|
|
|
*((uintx*) _addr) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_uint64_t() const {
|
|
|
|
return strcmp(_type, "uint64_t") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t Flag::get_uint64_t() const {
|
|
|
|
return *((uint64_t*) _addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_uint64_t(uint64_t value) {
|
|
|
|
check_writable();
|
|
|
|
*((uint64_t*) _addr) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_double() const {
|
|
|
|
return strcmp(_type, "double") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double Flag::get_double() const {
|
|
|
|
return *((double*) _addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_double(double value) {
|
|
|
|
check_writable();
|
|
|
|
*((double*) _addr) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_ccstr() const {
|
|
|
|
return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::ccstr_accumulates() const {
|
|
|
|
return strcmp(_type, "ccstrlist") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccstr Flag::get_ccstr() const {
|
|
|
|
return *((ccstr*) _addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_ccstr(ccstr value) {
|
|
|
|
check_writable();
|
|
|
|
*((ccstr*) _addr) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Flag::Flags Flag::get_origin() {
|
|
|
|
return Flags(_flags & VALUE_ORIGIN_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Flag::set_origin(Flags origin) {
|
|
|
|
assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");
|
|
|
|
_flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_default() {
|
|
|
|
return (get_origin() == DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_ergonomic() {
|
|
|
|
return (get_origin() == ERGONOMIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_command_line() {
|
|
|
|
return (get_origin() == COMMAND_LINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_product() const {
|
|
|
|
return (_flags & KIND_PRODUCT) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_manageable() const {
|
|
|
|
return (_flags & KIND_MANAGEABLE) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_diagnostic() const {
|
|
|
|
return (_flags & KIND_DIAGNOSTIC) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_experimental() const {
|
|
|
|
return (_flags & KIND_EXPERIMENTAL) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_notproduct() const {
|
|
|
|
return (_flags & KIND_NOT_PRODUCT) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_develop() const {
|
|
|
|
return (_flags & KIND_DEVELOP) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_read_write() const {
|
|
|
|
return (_flags & KIND_READ_WRITE) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_commercial() const {
|
|
|
|
return (_flags & KIND_COMMERCIAL) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if this flag is a constant in the binary. Right now this is
|
|
|
|
* true for notproduct and develop flags in product builds.
|
|
|
|
*/
|
|
|
|
bool Flag::is_constant_in_binary() const {
|
|
|
|
#ifdef PRODUCT
|
|
|
|
return is_notproduct() || is_develop();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool Flag::is_unlocker() const {
|
2013-09-26 12:07:53 -07:00
|
|
|
return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 ||
|
|
|
|
strcmp(_name, "UnlockExperimentalVMOptions") == 0 ||
|
2011-12-05 12:50:00 -05:00
|
|
|
is_unlocker_ext();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Flag::is_unlocked() const {
|
2013-09-26 12:07:53 -07:00
|
|
|
if (is_diagnostic()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return UnlockDiagnosticVMOptions;
|
2013-09-26 12:07:53 -07:00
|
|
|
}
|
|
|
|
if (is_experimental()) {
|
2008-06-30 17:04:59 -07:00
|
|
|
return UnlockExperimentalVMOptions;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-09-26 12:07:53 -07:00
|
|
|
return is_unlocked_ext();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 16:46:39 -04:00
|
|
|
// Get custom message for this locked flag, or return NULL if
|
|
|
|
// none is available.
|
|
|
|
void Flag::get_locked_message(char* buf, int buflen) const {
|
2014-01-16 10:51:16 -08:00
|
|
|
buf[0] = '\0';
|
|
|
|
if (is_diagnostic() && !is_unlocked()) {
|
|
|
|
jio_snprintf(buf, buflen, "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n",
|
|
|
|
_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (is_experimental() && !is_unlocked()) {
|
|
|
|
jio_snprintf(buf, buflen, "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n",
|
|
|
|
_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (is_develop() && is_product_build()) {
|
|
|
|
jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n",
|
|
|
|
_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (is_notproduct() && is_product_build()) {
|
|
|
|
jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n",
|
|
|
|
_name);
|
|
|
|
return;
|
|
|
|
}
|
2012-03-20 16:46:39 -04:00
|
|
|
get_locked_message_ext(buf, buflen);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool Flag::is_writeable() const {
|
2013-09-26 12:07:53 -07:00
|
|
|
return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 15:50:47 -05:00
|
|
|
// All flags except "manageable" are assumed to be internal flags.
|
2007-12-01 00:00:00 +00:00
|
|
|
// Long term, we need to define a mechanism to specify which flags
|
|
|
|
// are external/stable and change this function accordingly.
|
|
|
|
bool Flag::is_external() const {
|
2013-09-26 12:07:53 -07:00
|
|
|
return is_manageable() || is_external_ext();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 15:50:47 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Length of format string (e.g. "%.1234s") for printing ccstr below
|
|
|
|
#define FORMAT_BUFFER_LEN 16
|
|
|
|
|
2010-08-31 03:14:00 -07:00
|
|
|
void Flag::print_on(outputStream* st, bool withComments) {
|
2013-09-26 12:07:53 -07:00
|
|
|
// Don't print notproduct and develop flags in a product build.
|
|
|
|
if (is_constant_in_binary()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-08-31 03:14:00 -07:00
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' '));
|
|
|
|
|
|
|
|
if (is_bool()) {
|
|
|
|
st->print("%-16s", get_bool() ? "true" : "false");
|
|
|
|
}
|
|
|
|
if (is_intx()) {
|
|
|
|
st->print("%-16ld", get_intx());
|
|
|
|
}
|
|
|
|
if (is_uintx()) {
|
|
|
|
st->print("%-16lu", get_uintx());
|
|
|
|
}
|
|
|
|
if (is_uint64_t()) {
|
|
|
|
st->print("%-16lu", get_uint64_t());
|
|
|
|
}
|
|
|
|
if (is_double()) {
|
|
|
|
st->print("%-16f", get_double());
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if (is_ccstr()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
const char* cp = get_ccstr();
|
|
|
|
if (cp != NULL) {
|
|
|
|
const char* eol;
|
|
|
|
while ((eol = strchr(cp, '\n')) != NULL) {
|
|
|
|
char format_buffer[FORMAT_BUFFER_LEN];
|
|
|
|
size_t llen = pointer_delta(eol, cp, sizeof(char));
|
|
|
|
jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
|
|
|
|
"%%." SIZE_FORMAT "s", llen);
|
|
|
|
st->print(format_buffer, cp);
|
|
|
|
st->cr();
|
|
|
|
cp = eol+1;
|
|
|
|
st->print("%5s %-35s += ", "", _name);
|
|
|
|
}
|
|
|
|
st->print("%-16s", cp);
|
|
|
|
}
|
|
|
|
else st->print("%-16s", "");
|
2010-08-31 03:14:00 -07:00
|
|
|
}
|
2013-09-26 12:07:53 -07:00
|
|
|
|
2013-12-16 10:57:08 -08:00
|
|
|
st->print("%-20s", " ");
|
2013-09-26 12:07:53 -07:00
|
|
|
print_kind(st);
|
|
|
|
|
2010-08-31 03:14:00 -07:00
|
|
|
if (withComments) {
|
|
|
|
#ifndef PRODUCT
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("%s", _doc);
|
2010-08-31 03:14:00 -07:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void Flag::print_kind(outputStream* st) {
|
|
|
|
struct Data {
|
|
|
|
int flag;
|
|
|
|
const char* name;
|
|
|
|
};
|
|
|
|
|
|
|
|
Data data[] = {
|
|
|
|
{ KIND_C1, "C1" },
|
|
|
|
{ KIND_C2, "C2" },
|
|
|
|
{ KIND_ARCH, "ARCH" },
|
|
|
|
{ KIND_SHARK, "SHARK" },
|
|
|
|
{ KIND_PLATFORM_DEPENDENT, "pd" },
|
|
|
|
{ KIND_PRODUCT, "product" },
|
|
|
|
{ KIND_MANAGEABLE, "manageable" },
|
|
|
|
{ KIND_DIAGNOSTIC, "diagnostic" },
|
2013-11-18 08:21:19 +01:00
|
|
|
{ KIND_EXPERIMENTAL, "experimental" },
|
|
|
|
{ KIND_COMMERCIAL, "commercial" },
|
2013-09-26 12:07:53 -07:00
|
|
|
{ KIND_NOT_PRODUCT, "notproduct" },
|
|
|
|
{ KIND_DEVELOP, "develop" },
|
|
|
|
{ KIND_LP64_PRODUCT, "lp64_product" },
|
|
|
|
{ KIND_READ_WRITE, "rw" },
|
|
|
|
{ -1, "" }
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((_flags & KIND_MASK) != 0) {
|
|
|
|
st->print("{");
|
|
|
|
bool is_first = true;
|
|
|
|
|
|
|
|
for (int i = 0; data[i].flag != -1; i++) {
|
|
|
|
Data d = data[i];
|
|
|
|
if ((_flags & d.flag) != 0) {
|
|
|
|
if (is_first) {
|
|
|
|
is_first = false;
|
|
|
|
} else {
|
|
|
|
st->print(" ");
|
|
|
|
}
|
|
|
|
st->print(d.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
st->print("}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void Flag::print_as_flag(outputStream* st) {
|
|
|
|
if (is_bool()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else if (is_intx()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("-XX:%s=" INTX_FORMAT, _name, get_intx());
|
2007-12-01 00:00:00 +00:00
|
|
|
} else if (is_uintx()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx());
|
2009-11-04 16:49:23 -05:00
|
|
|
} else if (is_uint64_t()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t());
|
2012-05-10 14:16:34 +02:00
|
|
|
} else if (is_double()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("-XX:%s=%f", _name, get_double());
|
2007-12-01 00:00:00 +00:00
|
|
|
} else if (is_ccstr()) {
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print("-XX:%s=", _name);
|
2008-04-03 10:20:44 -07:00
|
|
|
const char* cp = get_ccstr();
|
|
|
|
if (cp != NULL) {
|
|
|
|
// Need to turn embedded '\n's back into separate arguments
|
|
|
|
// Not so efficient to print one character at a time,
|
|
|
|
// but the choice is to do the transformation to a buffer
|
|
|
|
// and print that. And this need not be efficient.
|
|
|
|
for (; *cp != '\0'; cp += 1) {
|
|
|
|
switch (*cp) {
|
|
|
|
default:
|
|
|
|
st->print("%c", *cp);
|
|
|
|
break;
|
|
|
|
case '\n':
|
2013-09-26 12:07:53 -07:00
|
|
|
st->print(" -XX:%s=", _name);
|
2008-04-03 10:20:44 -07:00
|
|
|
break;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 4991491 do not "optimize out" the was_set false values: omitting them
|
|
|
|
// tickles a Microsoft compiler bug causing flagTable to be malformed
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
#define NAME(name) NOT_PRODUCT(&name) PRODUCT_ONLY(&CONST_##name)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
#define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) },
|
|
|
|
#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) },
|
|
|
|
#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) },
|
|
|
|
#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) },
|
|
|
|
#define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#ifdef _LP64
|
2013-09-26 12:07:53 -07:00
|
|
|
#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) },
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#else
|
2013-09-26 12:07:53 -07:00
|
|
|
#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#endif // _LP64
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
|
|
|
#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) },
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
static Flag flagTable[] = {
|
2011-11-30 12:48:52 -05:00
|
|
|
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)
|
2007-12-01 00:00:00 +00:00
|
|
|
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)
|
2013-01-23 13:02:39 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2008-06-30 17:04:59 -07:00
|
|
|
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)
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef COMPILER1
|
2013-08-21 13:34:45 +02:00
|
|
|
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)
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
#ifdef COMPILER2
|
2009-11-12 09:24:21 -08:00
|
|
|
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)
|
2010-08-11 05:51:21 -07:00
|
|
|
#endif
|
|
|
|
#ifdef SHARK
|
|
|
|
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)
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
2012-08-27 15:17:17 -07:00
|
|
|
ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, ARCH_PRODUCT_FLAG_STRUCT, ARCH_DIAGNOSTIC_FLAG_STRUCT, ARCH_EXPERIMENTAL_FLAG_STRUCT, ARCH_NOTPRODUCT_FLAG_STRUCT)
|
2011-12-05 12:50:00 -05:00
|
|
|
FLAGTABLE_EXT
|
2007-12-01 00:00:00 +00:00
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
Flag* Flag::flags = flagTable;
|
|
|
|
size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag));
|
|
|
|
|
2013-06-28 20:18:04 -07:00
|
|
|
inline bool str_equal(const char* s, const char* q, size_t len) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// s is null terminated, q is not!
|
|
|
|
if (strlen(s) != (unsigned int) len) return false;
|
|
|
|
return strncmp(s, q, len) == 0;
|
|
|
|
}
|
|
|
|
|
2012-03-20 16:46:39 -04:00
|
|
|
// Search the flag table for a named flag
|
2014-01-16 10:51:16 -08:00
|
|
|
Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
|
2013-09-26 12:07:53 -07:00
|
|
|
for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
|
|
|
|
if (str_equal(current->_name, name, length)) {
|
|
|
|
// Found a matching entry.
|
|
|
|
// Don't report notproduct and develop flags in product builds.
|
|
|
|
if (current->is_constant_in_binary()) {
|
2014-01-16 10:51:16 -08:00
|
|
|
return (return_flag == true ? current : NULL);
|
2013-09-26 12:07:53 -07:00
|
|
|
}
|
|
|
|
// Report locked flags only if allowed.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!(current->is_unlocked() || current->is_unlocker())) {
|
2012-03-20 16:46:39 -04:00
|
|
|
if (!allow_locked) {
|
|
|
|
// disable use of locked flags, e.g. diagnostic, experimental,
|
|
|
|
// commercial... until they are explicitly unlocked
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
}
|
2012-03-20 16:46:39 -04:00
|
|
|
// Flag name is not in the flag table
|
2007-12-01 00:00:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-28 20:18:04 -07:00
|
|
|
// Compute string similarity based on Dice's coefficient
|
|
|
|
static float str_similar(const char* str1, const char* str2, size_t len2) {
|
|
|
|
int len1 = (int) strlen(str1);
|
|
|
|
int total = len1 + (int) len2;
|
|
|
|
|
|
|
|
int hit = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < len1 -1; ++i) {
|
|
|
|
for (int j = 0; j < (int) len2 -1; ++j) {
|
|
|
|
if ((str1[i] == str2[j]) && (str1[i+1] == str2[j+1])) {
|
|
|
|
++hit;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 2.0f * (float) hit / (float) total;
|
|
|
|
}
|
|
|
|
|
|
|
|
Flag* Flag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
|
|
|
|
float VMOptionsFuzzyMatchSimilarity = 0.7f;
|
|
|
|
Flag* match = NULL;
|
|
|
|
float score;
|
|
|
|
float max_score = -1;
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
|
|
|
|
score = str_similar(current->_name, name, length);
|
2013-06-28 20:18:04 -07:00
|
|
|
if (score > max_score) {
|
|
|
|
max_score = score;
|
|
|
|
match = current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(match->is_unlocked() || match->is_unlocker())) {
|
|
|
|
if (!allow_locked) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (max_score < VMOptionsFuzzyMatchSimilarity) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Returns the address of the index'th element
|
|
|
|
static Flag* address_of_flag(CommandLineFlagWithType flag) {
|
|
|
|
assert((size_t)flag < Flag::numFlags, "bad command line flag index");
|
|
|
|
return &Flag::flags[flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CommandLineFlagsEx::is_default(CommandLineFlag flag) {
|
|
|
|
assert((size_t)flag < Flag::numFlags, "bad command line flag index");
|
|
|
|
Flag* f = &Flag::flags[flag];
|
2013-09-26 12:07:53 -07:00
|
|
|
return f->is_default();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-03-02 16:10:12 -08:00
|
|
|
bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) {
|
|
|
|
assert((size_t)flag < Flag::numFlags, "bad command line flag index");
|
|
|
|
Flag* f = &Flag::flags[flag];
|
2013-09-26 12:07:53 -07:00
|
|
|
return f->is_ergonomic();
|
2008-03-02 16:10:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
|
|
|
|
assert((size_t)flag < Flag::numFlags, "bad command line flag index");
|
|
|
|
Flag* f = &Flag::flags[flag];
|
2013-09-26 12:07:53 -07:00
|
|
|
return f->is_command_line();
|
2008-03-02 16:10:12 -08:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
|
|
|
|
Flag* result = Flag::find_flag((char*)name, strlen(name));
|
|
|
|
if (result == NULL) return false;
|
2013-09-26 12:07:53 -07:00
|
|
|
*value = result->is_command_line();
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-23 08:12:12 +01:00
|
|
|
template<class E, class T>
|
|
|
|
static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin)
|
|
|
|
{
|
|
|
|
E e;
|
|
|
|
e.set_name(name);
|
|
|
|
e.set_old_value(old_value);
|
|
|
|
e.set_new_value(new_value);
|
|
|
|
e.set_origin(origin);
|
|
|
|
e.commit();
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) {
|
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_bool()) return false;
|
|
|
|
*value = result->get_bool();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_bool()) return false;
|
|
|
|
bool old_value = result->get_bool();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
result->set_bool(*value);
|
|
|
|
*value = old_value;
|
2013-09-26 12:07:53 -07:00
|
|
|
result->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* faddr = address_of_flag(flag);
|
|
|
|
guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
faddr->set_bool(value);
|
2013-09-26 12:07:53 -07:00
|
|
|
faddr->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) {
|
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_intx()) return false;
|
|
|
|
*value = result->get_intx();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_intx()) return false;
|
|
|
|
intx old_value = result->get_intx();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
result->set_intx(*value);
|
|
|
|
*value = old_value;
|
2013-09-26 12:07:53 -07:00
|
|
|
result->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* faddr = address_of_flag(flag);
|
|
|
|
guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
faddr->set_intx(value);
|
2013-09-26 12:07:53 -07:00
|
|
|
faddr->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) {
|
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_uintx()) return false;
|
|
|
|
*value = result->get_uintx();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_uintx()) return false;
|
|
|
|
uintx old_value = result->get_uintx();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
result->set_uintx(*value);
|
|
|
|
*value = old_value;
|
2013-09-26 12:07:53 -07:00
|
|
|
result->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* faddr = address_of_flag(flag);
|
|
|
|
guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
faddr->set_uintx(value);
|
2013-09-26 12:07:53 -07:00
|
|
|
faddr->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 16:25:51 -04:00
|
|
|
bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) {
|
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_uint64_t()) return false;
|
|
|
|
*value = result->get_uint64_t();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) {
|
2009-10-28 16:25:51 -04:00
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_uint64_t()) return false;
|
|
|
|
uint64_t old_value = result->get_uint64_t();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
|
2009-10-28 16:25:51 -04:00
|
|
|
result->set_uint64_t(*value);
|
|
|
|
*value = old_value;
|
2013-09-26 12:07:53 -07:00
|
|
|
result->set_origin(origin);
|
2009-10-28 16:25:51 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
|
2009-10-28 16:25:51 -04:00
|
|
|
Flag* faddr = address_of_flag(flag);
|
|
|
|
guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
|
2009-10-28 16:25:51 -04:00
|
|
|
faddr->set_uint64_t(value);
|
2013-09-26 12:07:53 -07:00
|
|
|
faddr->set_origin(origin);
|
2009-10-28 16:25:51 -04:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) {
|
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_double()) return false;
|
|
|
|
*value = result->get_double();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_double()) return false;
|
|
|
|
double old_value = result->get_double();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
result->set_double(*value);
|
|
|
|
*value = old_value;
|
2013-09-26 12:07:53 -07:00
|
|
|
result->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* faddr = address_of_flag(flag);
|
|
|
|
guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
faddr->set_double(value);
|
2013-09-26 12:07:53 -07:00
|
|
|
faddr->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) {
|
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_ccstr()) return false;
|
|
|
|
*value = result->get_ccstr();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* result = Flag::find_flag(name, len);
|
|
|
|
if (result == NULL) return false;
|
|
|
|
if (!result->is_ccstr()) return false;
|
|
|
|
ccstr old_value = result->get_ccstr();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
|
2008-09-25 12:50:51 -07:00
|
|
|
char* new_value = NULL;
|
|
|
|
if (*value != NULL) {
|
2012-06-28 17:03:16 -04:00
|
|
|
new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
|
2008-09-25 12:50:51 -07:00
|
|
|
strcpy(new_value, *value);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
result->set_ccstr(new_value);
|
2013-09-26 12:07:53 -07:00
|
|
|
if (result->is_default() && old_value != NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Prior value is NOT heap allocated, but was a literal constant.
|
2012-06-28 17:03:16 -04:00
|
|
|
char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
strcpy(old_value_to_free, old_value);
|
|
|
|
old_value = old_value_to_free;
|
|
|
|
}
|
|
|
|
*value = old_value;
|
2013-09-26 12:07:53 -07:00
|
|
|
result->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
|
2007-12-01 00:00:00 +00:00
|
|
|
Flag* faddr = address_of_flag(flag);
|
|
|
|
guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
|
|
|
|
ccstr old_value = faddr->get_ccstr();
|
2014-01-23 08:12:12 +01:00
|
|
|
trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin);
|
2012-06-28 17:03:16 -04:00
|
|
|
char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
strcpy(new_value, value);
|
|
|
|
faddr->set_ccstr(new_value);
|
2013-09-26 12:07:53 -07:00
|
|
|
if (!faddr->is_default() && old_value != NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Prior value is heap allocated so free it.
|
2012-06-28 17:03:16 -04:00
|
|
|
FREE_C_HEAP_ARRAY(char, old_value, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-09-26 12:07:53 -07:00
|
|
|
faddr->set_origin(origin);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
static int compare_flags(const void* void_a, const void* void_b) {
|
2013-09-26 12:07:53 -07:00
|
|
|
return strcmp((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-09 10:27:24 +01:00
|
|
|
void CommandLineFlags::printSetFlags(outputStream* out) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Print which flags were set on the command line
|
|
|
|
// note: this method is called before the thread structure is in place
|
|
|
|
// which means resource allocation cannot be used.
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
// The last entry is the null entry.
|
|
|
|
const size_t length = Flag::numFlags - 1;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Sort
|
2012-06-28 17:03:16 -04:00
|
|
|
Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
|
2013-09-26 12:07:53 -07:00
|
|
|
for (size_t i = 0; i < length; i++) {
|
|
|
|
array[i] = &flagTable[i];
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
qsort(array, length, sizeof(Flag*), compare_flags);
|
|
|
|
|
|
|
|
// Print
|
2013-09-26 12:07:53 -07:00
|
|
|
for (size_t i = 0; i < length; i++) {
|
|
|
|
if (array[i]->get_origin() /* naked field! */) {
|
2012-01-09 10:27:24 +01:00
|
|
|
array[i]->print_as_flag(out);
|
|
|
|
out->print(" ");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-09 10:27:24 +01:00
|
|
|
out->cr();
|
2012-06-28 17:03:16 -04:00
|
|
|
FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
|
|
|
|
|
|
|
void CommandLineFlags::verify() {
|
|
|
|
assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict");
|
|
|
|
}
|
|
|
|
|
2010-01-07 16:24:17 -08:00
|
|
|
#endif // PRODUCT
|
|
|
|
|
2012-01-09 10:27:24 +01:00
|
|
|
void CommandLineFlags::printFlags(outputStream* out, bool withComments) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Print the flags sorted by name
|
|
|
|
// note: this method is called before the thread structure is in place
|
|
|
|
// which means resource allocation cannot be used.
|
|
|
|
|
2013-09-26 12:07:53 -07:00
|
|
|
// The last entry is the null entry.
|
|
|
|
const size_t length = Flag::numFlags - 1;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Sort
|
2012-06-28 17:03:16 -04:00
|
|
|
Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
|
2013-09-26 12:07:53 -07:00
|
|
|
for (size_t i = 0; i < length; i++) {
|
|
|
|
array[i] = &flagTable[i];
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
qsort(array, length, sizeof(Flag*), compare_flags);
|
|
|
|
|
|
|
|
// Print
|
2012-01-09 10:27:24 +01:00
|
|
|
out->print_cr("[Global flags]");
|
2013-09-26 12:07:53 -07:00
|
|
|
for (size_t i = 0; i < length; i++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (array[i]->is_unlocked()) {
|
2012-01-09 10:27:24 +01:00
|
|
|
array[i]->print_on(out, withComments);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-28 17:03:16 -04:00
|
|
|
FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|