diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 432b1a47bd0..c6e23d3ce17 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -3384,7 +3384,7 @@ void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) { // Notify the runtime very infrequently only to take care of counter overflows int freq_log = Tier23InlineeNotifyFreqLog; double scale; - if (_method->has_option_value("CompileThresholdScaling", scale)) { + if (_method->has_option_value(CompileCommand::CompileThresholdScaling, scale)) { freq_log = CompilerConfig::scaled_freq_log(freq_log, scale); } increment_event_counter_impl(info, x->inlinee(), LIR_OprFact::intConst(InvocationCounter::count_increment), right_n_bits(freq_log), InvocationEntryBci, false, true); @@ -3425,7 +3425,7 @@ void LIRGenerator::increment_event_counter(CodeEmitInfo* info, LIR_Opr step, int } // Increment the appropriate invocation/backedge counter and notify the runtime. double scale; - if (_method->has_option_value("CompileThresholdScaling", scale)) { + if (_method->has_option_value(CompileCommand::CompileThresholdScaling, scale)) { freq_log = CompilerConfig::scaled_freq_log(freq_log, scale); } increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true); diff --git a/src/hotspot/share/ci/ciMethod.cpp b/src/hotspot/share/ci/ciMethod.cpp index ed9c821f347..7c60456f701 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -1043,17 +1043,17 @@ MethodCounters* ciMethod::ensure_method_counters() { // ------------------------------------------------------------------ // ciMethod::has_option // -bool ciMethod::has_option(const char* option) { +bool ciMethod::has_option(enum CompileCommand option) { check_is_loaded(); VM_ENTRY_MARK; methodHandle mh(THREAD, get_Method()); - return CompilerOracle::has_option_string(mh, option); + return CompilerOracle::has_option(mh, option); } // ------------------------------------------------------------------ // ciMethod::has_option_value // -bool ciMethod::has_option_value(const char* option, double& value) { +bool ciMethod::has_option_value(enum CompileCommand option, double& value) { check_is_loaded(); VM_ENTRY_MARK; methodHandle mh(THREAD, get_Method()); diff --git a/src/hotspot/share/ci/ciMethod.hpp b/src/hotspot/share/ci/ciMethod.hpp index 3aa3d536df5..4507598afbf 100644 --- a/src/hotspot/share/ci/ciMethod.hpp +++ b/src/hotspot/share/ci/ciMethod.hpp @@ -293,8 +293,8 @@ class ciMethod : public ciMetadata { // Find the proper vtable index to invoke this method. int resolve_vtable_index(ciKlass* caller, ciKlass* receiver); - bool has_option(const char *option); - bool has_option_value(const char* option, double& value); + bool has_option(enum CompileCommand option); + bool has_option_value(enum CompileCommand option, double& value); bool can_be_compiled(); bool can_be_parsed() const { return _can_be_parsed; } bool has_compiled_code(); diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 87158b41568..2971733e883 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -978,15 +978,15 @@ void nmethod::print_nmethod(bool printmethod) { #if defined(SUPPORT_DATA_STRUCTS) if (AbstractDisassembler::show_structs()) { methodHandle mh(Thread::current(), _method); - if (printmethod || PrintDebugInfo || CompilerOracle::has_option_string(mh, "PrintDebugInfo")) { + if (printmethod || PrintDebugInfo || CompilerOracle::has_option(mh, CompileCommand::PrintDebugInfo)) { print_scopes(); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); } - if (printmethod || PrintRelocations || CompilerOracle::has_option_string(mh, "PrintRelocations")) { + if (printmethod || PrintRelocations || CompilerOracle::has_option(mh, CompileCommand::PrintRelocations)) { print_relocations(); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); } - if (printmethod || PrintDependencies || CompilerOracle::has_option_string(mh, "PrintDependencies")) { + if (printmethod || PrintDependencies || CompilerOracle::has_option(mh, CompileCommand::PrintDependencies)) { print_dependencies(); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); } diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index f29497a0d42..08f52c365c5 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -1585,8 +1585,8 @@ bool CompileBroker::compilation_is_prohibited(const methodHandle& method, int os // The method may be explicitly excluded by the user. double scale; - if (excluded || (CompilerOracle::has_option_value(method, "CompileThresholdScaling", scale) && scale == 0)) { - bool quietly = CompilerOracle::should_exclude_quietly(); + if (excluded || (CompilerOracle::has_option_value(method, CompileCommand::CompileThresholdScaling, scale) && scale == 0)) { + bool quietly = CompilerOracle::be_quiet(); if (PrintCompilation && !quietly) { // This does not happen quietly... ResourceMark rm; diff --git a/src/hotspot/share/compiler/compilerDirectives.cpp b/src/hotspot/share/compiler/compilerDirectives.cpp index 753f9798a83..bc9d8a8b67e 100644 --- a/src/hotspot/share/compiler/compilerDirectives.cpp +++ b/src/hotspot/share/compiler/compilerDirectives.cpp @@ -140,7 +140,7 @@ bool CompilerDirectives::match(const methodHandle& method) { } bool CompilerDirectives::add_match(char* str, const char*& error_msg) { - BasicMatcher* bm = BasicMatcher::parse_method_pattern(str, error_msg); + BasicMatcher* bm = BasicMatcher::parse_method_pattern(str, error_msg, false); if (bm == NULL) { assert(error_msg != NULL, "Must have error message"); return false; @@ -326,7 +326,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle // Early bail out - checking all options is expensive - we rely on them not being used // Only set a flag if it has not been modified and value changes. // Only copy set if a flag needs to be set - if (!CompilerDirectivesIgnoreCompileCommandsOption && CompilerOracle::has_any_option()) { + if (!CompilerDirectivesIgnoreCompileCommandsOption && CompilerOracle::has_any_command_set()) { DirectiveSetPtr set(this); // All CompileCommands are not equal so this gets a bit verbose @@ -359,8 +359,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle } // inline and dontinline (including exclude) are implemented in the directiveset accessors - // ignore flags whose cc_flags are X -#define init_default_cc(name, type, dvalue, cc_flag) { type v; if (!_modified[name##Index] && CompilerOracle::has_option_value(method, #cc_flag, v) && v != this->name##Option) { set.cloned()->name##Option = v; } } +#define init_default_cc(name, type, dvalue, cc_flag) { type v; if (!_modified[name##Index] && CompilerOracle::has_option_value(method, CompileCommand::cc_flag, v) && v != this->name##Option) { set.cloned()->name##Option = v; } } compilerdirectives_common_flags(init_default_cc) compilerdirectives_c2_flags(init_default_cc) compilerdirectives_c1_flags(init_default_cc) @@ -370,7 +369,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle bool need_reset = true; // if Control/DisableIntrinsic redefined, only need to reset control_words once if (!_modified[ControlIntrinsicIndex] && - CompilerOracle::has_option_value(method, "ControlIntrinsic", option_value)) { + CompilerOracle::has_option_value(method, CompileCommand::ControlIntrinsic, option_value)) { ControlIntrinsicIter iter(option_value); if (need_reset) { @@ -390,7 +389,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle if (!_modified[DisableIntrinsicIndex] && - CompilerOracle::has_option_value(method, "DisableIntrinsic", option_value)) { + CompilerOracle::has_option_value(method, CompileCommand::DisableIntrinsic, option_value)) { ControlIntrinsicIter iter(option_value, true/*disable_all*/); if (need_reset) { diff --git a/src/hotspot/share/compiler/compilerDirectives.hpp b/src/hotspot/share/compiler/compilerDirectives.hpp index a67e534a9b2..687167156e9 100644 --- a/src/hotspot/share/compiler/compilerDirectives.hpp +++ b/src/hotspot/share/compiler/compilerDirectives.hpp @@ -34,11 +34,11 @@ // Directives flag name, type, default value, compile command name #define compilerdirectives_common_flags(cflags) \ - cflags(Enable, bool, false, X) \ - cflags(Exclude, bool, false, X) \ + cflags(Enable, bool, false, Unknown) \ + cflags(Exclude, bool, false, Unknown) \ cflags(BreakAtExecute, bool, false, BreakAtExecute) \ cflags(BreakAtCompile, bool, false, BreakAtCompile) \ - cflags(Log, bool, LogCompilation, X) \ + cflags(Log, bool, LogCompilation, Unknown) \ cflags(PrintAssembly, bool, PrintAssembly, PrintAssembly) \ cflags(PrintInlining, bool, PrintInlining, PrintInlining) \ cflags(PrintNMethods, bool, PrintNMethods, PrintNMethods) \ @@ -46,7 +46,7 @@ cflags(ReplayInline, bool, false, ReplayInline) \ cflags(DumpReplay, bool, false, DumpReplay) \ cflags(DumpInline, bool, false, DumpInline) \ - cflags(CompilerDirectivesIgnoreCompileCommands, bool, CompilerDirectivesIgnoreCompileCommands, X) \ + cflags(CompilerDirectivesIgnoreCompileCommands, bool, CompilerDirectivesIgnoreCompileCommands, Unknown) \ cflags(DisableIntrinsic, ccstrlist, DisableIntrinsic, DisableIntrinsic) \ cflags(ControlIntrinsic, ccstrlist, ControlIntrinsic, ControlIntrinsic) \ cflags(RepeatCompilation, intx, RepeatCompilation, RepeatCompilation) diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp index f6880786dfc..878b6592170 100644 --- a/src/hotspot/share/compiler/compilerOracle.cpp +++ b/src/hotspot/share/compiler/compilerOracle.cpp @@ -38,83 +38,72 @@ #include "runtime/jniHandles.hpp" #include "runtime/os.hpp" -enum OptionType { - IntxType, - UintxType, - BoolType, - CcstrType, - DoubleType, - UnknownType +static const char* optiontype_names[] = { +#define enum_of_types(type, name) name, + OPTION_TYPES(enum_of_types) +#undef enum_of_types }; +const char* optiontype2name(enum OptionType type) { + return optiontype_names[static_cast(type)]; +} + +static enum OptionType option_types[] = { +#define enum_of_options(option, name, ctype) OptionType::ctype, + COMPILECOMMAND_OPTIONS(enum_of_options) +#undef enum_of_options +}; + +enum OptionType option2type(enum CompileCommand option) { + return option_types[static_cast(option)]; +} + +static const char* option_names[] = { +#define enum_of_options(option, name, ctype) name, + COMPILECOMMAND_OPTIONS(enum_of_options) +#undef enum_of_options +}; + +const char* option2name(enum CompileCommand option) { + return option_names[static_cast(option)]; +} + /* Methods to map real type names to OptionType */ template static OptionType get_type_for() { - return UnknownType; + return OptionType::Unknown; }; template<> OptionType get_type_for() { - return IntxType; + return OptionType::Intx; } template<> OptionType get_type_for() { - return UintxType; + return OptionType::Uintx; } template<> OptionType get_type_for() { - return BoolType; + return OptionType::Bool; } template<> OptionType get_type_for() { - return CcstrType; + return OptionType::Ccstr; } template<> OptionType get_type_for() { - return DoubleType; + return OptionType::Double; } -// this must parallel the command_names below -enum OracleCommand { - UnknownCommand = -1, - OracleFirstCommand = 0, - BreakCommand = OracleFirstCommand, - PrintCommand, - ExcludeCommand, - InlineCommand, - DontInlineCommand, - CompileOnlyCommand, - LogCommand, - OptionCommand, - QuietCommand, - HelpCommand, - OracleCommandCount -}; - -// this must parallel the enum OracleCommand -static const char * command_names[] = { - "break", - "print", - "exclude", - "inline", - "dontinline", - "compileonly", - "log", - "option", - "quiet", - "help" -}; - class MethodMatcher; class TypedMethodOptionMatcher; -static BasicMatcher* lists[OracleCommandCount] = { 0, }; static TypedMethodOptionMatcher* option_list = NULL; static bool any_set = false; class TypedMethodOptionMatcher : public MethodMatcher { private: TypedMethodOptionMatcher* _next; - const char* _option; + enum CompileCommand _option; OptionType _type; public: @@ -128,29 +117,36 @@ class TypedMethodOptionMatcher : public MethodMatcher { TypedMethodOptionMatcher() : MethodMatcher(), _next(NULL), - _type(UnknownType) { - _option = NULL; + _option(CompileCommand::Unknown), + _type(OptionType::Unknown) { memset(&_u, 0, sizeof(_u)); } - static TypedMethodOptionMatcher* parse_method_pattern(char*& line, const char*& error_msg); - TypedMethodOptionMatcher* match(const methodHandle& method, const char* opt, OptionType type); + ~TypedMethodOptionMatcher(); + static TypedMethodOptionMatcher* parse_method_pattern(char*& line, char* errorbuf, const int buf_size); + TypedMethodOptionMatcher* match(const methodHandle &method, enum CompileCommand option, OptionType type); - void init(const char* opt, OptionType type, TypedMethodOptionMatcher* next) { + void init(enum CompileCommand option, OptionType type, TypedMethodOptionMatcher* next) { _next = next; _type = type; - _option = os::strdup_check_oom(opt); + _option = option; + } + + void init_matcher(Symbol* class_name, Mode class_mode, + Symbol* method_name, Mode method_mode, + Symbol* signature) { + MethodMatcher::init(class_name, class_mode, method_name, method_mode, signature); } void set_next(TypedMethodOptionMatcher* next) {_next = next; } TypedMethodOptionMatcher* next() { return _next; } OptionType type() { return _type; } + enum CompileCommand option() { return _option; } template T value(); template void set_value(T value); void print(); void print_all(); TypedMethodOptionMatcher* clone(); - ~TypedMethodOptionMatcher(); }; // A few templated accessors instead of a full template class. @@ -197,21 +193,22 @@ template<> void TypedMethodOptionMatcher::set_value(ccstr value) { void TypedMethodOptionMatcher::print() { ttyLocker ttyl; print_base(tty); + const char* name = option2name(_option); switch (_type) { - case IntxType: - tty->print_cr(" intx %s = " INTX_FORMAT, _option, value()); + case OptionType::Intx: + tty->print_cr(" intx %s = " INTX_FORMAT, name, value()); break; - case UintxType: - tty->print_cr(" uintx %s = " UINTX_FORMAT, _option, value()); + case OptionType::Uintx: + tty->print_cr(" uintx %s = " UINTX_FORMAT, name, value()); break; - case BoolType: - tty->print_cr(" bool %s = %s", _option, value() ? "true" : "false"); + case OptionType::Bool: + tty->print_cr(" bool %s = %s", name, value() ? "true" : "false"); break; - case DoubleType: - tty->print_cr(" double %s = %f", _option, value()); + case OptionType::Double: + tty->print_cr(" double %s = %f", name, value()); break; - case CcstrType: - tty->print_cr(" const char* %s = '%s'", _option, value()); + case OptionType::Ccstr: + tty->print_cr(" const char* %s = '%s'", name, value()); break; default: ShouldNotReachHere(); @@ -247,36 +244,31 @@ TypedMethodOptionMatcher* TypedMethodOptionMatcher::clone() { } TypedMethodOptionMatcher::~TypedMethodOptionMatcher() { - if (type() == CcstrType) { + if (type() == OptionType::Ccstr) { ccstr v = value(); os::free((void*)v); } - - if (_option != NULL) { - os::free((void*)_option); - } } -TypedMethodOptionMatcher* TypedMethodOptionMatcher::parse_method_pattern(char*& line, const char*& error_msg) { - assert(error_msg == NULL, "Dont call here with error_msg already set"); +TypedMethodOptionMatcher* TypedMethodOptionMatcher::parse_method_pattern(char*& line, char* errorbuf, const int buf_size) { + assert(*errorbuf == '\0', "Dont call here with error_msg already set"); + const char* error_msg = NULL; TypedMethodOptionMatcher* tom = new TypedMethodOptionMatcher(); MethodMatcher::parse_method_pattern(line, error_msg, tom); if (error_msg != NULL) { + jio_snprintf(errorbuf, buf_size, error_msg); delete tom; return NULL; } return tom; } -TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& method, const char* opt, OptionType type) { +TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& method, enum CompileCommand option, OptionType type) { TypedMethodOptionMatcher* current = this; while (current != NULL) { - // Fastest compare first. - if (current->type() == type) { - if (strcmp(current->_option, opt) == 0) { - if (current->matches(method)) { - return current; - } + if (current->_option == option) { + if (current->matches(method)) { + return current; } } current = current->next(); @@ -285,40 +277,57 @@ TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& me } template -static void add_option_string(TypedMethodOptionMatcher* matcher, - const char* option, - T value) { +static void register_command(TypedMethodOptionMatcher* matcher, + enum CompileCommand option, + T value) { assert(matcher != option_list, "No circular lists please"); - matcher->init(option, get_type_for(), option_list); + if (option == CompileCommand::Log && !LogCompilation) { + tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged with "); + tty->print_cr(" CompileCommand=log,"); + } + enum OptionType type = option2type(option); + if (type == OptionType::Ccstrlist) { + type = OptionType::Ccstr; // ccstrlists are stores as ccstr + } + assert(type == get_type_for(), "sanity"); + matcher->init(option, type, option_list); matcher->set_value(value); option_list = matcher; - any_set = true; - return; -} - -static bool check_predicate(OracleCommand command, const methodHandle& method) { - return ((lists[command] != NULL) && - !method.is_null() && - lists[command]->match(method)); -} - -static void add_predicate(OracleCommand command, BasicMatcher* bm) { - assert(command != OptionCommand, "must use add_option_string"); - if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) { - tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged."); - } - bm->set_next(lists[command]); - lists[command] = bm; - if ((command != DontInlineCommand) && (command != InlineCommand)) { + if ((option != CompileCommand::DontInline) && + (option != CompileCommand::Inline) && + (option != CompileCommand::Log)) { any_set = true; } + if (!CompilerOracle::be_quiet()) { + // Print out the succesful registration of a comile command + ttyLocker ttyl; + tty->print("CompileCommand: %s ", option2name(option)); + matcher->print(); + } return; } template -bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, T& value) { +bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, T& value, bool verify_type) { + enum OptionType type = option2type(option); + if (type == OptionType::Unknown) { + return false; // Can't query options with type Unknown. + } + if (type == OptionType::Ccstrlist) { + type = OptionType::Ccstr; // CCstrList type options are stored as Ccstr + } + if (verify_type) { + if (type != get_type_for()) { + // Whitebox API expects false if option and type doesn't match + return false; + } + } else { + assert(type == get_type_for(), "Value type (%s) must match option %s (%s)", + optiontype2name(get_type_for()), + option2name(option), optiontype2name(option2type(option))); + } if (option_list != NULL) { - TypedMethodOptionMatcher* m = option_list->match(method, option, get_type_for()); + TypedMethodOptionMatcher* m = option_list->match(method, option, type); if (m != NULL) { value = m->value(); return true; @@ -327,98 +336,144 @@ bool CompilerOracle::has_option_value(const methodHandle& method, const char* op return false; } -bool CompilerOracle::has_any_option() { +static bool check_predicate(enum CompileCommand option, const methodHandle& method) { + bool value = false; + if (CompilerOracle::has_option_value(method, option, value)) { + return value; + } + return false; +} + +static bool has_command(enum CompileCommand option) { + TypedMethodOptionMatcher* m = option_list; + while (m != NULL) { + if (m->option() == option) { + return true; + } else { + m = m->next(); + } + } + return false; +} + +bool CompilerOracle::has_any_command_set() { return any_set; } // Explicit instantiation for all OptionTypes supported. -template bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, intx& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, uintx& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, bool& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, ccstr& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, double& value); +template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, intx& value, bool verify_type); +template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, uintx& value, bool verify_type); +template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, bool& value, bool verify_type); +template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, ccstr& value, bool verify_type); +template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, double& value, bool verify_type); -bool CompilerOracle::has_option_string(const methodHandle& method, const char* option) { +bool CompilerOracle::has_option(const methodHandle& method, enum CompileCommand option) { bool value = false; has_option_value(method, option, value); return value; } bool CompilerOracle::should_exclude(const methodHandle& method) { - if (check_predicate(ExcludeCommand, method)) { + if (check_predicate(CompileCommand::Exclude, method)) { return true; } - if (lists[CompileOnlyCommand] != NULL) { - return !lists[CompileOnlyCommand]->match(method); + if (has_command(CompileCommand::CompileOnly)) { + return !check_predicate(CompileCommand::CompileOnly, method); } return false; } bool CompilerOracle::should_inline(const methodHandle& method) { - return (check_predicate(InlineCommand, method)); + return (check_predicate(CompileCommand::Inline, method)); } bool CompilerOracle::should_not_inline(const methodHandle& method) { - return check_predicate(DontInlineCommand, method) || check_predicate(ExcludeCommand, method); + return check_predicate(CompileCommand::DontInline, method) || check_predicate(CompileCommand::Exclude, method); } bool CompilerOracle::should_print(const methodHandle& method) { - return check_predicate(PrintCommand, method); + return check_predicate(CompileCommand::Print, method); } bool CompilerOracle::should_print_methods() { - return lists[PrintCommand] != NULL; + return has_command(CompileCommand::Print); } bool CompilerOracle::should_log(const methodHandle& method) { - if (!LogCompilation) return false; - if (lists[LogCommand] == NULL) return true; // by default, log all - return (check_predicate(LogCommand, method)); + if (!LogCompilation) return false; + if (!has_command(CompileCommand::Log)) { + return true; // by default, log all + } + return (check_predicate(CompileCommand::Log, method)); } bool CompilerOracle::should_break_at(const methodHandle& method) { - return check_predicate(BreakCommand, method); + return check_predicate(CompileCommand::Break, method); } -static OracleCommand parse_command_name(const char * line, int* bytes_read) { - assert(ARRAY_SIZE(command_names) == OracleCommandCount, - "command_names size mismatch"); +static enum CompileCommand parse_option_name(const char* line, int* bytes_read, char* errorbuf, int bufsize) { + assert(ARRAY_SIZE(option_names) == static_cast(CompileCommand::Count), "option_names size mismatch"); *bytes_read = 0; - char command[33]; - int matches = sscanf(line, "%32[a-z]%n", command, bytes_read); + char option_buf[256]; + int matches = sscanf(line, "%255[a-zA-Z0-9]%n", option_buf, bytes_read); if (matches > 0) { - for (uint i = 0; i < ARRAY_SIZE(command_names); i++) { - if (strcmp(command, command_names[i]) == 0) { - return (OracleCommand)i; + for (uint i = 0; i < ARRAY_SIZE(option_names); i++) { + if (strcasecmp(option_buf, option_names[i]) == 0) { + return static_cast(i); } } } - return UnknownCommand; + jio_snprintf(errorbuf, bufsize, "Unrecognized option '%s'", option_buf); + return CompileCommand::Unknown; +} + +void print_tip() { // CMH Update info + tty->cr(); + tty->print_cr("Usage: '-XX:CompileCommand=