diff --git a/src/share/vm/ci/ciMethod.cpp b/src/share/vm/ci/ciMethod.cpp index 4244eab579e53c7cd76b8345d6cee3528307f882..476ae145e30c2c8f06d86677b03490625ecaca3f 100644 --- a/src/share/vm/ci/ciMethod.cpp +++ b/src/share/vm/ci/ciMethod.cpp @@ -1105,6 +1105,22 @@ bool ciMethod::has_option(const char* option) { return CompilerOracle::has_option_string(mh, option); } +// ------------------------------------------------------------------ +// ciMethod::has_option_value +// +template +bool ciMethod::has_option_value(const char* option, T& value) { + check_is_loaded(); + VM_ENTRY_MARK; + methodHandle mh(THREAD, get_Method()); + return CompilerOracle::has_option_value(mh, option, value); +} +// Explicit instantiation for all OptionTypes supported. +template bool ciMethod::has_option_value(const char* option, intx& value); +template bool ciMethod::has_option_value(const char* option, uintx& value); +template bool ciMethod::has_option_value(const char* option, bool& value); +template bool ciMethod::has_option_value(const char* option, ccstr& value); + // ------------------------------------------------------------------ // ciMethod::can_be_compiled // diff --git a/src/share/vm/ci/ciMethod.hpp b/src/share/vm/ci/ciMethod.hpp index 4092f691b9005980549e5d228c93b87c337c45ed..24eec2ad992734e24e18bac88cbb7b46d52088ba 100644 --- a/src/share/vm/ci/ciMethod.hpp +++ b/src/share/vm/ci/ciMethod.hpp @@ -264,6 +264,8 @@ class ciMethod : public ciMetadata { bool should_print_assembly(); bool break_at_execute(); bool has_option(const char *option); + template + bool has_option_value(const char* option, T& value); bool can_be_compiled(); bool can_be_osr_compiled(int entry_bci); void set_not_compilable(const char* reason = NULL); diff --git a/src/share/vm/compiler/compilerOracle.cpp b/src/share/vm/compiler/compilerOracle.cpp index 78a704df0e2e6ce8fd5d9bd6ffd2468d3c13a927..2e3ce877760d00f717a433b97c92f58222d54095 100644 --- a/src/share/vm/compiler/compilerOracle.cpp +++ b/src/share/vm/compiler/compilerOracle.cpp @@ -172,7 +172,6 @@ enum OptionType { UintxType, BoolType, CcstrType, - CcstrListType, UnknownType }; @@ -194,6 +193,19 @@ template<> OptionType get_type_for() { return BoolType; } +template<> OptionType get_type_for() { + return CcstrType; +} + +template +static const T copy_value(const T value) { + return value; +} + +template<> const ccstr copy_value(const ccstr value) { + return (const ccstr)strdup(value); +} + template class TypedMethodOptionMatcher : public MethodMatcher { const char* _option; @@ -206,7 +218,7 @@ public: Symbol* signature, const char* opt, const T value, MethodMatcher* next) : MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next), - _type(get_type_for()), _value(value) { + _type(get_type_for()), _value(copy_value(value)) { _option = strdup(opt); } @@ -252,8 +264,8 @@ template<> void TypedMethodOptionMatcher::print() { ttyLocker ttyl; print_base(); - tty->print(" %s", _option); - tty->print(" " INTX_FORMAT, _value); + tty->print(" intx %s", _option); + tty->print(" = " INTX_FORMAT, _value); tty->cr(); }; @@ -261,8 +273,8 @@ template<> void TypedMethodOptionMatcher::print() { ttyLocker ttyl; print_base(); - tty->print(" %s", _option); - tty->print(" " UINTX_FORMAT, _value); + tty->print(" uintx %s", _option); + tty->print(" = " UINTX_FORMAT, _value); tty->cr(); }; @@ -270,8 +282,17 @@ template<> void TypedMethodOptionMatcher::print() { ttyLocker ttyl; print_base(); - tty->print(" %s", _option); - tty->print(" %s", _value ? "true" : "false"); + tty->print(" bool %s", _option); + tty->print(" = %s", _value ? "true" : "false"); + tty->cr(); +}; + +template<> +void TypedMethodOptionMatcher::print() { + ttyLocker ttyl; + print_base(); + tty->print(" const char* %s", _option); + tty->print(" = '%s'", _value); tty->cr(); }; @@ -367,6 +388,7 @@ bool CompilerOracle::has_option_value(methodHandle method, const char* option, T template bool CompilerOracle::has_option_value(methodHandle method, const char* option, intx& value); template bool CompilerOracle::has_option_value(methodHandle method, const char* option, uintx& value); template bool CompilerOracle::has_option_value(methodHandle method, const char* option, bool& value); +template bool CompilerOracle::has_option_value(methodHandle method, const char* option, ccstr& value); bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) { quietly = true; @@ -558,12 +580,45 @@ static MethodMatcher* scan_flag_and_value(const char* type, const char* line, in } else { jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); } + } else if (strcmp(type, "ccstr") == 0) { + ResourceMark rm; + char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); + if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) { + total_bytes_read += bytes_read; + return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); + } else { + jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); + } + } else if (strcmp(type, "ccstrlist") == 0) { + // Accumulates several strings into one. The internal type is ccstr. + ResourceMark rm; + char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); + char* next_value = value; + if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { + total_bytes_read += bytes_read; + line += bytes_read; + next_value += bytes_read; + char* end_value = next_value-1; + while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { + total_bytes_read += bytes_read; + line += bytes_read; + *end_value = ' '; // override '\0' + next_value += bytes_read; + end_value = next_value-1; + } + return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); + } else { + jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); + } } else if (strcmp(type, "bool") == 0) { char value[256]; if (sscanf(line, "%*[ \t]%255[a-zA-Z]%n", value, &bytes_read) == 1) { if (strcmp(value, "true") == 0) { total_bytes_read += bytes_read; return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true); + } else if (strcmp(value, "false") == 0) { + total_bytes_read += bytes_read; + return add_option_string(c_name, c_match, m_name, m_match, signature, flag, false); } else { jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); } @@ -664,8 +719,7 @@ void CompilerOracle::parse_from_line(char* line) { // (i.e., to check if a flag "someflag" is enabled for a method). // // Type (2) is used to support options with a value. Values can have the - // the following types: intx, uintx, bool, ccstr, and ccstrlist. Currently, - // values of type intx, uintx, and bool are supported. + // the following types: intx, uintx, bool, ccstr, and ccstrlist. // // For future extensions: extend scan_flag_and_value() char option[256]; // stores flag for Type (1) and type of Type (2) diff --git a/src/share/vm/opto/compile.hpp b/src/share/vm/opto/compile.hpp index b00651202454302279e7f7d28e5c388dbf90eeb6..c7be16ee1b2ad2af0a5bb403fcc6d6d43f1e88ec 100644 --- a/src/share/vm/opto/compile.hpp +++ b/src/share/vm/opto/compile.hpp @@ -598,6 +598,10 @@ class Compile : public Phase { bool method_has_option(const char * option) { return method() != NULL && method()->has_option(option); } + template + bool method_has_option_value(const char * option, T& value) { + return method() != NULL && method()->has_option_value(option, value); + } #ifndef PRODUCT bool trace_opto_output() const { return _trace_opto_output; } bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }