diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 1cb350f1e39c4..cd08413565808 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -35,6 +35,7 @@ #include "ci/ciObjArray.hpp" #include "ci/ciUtilities.hpp" #include "compiler/compilerDefinitions.inline.hpp" +#include "compiler/compilerOracle.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/c1/barrierSetC1.hpp" #include "oops/klass.inline.hpp" @@ -3216,7 +3217,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(CompileCommand::CompileThresholdScaling, scale)) { + if (_method->has_option_value(CompileCommandEnum::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); @@ -3257,7 +3258,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(CompileCommand::CompileThresholdScaling, scale)) { + if (_method->has_option_value(CompileCommandEnum::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 0b41a257a4bf9..aac2a553cda31 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -36,6 +36,7 @@ #include "ci/ciUtilities.inline.hpp" #include "compiler/abstractCompiler.hpp" #include "compiler/compilerDefinitions.inline.hpp" +#include "compiler/compilerOracle.hpp" #include "compiler/methodLiveness.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" @@ -1062,7 +1063,7 @@ MethodCounters* ciMethod::ensure_method_counters() { // ------------------------------------------------------------------ // ciMethod::has_option // -bool ciMethod::has_option(enum CompileCommand option) { +bool ciMethod::has_option(CompileCommandEnum option) { check_is_loaded(); VM_ENTRY_MARK; methodHandle mh(THREAD, get_Method()); @@ -1072,7 +1073,7 @@ bool ciMethod::has_option(enum CompileCommand option) { // ------------------------------------------------------------------ // ciMethod::has_option_value // -bool ciMethod::has_option_value(enum CompileCommand option, double& value) { +bool ciMethod::has_option_value(CompileCommandEnum 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 0c171d0cf0b7c..a7c18b09f13eb 100644 --- a/src/hotspot/share/ci/ciMethod.hpp +++ b/src/hotspot/share/ci/ciMethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,10 @@ #include "ci/ciSignature.hpp" #include "classfile/vmIntrinsics.hpp" #include "compiler/methodLiveness.hpp" -#include "compiler/compilerOracle.hpp" #include "oops/method.hpp" #include "runtime/handles.hpp" #include "utilities/bitMap.hpp" +#include "utilities/vmEnums.hpp" class ciMethodBlocks; class MethodLiveness; @@ -303,8 +303,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(enum CompileCommand option); - bool has_option_value(enum CompileCommand option, double& value); + bool has_option(CompileCommandEnum option); + bool has_option_value(CompileCommandEnum 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 4b72c32c9cb13..ee57e11f9323c 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -36,6 +36,7 @@ #include "compiler/compileLog.hpp" #include "compiler/compileTask.hpp" #include "compiler/compilerDirectives.hpp" +#include "compiler/compilerOracle.hpp" #include "compiler/directivesParser.hpp" #include "compiler/disassembler.hpp" #include "compiler/oopMap.inline.hpp" @@ -1605,15 +1606,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(mh, CompileCommand::PrintDebugInfo)) { + if (printmethod || PrintDebugInfo || CompilerOracle::has_option(mh, CompileCommandEnum::PrintDebugInfo)) { print_scopes(); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); } - if (printmethod || PrintRelocations || CompilerOracle::has_option(mh, CompileCommand::PrintRelocations)) { + if (printmethod || PrintRelocations || CompilerOracle::has_option(mh, CompileCommandEnum::PrintRelocations)) { print_relocations(); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); } - if (printmethod || PrintDependencies || CompilerOracle::has_option(mh, CompileCommand::PrintDependencies)) { + if (printmethod || PrintDependencies || CompilerOracle::has_option(mh, CompileCommandEnum::PrintDependencies)) { print_dependencies_on(tty); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); } diff --git a/src/hotspot/share/compiler/compilationPolicy.cpp b/src/hotspot/share/compiler/compilationPolicy.cpp index 4fcd9b5bde43d..0e6d8f6a6c91b 100644 --- a/src/hotspot/share/compiler/compilationPolicy.cpp +++ b/src/hotspot/share/compiler/compilationPolicy.cpp @@ -229,7 +229,7 @@ class LoopPredicate : AllStatic { public: static bool apply_scaled(const methodHandle& method, CompLevel cur_level, int i, int b, double scale) { double threshold_scaling; - if (CompilerOracle::has_option_value(method, CompileCommand::CompileThresholdScaling, threshold_scaling)) { + if (CompilerOracle::has_option_value(method, CompileCommandEnum::CompileThresholdScaling, threshold_scaling)) { scale *= threshold_scaling; } switch(cur_level) { @@ -267,7 +267,7 @@ class CallPredicate : AllStatic { public: static bool apply_scaled(const methodHandle& method, CompLevel cur_level, int i, int b, double scale) { double threshold_scaling; - if (CompilerOracle::has_option_value(method, CompileCommand::CompileThresholdScaling, threshold_scaling)) { + if (CompilerOracle::has_option_value(method, CompileCommandEnum::CompileThresholdScaling, threshold_scaling)) { scale *= threshold_scaling; } switch(cur_level) { diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 61d5f9bd576c8..82f0996bc603e 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -1549,7 +1549,7 @@ 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, CompileCommand::CompileThresholdScaling, scale) && scale == 0)) { + if (excluded || (CompilerOracle::has_option_value(method, CompileCommandEnum::CompileThresholdScaling, scale) && scale == 0)) { bool quietly = CompilerOracle::be_quiet(); if (PrintCompilation && !quietly) { // This does not happen quietly... diff --git a/src/hotspot/share/compiler/compilerDirectives.cpp b/src/hotspot/share/compiler/compilerDirectives.cpp index 74a1076cc49bc..f5ccd9e69e929 100644 --- a/src/hotspot/share/compiler/compilerDirectives.cpp +++ b/src/hotspot/share/compiler/compilerDirectives.cpp @@ -426,7 +426,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle } // inline and dontinline (including exclude) are implemented in the directiveset accessors -#define init_default_cc(name, type, dvalue, cc_flag) { type v; if (!_modified[name##Index] && CompileCommand::cc_flag != CompileCommand::Unknown && CompilerOracle::has_option_value(method, CompileCommand::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] && CompileCommandEnum::cc_flag != CompileCommandEnum::Unknown && CompilerOracle::has_option_value(method, CompileCommandEnum::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) @@ -438,7 +438,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle if (!_modified[TraceAutoVectorizationIndex]) { // Parse ccstr and create mask ccstrlist option; - if (CompilerOracle::has_option_value(method, CompileCommand::TraceAutoVectorization, option)) { + if (CompilerOracle::has_option_value(method, CompileCommandEnum::TraceAutoVectorization, option)) { TraceAutoVectorizationTagValidator validator(option, false); if (validator.is_valid()) { set.cloned()->set_trace_auto_vectorization_tags(validator.tags()); @@ -448,7 +448,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle if (!_modified[PrintIdealPhaseIndex]) { // Parse ccstr and create set ccstrlist option; - if (CompilerOracle::has_option_value(method, CompileCommand::PrintIdealPhase, option)) { + if (CompilerOracle::has_option_value(method, CompileCommandEnum::PrintIdealPhase, option)) { PhaseNameValidator validator(option); if (validator.is_valid()) { assert(!validator.phase_name_set().is_empty(), "Phase name set must be non-empty"); @@ -464,7 +464,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, CompileCommand::ControlIntrinsic, option_value)) { + CompilerOracle::has_option_value(method, CompileCommandEnum::ControlIntrinsic, option_value)) { ControlIntrinsicIter iter(option_value); if (need_reset) { @@ -484,7 +484,7 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle if (!_modified[DisableIntrinsicIndex] && - CompilerOracle::has_option_value(method, CompileCommand::DisableIntrinsic, option_value)) { + CompilerOracle::has_option_value(method, CompileCommandEnum::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 6cd831c8d72a6..0b1090406b904 100644 --- a/src/hotspot/share/compiler/compilerDirectives.hpp +++ b/src/hotspot/share/compiler/compilerDirectives.hpp @@ -30,7 +30,6 @@ #include "ci/ciMethod.hpp" #include "compiler/compiler_globals.hpp" #include "compiler/methodMatcher.hpp" -#include "compiler/compilerOracle.hpp" #include "opto/phasetype.hpp" #include "utilities/bitMap.hpp" #include "utilities/exceptions.hpp" diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp index a8eee10fac539..ea09e3ebb7f75 100644 --- a/src/hotspot/share/compiler/compilerOracle.cpp +++ b/src/hotspot/share/compiler/compilerOracle.cpp @@ -58,7 +58,7 @@ static enum OptionType option_types[] = { #undef enum_of_options }; -static enum OptionType option2type(enum CompileCommand option) { +static enum OptionType option2type(CompileCommandEnum option) { return option_types[static_cast(option)]; } @@ -68,7 +68,7 @@ static const char* option_names[] = { #undef enum_of_options }; -static const char* option2name(enum CompileCommand option) { +static const char* option2name(CompileCommandEnum option) { return option_names[static_cast(option)]; } @@ -106,28 +106,28 @@ static bool any_set = false; static bool print_final_memstat_report = false; // A filter for quick lookup if an option is set -static bool option_filter[static_cast(CompileCommand::Unknown) + 1] = { 0 }; +static bool option_filter[static_cast(CompileCommandEnum::Unknown) + 1] = { 0 }; -static void command_set_in_filter(enum CompileCommand option) { - assert(option != CompileCommand::Unknown, "sanity"); +static void command_set_in_filter(CompileCommandEnum option) { + assert(option != CompileCommandEnum::Unknown, "sanity"); assert(option2type(option) != OptionType::Unknown, "sanity"); - if ((option != CompileCommand::DontInline) && - (option != CompileCommand::Inline) && - (option != CompileCommand::Log)) { + if ((option != CompileCommandEnum::DontInline) && + (option != CompileCommandEnum::Inline) && + (option != CompileCommandEnum::Log)) { any_set = true; } option_filter[static_cast(option)] = true; } -static bool has_command(enum CompileCommand option) { +static bool has_command(CompileCommandEnum option) { return option_filter[static_cast(option)]; } class TypedMethodOptionMatcher : public MethodMatcher { private: TypedMethodOptionMatcher* _next; - enum CompileCommand _option; + CompileCommandEnum _option; public: union { @@ -140,15 +140,15 @@ class TypedMethodOptionMatcher : public MethodMatcher { TypedMethodOptionMatcher() : MethodMatcher(), _next(nullptr), - _option(CompileCommand::Unknown) { + _option(CompileCommandEnum::Unknown) { memset(&_u, 0, sizeof(_u)); } ~TypedMethodOptionMatcher(); static TypedMethodOptionMatcher* parse_method_pattern(char*& line, char* errorbuf, const int buf_size); - TypedMethodOptionMatcher* match(const methodHandle &method, enum CompileCommand option); + TypedMethodOptionMatcher* match(const methodHandle &method, CompileCommandEnum option); - void init(enum CompileCommand option, TypedMethodOptionMatcher* next) { + void init(CompileCommandEnum option, TypedMethodOptionMatcher* next) { _next = next; _option = option; } @@ -161,7 +161,7 @@ class TypedMethodOptionMatcher : public MethodMatcher { void set_next(TypedMethodOptionMatcher* next) {_next = next; } TypedMethodOptionMatcher* next() { return _next; } - enum CompileCommand option() { return _option; } + CompileCommandEnum option() { return _option; } template T value(); template void set_value(T value); void print(); @@ -286,7 +286,7 @@ TypedMethodOptionMatcher* TypedMethodOptionMatcher::parse_method_pattern(char*& return tom; } -TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& method, enum CompileCommand option) { +TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& method, CompileCommandEnum option) { TypedMethodOptionMatcher* current = this; while (current != nullptr) { if (current->_option == option) { @@ -301,16 +301,16 @@ TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& me template static void register_command(TypedMethodOptionMatcher* matcher, - enum CompileCommand option, + CompileCommandEnum option, T value) { assert(matcher != option_list, "No circular lists please"); - if (option == CompileCommand::Log && !LogCompilation) { + if (option == CompileCommandEnum::Log && !LogCompilation) { tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged with "); tty->print_cr(" CompileCommand=log,"); } assert(CompilerOracle::option_matches_type(option, value), "Value must match option type"); - if (option == CompileCommand::Blackhole && !UnlockExperimentalVMOptions) { + if (option == CompileCommandEnum::Blackhole && !UnlockExperimentalVMOptions) { warning("Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions"); // Delete matcher as we don't keep it delete matcher; @@ -333,7 +333,7 @@ static void register_command(TypedMethodOptionMatcher* matcher, } template -bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, T& value) { +bool CompilerOracle::has_option_value(const methodHandle& method, CompileCommandEnum option, T& value) { assert(option_matches_type(option, value), "Value must match option type"); if (!has_command(option)) { return false; @@ -348,22 +348,22 @@ bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCo return false; } -static bool resolve_inlining_predicate(enum CompileCommand option, const methodHandle& method) { - assert(option == CompileCommand::Inline || option == CompileCommand::DontInline, "Sanity"); +static bool resolve_inlining_predicate(CompileCommandEnum option, const methodHandle& method) { + assert(option == CompileCommandEnum::Inline || option == CompileCommandEnum::DontInline, "Sanity"); bool v1 = false; bool v2 = false; - bool has_inline = CompilerOracle::has_option_value(method, CompileCommand::Inline, v1); - bool has_dnotinline = CompilerOracle::has_option_value(method, CompileCommand::DontInline, v2); + bool has_inline = CompilerOracle::has_option_value(method, CompileCommandEnum::Inline, v1); + bool has_dnotinline = CompilerOracle::has_option_value(method, CompileCommandEnum::DontInline, v2); if (has_inline && has_dnotinline) { if (v1 && v2) { // Conflict options detected // Find the last one for that method and return the predicate accordingly // option_list lists options in reverse order. So the first option we find is the last which was specified. - enum CompileCommand last_one = CompileCommand::Unknown; + CompileCommandEnum last_one = CompileCommandEnum::Unknown; TypedMethodOptionMatcher* current = option_list; while (current != nullptr) { last_one = current->option(); - if (last_one == CompileCommand::Inline || last_one == CompileCommand::DontInline) { + if (last_one == CompileCommandEnum::Inline || last_one == CompileCommandEnum::DontInline) { if (current->matches(method)) { return last_one == option; } @@ -374,10 +374,10 @@ static bool resolve_inlining_predicate(enum CompileCommand option, const methodH return false; } else { // No conflicts - return option == CompileCommand::Inline ? v1 : v2; + return option == CompileCommandEnum::Inline ? v1 : v2; } } else { - if (option == CompileCommand::Inline) { + if (option == CompileCommandEnum::Inline) { return has_inline ? v1 : false; } else { return has_dnotinline ? v2 : false; @@ -385,9 +385,9 @@ static bool resolve_inlining_predicate(enum CompileCommand option, const methodH } } -static bool check_predicate(enum CompileCommand option, const methodHandle& method) { +static bool check_predicate(CompileCommandEnum option, const methodHandle& method) { // Special handling for Inline and DontInline since conflict options may be specified - if (option == CompileCommand::Inline || option == CompileCommand::DontInline) { + if (option == CompileCommandEnum::Inline || option == CompileCommandEnum::DontInline) { return resolve_inlining_predicate(option, method); } @@ -403,14 +403,14 @@ bool CompilerOracle::has_any_command_set() { } // Explicit instantiation for all OptionTypes supported. -template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, intx& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, uintx& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, bool& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, ccstr& value); -template bool CompilerOracle::has_option_value(const methodHandle& method, enum CompileCommand option, double& value); +template bool CompilerOracle::has_option_value(const methodHandle& method, CompileCommandEnum option, intx& value); +template bool CompilerOracle::has_option_value(const methodHandle& method, CompileCommandEnum option, uintx& value); +template bool CompilerOracle::has_option_value(const methodHandle& method, CompileCommandEnum option, bool& value); +template bool CompilerOracle::has_option_value(const methodHandle& method, CompileCommandEnum option, ccstr& value); +template bool CompilerOracle::has_option_value(const methodHandle& method, CompileCommandEnum option, double& value); template -bool CompilerOracle::option_matches_type(enum CompileCommand option, T& value) { +bool CompilerOracle::option_matches_type(CompileCommandEnum option, T& value) { enum OptionType option_type = option2type(option); if (option_type == OptionType::Unknown) { return false; // Can't query options with type Unknown. @@ -421,47 +421,47 @@ bool CompilerOracle::option_matches_type(enum CompileCommand option, T& value) { return (get_type_for() == option_type); } -template bool CompilerOracle::option_matches_type(enum CompileCommand option, intx& value); -template bool CompilerOracle::option_matches_type(enum CompileCommand option, uintx& value); -template bool CompilerOracle::option_matches_type(enum CompileCommand option, bool& value); -template bool CompilerOracle::option_matches_type(enum CompileCommand option, ccstr& value); -template bool CompilerOracle::option_matches_type(enum CompileCommand option, double& value); +template bool CompilerOracle::option_matches_type(CompileCommandEnum option, intx& value); +template bool CompilerOracle::option_matches_type(CompileCommandEnum option, uintx& value); +template bool CompilerOracle::option_matches_type(CompileCommandEnum option, bool& value); +template bool CompilerOracle::option_matches_type(CompileCommandEnum option, ccstr& value); +template bool CompilerOracle::option_matches_type(CompileCommandEnum option, double& value); -bool CompilerOracle::has_option(const methodHandle& method, enum CompileCommand option) { +bool CompilerOracle::has_option(const methodHandle& method, CompileCommandEnum option) { bool value = false; has_option_value(method, option, value); return value; } bool CompilerOracle::should_exclude(const methodHandle& method) { - if (check_predicate(CompileCommand::Exclude, method)) { + if (check_predicate(CompileCommandEnum::Exclude, method)) { return true; } - if (has_command(CompileCommand::CompileOnly)) { - return !check_predicate(CompileCommand::CompileOnly, method); + if (has_command(CompileCommandEnum::CompileOnly)) { + return !check_predicate(CompileCommandEnum::CompileOnly, method); } return false; } bool CompilerOracle::should_inline(const methodHandle& method) { - return (check_predicate(CompileCommand::Inline, method)); + return (check_predicate(CompileCommandEnum::Inline, method)); } bool CompilerOracle::should_not_inline(const methodHandle& method) { - return check_predicate(CompileCommand::DontInline, method) || check_predicate(CompileCommand::Exclude, method); + return check_predicate(CompileCommandEnum::DontInline, method) || check_predicate(CompileCommandEnum::Exclude, method); } bool CompilerOracle::should_print(const methodHandle& method) { - return check_predicate(CompileCommand::Print, method); + return check_predicate(CompileCommandEnum::Print, method); } bool CompilerOracle::should_print_methods() { - return has_command(CompileCommand::Print); + return has_command(CompileCommandEnum::Print); } // Tells whether there are any methods to collect memory statistics for bool CompilerOracle::should_collect_memstat() { - return has_command(CompileCommand::MemStat) || has_command(CompileCommand::MemLimit); + return has_command(CompileCommandEnum::MemStat) || has_command(CompileCommandEnum::MemLimit); } bool CompilerOracle::should_print_final_memstat_report() { @@ -470,18 +470,18 @@ bool CompilerOracle::should_print_final_memstat_report() { bool CompilerOracle::should_log(const methodHandle& method) { if (!LogCompilation) return false; - if (!has_command(CompileCommand::Log)) { + if (!has_command(CompileCommandEnum::Log)) { return true; // by default, log all } - return (check_predicate(CompileCommand::Log, method)); + return (check_predicate(CompileCommandEnum::Log, method)); } bool CompilerOracle::should_break_at(const methodHandle& method) { - return check_predicate(CompileCommand::Break, method); + return check_predicate(CompileCommandEnum::Break, method); } void CompilerOracle::tag_blackhole_if_possible(const methodHandle& method) { - if (!check_predicate(CompileCommand::Blackhole, method)) { + if (!check_predicate(CompileCommandEnum::Blackhole, method)) { return; } guarantee(UnlockExperimentalVMOptions, "Checked during initial parsing"); @@ -511,8 +511,8 @@ void CompilerOracle::tag_blackhole_if_possible(const methodHandle& method) { method->set_intrinsic_id(vmIntrinsics::_blackhole); } -static enum CompileCommand match_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"); +static CompileCommandEnum match_option_name(const char* line, int* bytes_read, char* errorbuf, int bufsize) { + assert(ARRAY_SIZE(option_names) == static_cast(CompileCommandEnum::Count), "option_names size mismatch"); *bytes_read = 0; char option_buf[256]; @@ -520,22 +520,22 @@ static enum CompileCommand match_option_name(const char* line, int* bytes_read, if (matches > 0 && strcasecmp(option_buf, "unknown") != 0) { for (uint i = 0; i < ARRAY_SIZE(option_names); i++) { if (strcasecmp(option_buf, option_names[i]) == 0) { - return static_cast(i); + return static_cast(i); } } } jio_snprintf(errorbuf, bufsize, "Unrecognized option '%s'", option_buf); - return CompileCommand::Unknown; + return CompileCommandEnum::Unknown; } // match exactly and don't mess with errorbuf -enum CompileCommand CompilerOracle::parse_option_name(const char* line) { +CompileCommandEnum CompilerOracle::parse_option_name(const char* line) { for (uint i = 0; i < ARRAY_SIZE(option_names); i++) { if (strcasecmp(line, option_names[i]) == 0) { - return static_cast(i); + return static_cast(i); } } - return CompileCommand::Unknown; + return CompileCommandEnum::Unknown; } enum OptionType CompilerOracle::parse_option_type(const char* type_str) { @@ -555,7 +555,7 @@ static void print_tip() { // CMH Update info tty->cr(); } -static void print_option(enum CompileCommand option, const char* name, enum OptionType type) { +static void print_option(CompileCommandEnum option, const char* name, enum OptionType type) { if (type != OptionType::Unknown) { tty->print_cr(" %s (%s)", name, optiontype2name(type)); } @@ -564,7 +564,7 @@ static void print_option(enum CompileCommand option, const char* name, enum Opti static void print_commands() { tty->cr(); tty->print_cr("All available options:"); -#define enum_of_options(option, name, ctype) print_option(CompileCommand::option, name, OptionType::ctype); +#define enum_of_options(option, name, ctype) print_option(CompileCommandEnum::option, name, OptionType::ctype); COMPILECOMMAND_OPTIONS(enum_of_options) #undef enum_of_options tty->cr(); @@ -699,7 +699,7 @@ static bool parseMemStat(const char* line, uintx& value, int& bytes_read, char* } static void scan_value(enum OptionType type, char* line, int& total_bytes_read, - TypedMethodOptionMatcher* matcher, enum CompileCommand option, char* errorbuf, const int buf_size) { + TypedMethodOptionMatcher* matcher, CompileCommandEnum option, char* errorbuf, const int buf_size) { int bytes_read = 0; const char* ccname = option2name(option); const char* type_str = optiontype2name(type); @@ -708,7 +708,7 @@ static void scan_value(enum OptionType type, char* line, int& total_bytes_read, if (type == OptionType::Intx) { intx value; bool success = false; - if (option == CompileCommand::MemLimit) { + if (option == CompileCommandEnum::MemLimit) { // Special parsing for MemLimit success = parseMemLimit(line, value, bytes_read, errorbuf, buf_size); } else { @@ -726,7 +726,7 @@ static void scan_value(enum OptionType type, char* line, int& total_bytes_read, } else if (type == OptionType::Uintx) { uintx value; bool success = false; - if (option == CompileCommand::MemStat) { + if (option == CompileCommandEnum::MemStat) { // Special parsing for MemStat success = parseMemStat(line, value, bytes_read, errorbuf, buf_size); } else { @@ -769,27 +769,27 @@ static void scan_value(enum OptionType type, char* line, int& total_bytes_read, end_value = next_value-1; } - if (option == CompileCommand::ControlIntrinsic || option == CompileCommand::DisableIntrinsic) { - ControlIntrinsicValidator validator(value, (option == CompileCommand::DisableIntrinsic)); + if (option == CompileCommandEnum::ControlIntrinsic || option == CompileCommandEnum::DisableIntrinsic) { + ControlIntrinsicValidator validator(value, (option == CompileCommandEnum::DisableIntrinsic)); if (!validator.is_valid()) { jio_snprintf(errorbuf, buf_size, "Unrecognized intrinsic detected in %s: %s", option2name(option), validator.what()); } } #if !defined(PRODUCT) && defined(COMPILER2) - else if (option == CompileCommand::TraceAutoVectorization) { + else if (option == CompileCommandEnum::TraceAutoVectorization) { TraceAutoVectorizationTagValidator validator(value, true); if (!validator.is_valid()) { jio_snprintf(errorbuf, buf_size, "Unrecognized tag name in %s: %s", option2name(option), validator.what()); } - } else if (option == CompileCommand::PrintIdealPhase) { + } else if (option == CompileCommandEnum::PrintIdealPhase) { PhaseNameValidator validator(value); if (!validator.is_valid()) { jio_snprintf(errorbuf, buf_size, "Unrecognized phase name in %s: %s", option2name(option), validator.what()); } - } else if (option == CompileCommand::TestOptionList) { + } else if (option == CompileCommandEnum::TestOptionList) { // all values are ok } #endif @@ -862,8 +862,8 @@ static void scan_option_and_value(enum OptionType type, char* line, int& total_b total_bytes_read += bytes_read; int bytes_read2 = 0; total_bytes_read += skip_whitespace(line); - enum CompileCommand option = match_option_name(option_buf, &bytes_read2, errorbuf, buf_size); - if (option == CompileCommand::Unknown) { + CompileCommandEnum option = match_option_name(option_buf, &bytes_read2, errorbuf, buf_size); + if (option == CompileCommandEnum::Unknown) { assert(*errorbuf != '\0', "error must have been set"); return; } @@ -914,26 +914,26 @@ bool CompilerOracle::parse_from_line(char* line) { int bytes_read; char error_buf[1024] = {0}; - enum CompileCommand option = match_option_name(line, &bytes_read, error_buf, sizeof(error_buf)); + CompileCommandEnum option = match_option_name(line, &bytes_read, error_buf, sizeof(error_buf)); line += bytes_read; ResourceMark rm; - if (option == CompileCommand::Unknown) { + if (option == CompileCommandEnum::Unknown) { print_parse_error(error_buf, original.get()); return false; } - if (option == CompileCommand::Quiet) { + if (option == CompileCommandEnum::Quiet) { _quiet = true; return true; } - if (option == CompileCommand::Help) { + if (option == CompileCommandEnum::Help) { usage(); return true; } - if (option == CompileCommand::Option) { + if (option == CompileCommandEnum::Option) { // Look for trailing options. // // Two types of trailing options are @@ -975,8 +975,8 @@ bool CompilerOracle::parse_from_line(char* line) { } else { // Type (1) option - option_type contains the option name -> bool value = true is implied int bytes_read; - enum CompileCommand option = match_option_name(option_type, &bytes_read, error_buf, sizeof(error_buf)); - if (option == CompileCommand::Unknown) { + CompileCommandEnum option = match_option_name(option_type, &bytes_read, error_buf, sizeof(error_buf)); + if (option == CompileCommandEnum::Unknown) { print_parse_error(error_buf, original.get()); return false; } @@ -1013,7 +1013,7 @@ bool CompilerOracle::parse_from_line(char* line) { // if this is a bool option this implies true register_command(matcher, option, true); return true; - } else if (option == CompileCommand::MemStat) { + } else if (option == CompileCommandEnum::MemStat) { // MemStat default action is to collect data but to not print register_command(matcher, option, (uintx)MemStatAction::collect); return true; @@ -1125,7 +1125,7 @@ bool compilerOracle_init() { default_cc_file, default_cc_file); } } - if (has_command(CompileCommand::Print)) { + if (has_command(CompileCommandEnum::Print)) { if (PrintAssembly) { warning("CompileCommand and/or %s file contains 'print' commands, but PrintAssembly is also enabled", default_cc_file); } @@ -1149,7 +1149,7 @@ bool CompilerOracle::parse_compile_only(char* line) { if (method_pattern != nullptr) { TypedMethodOptionMatcher* matcher = TypedMethodOptionMatcher::parse_method_pattern(method_pattern, error_buf, sizeof(error_buf)); if (matcher != nullptr) { - register_command(matcher, CompileCommand::CompileOnly, true); + register_command(matcher, CompileCommandEnum::CompileOnly, true); continue; } } @@ -1164,7 +1164,7 @@ bool CompilerOracle::parse_compile_only(char* line) { return true; } -enum CompileCommand CompilerOracle::string_to_option(const char* name) { +CompileCommandEnum CompilerOracle::string_to_option(const char* name) { int bytes_read = 0; char errorbuf[1024] = {0}; return match_option_name(name, &bytes_read, errorbuf, sizeof(errorbuf)); diff --git a/src/hotspot/share/compiler/compilerOracle.hpp b/src/hotspot/share/compiler/compilerOracle.hpp index 192e292d35a2b..43a30b30facec 100644 --- a/src/hotspot/share/compiler/compilerOracle.hpp +++ b/src/hotspot/share/compiler/compilerOracle.hpp @@ -101,7 +101,7 @@ NOT_PRODUCT(option(TestOptionDouble, "TestOptionDouble", Double)) \ option(Option, "option", Unknown) \ option(Unknown, "unknown", Unknown) -enum class CompileCommand { +enum class CompileCommandEnum : int { #define enum_of_options(option, name, ctype) option, COMPILECOMMAND_OPTIONS(enum_of_options) #undef enum_of_options @@ -123,7 +123,7 @@ class CompilerOracle : AllStatic { private: static bool _quiet; static void print_parse_error(char* error_msg, char* original_line); - static void print_command(enum CompileCommand option, const char* name, enum OptionType type); + static void print_command(CompileCommandEnum option, const char* name, enum OptionType type); public: // True if the command file has been specified or is implicit @@ -165,16 +165,16 @@ class CompilerOracle : AllStatic { static void tag_blackhole_if_possible(const methodHandle& method); // A wrapper for checking bool options - static bool has_option(const methodHandle& method, enum CompileCommand option); + static bool has_option(const methodHandle& method, CompileCommandEnum option); // Check if method has option and value set. If yes, overwrite value and return true, // otherwise leave value unchanged and return false. template - static bool has_option_value(const methodHandle& method, enum CompileCommand option, T& value); + static bool has_option_value(const methodHandle& method, CompileCommandEnum option, T& value); // This check is currently only needed by whitebox API template - static bool option_matches_type(enum CompileCommand option, T& value); + static bool option_matches_type(CompileCommandEnum option, T& value); // Reads from string instead of file static bool parse_from_string(const char* option_string, bool (*parser)(char*)); @@ -185,12 +185,12 @@ class CompilerOracle : AllStatic { static bool has_any_command_set(); // convert a string to a proper compilecommand option - used from whitebox. - // returns CompileCommand::Unknown on names not matching an option. - static enum CompileCommand string_to_option(const char* name); + // returns CompileCommandEnum::Unknown on names not matching an option. + static CompileCommandEnum string_to_option(const char* name); // convert a string to a proper compilecommand option - // returns CompileCommand::Unknown if name is not an option. - static enum CompileCommand parse_option_name(const char* name); + // returns CompileCommandEnum::Unknown if name is not an option. + static CompileCommandEnum parse_option_name(const char* name); // convert a string to a proper option type // returns OptionType::Unknown on strings not matching an option type. diff --git a/src/hotspot/share/compiler/methodMatcher.cpp b/src/hotspot/share/compiler/methodMatcher.cpp index de2e4e82bba3f..1a0ade2fadbd3 100644 --- a/src/hotspot/share/compiler/methodMatcher.cpp +++ b/src/hotspot/share/compiler/methodMatcher.cpp @@ -286,7 +286,7 @@ void MethodMatcher::parse_method_pattern(char*& line, const char*& error_msg, Me // In very rare case, the method name happens to be same as option type/name, so look ahead to make sure // it doesn't show up again. if ((OptionType::Unknown != CompilerOracle::parse_option_type(method_name) || - CompileCommand::Unknown != CompilerOracle::parse_option_name(method_name)) && + CompileCommandEnum::Unknown != CompilerOracle::parse_option_name(method_name)) && *(line + bytes_read) != '\0' && strstr(line + bytes_read, method_name) == nullptr) { error_msg = "Did not specify any method name"; diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index 99d5f9ae58801..0d9c92cad518a 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -31,6 +31,7 @@ #include "code/scopeDesc.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerEvent.hpp" +#include "compiler/compilerOracle.hpp" #include "compiler/disassembler.hpp" #include "compiler/oopMap.hpp" #include "interpreter/bytecodeStream.hpp" diff --git a/src/hotspot/share/oops/methodCounters.cpp b/src/hotspot/share/oops/methodCounters.cpp index e9237b18e6009..00096c5012cbd 100644 --- a/src/hotspot/share/oops/methodCounters.cpp +++ b/src/hotspot/share/oops/methodCounters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,8 +21,10 @@ * questions. * */ + #include "precompiled.hpp" #include "compiler/compiler_globals.hpp" +#include "compiler/compilerOracle.hpp" #include "oops/method.hpp" #include "oops/methodCounters.hpp" #include "runtime/handles.inline.hpp" @@ -40,7 +42,7 @@ MethodCounters::MethodCounters(const methodHandle& mh) : // Set per-method thresholds. double scale = 1.0; - CompilerOracle::has_option_value(mh, CompileCommand::CompileThresholdScaling, scale); + CompilerOracle::has_option_value(mh, CompileCommandEnum::CompileThresholdScaling, scale); _invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift; _backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift; diff --git a/src/hotspot/share/oops/methodCounters.hpp b/src/hotspot/share/oops/methodCounters.hpp index d1b2207961f27..80cfb159b50ce 100644 --- a/src/hotspot/share/oops/methodCounters.hpp +++ b/src/hotspot/share/oops/methodCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ #include "oops/metadata.hpp" #include "compiler/compilerDefinitions.hpp" -#include "compiler/compilerOracle.hpp" #include "interpreter/invocationCounter.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index 008de899bdb25..08dfc1fe95a36 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -1319,7 +1319,7 @@ void MethodData::init() { // Set per-method invoke- and backedge mask. double scale = 1.0; methodHandle mh(Thread::current(), _method); - CompilerOracle::has_option_value(mh, CompileCommand::CompileThresholdScaling, scale); + CompilerOracle::has_option_value(mh, CompileCommandEnum::CompileThresholdScaling, scale); _invoke_mask = (int)right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift; _backedge_mask = (int)right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift; @@ -1336,8 +1336,8 @@ void MethodData::init() { #if INCLUDE_RTM_OPT _rtm_state = NoRTM; // No RTM lock eliding by default if (UseRTMLocking && - !CompilerOracle::has_option(mh, CompileCommand::NoRTMLockEliding)) { - if (CompilerOracle::has_option(mh, CompileCommand::UseRTMLockEliding) || !UseRTMDeopt) { + !CompilerOracle::has_option(mh, CompileCommandEnum::NoRTMLockEliding)) { + if (CompilerOracle::has_option(mh, CompileCommandEnum::UseRTMLockEliding) || !UseRTMDeopt) { // Generate RTM lock eliding code without abort ratio calculation code. _rtm_state = UseRTM; } else if (UseRTMDeopt) { diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index d8881689678ec..e6a522e36107d 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -33,6 +33,7 @@ #include "compiler/compilationMemoryStatistic.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compileLog.hpp" +#include "compiler/compilerOracle.hpp" #include "compiler/compiler_globals.hpp" #include "compiler/disassembler.hpp" #include "compiler/oopMap.hpp" @@ -1082,10 +1083,10 @@ void Compile::Init(bool aliasing) { #if INCLUDE_RTM_OPT if (UseRTMLocking && has_method() && (method()->method_data_or_null() != nullptr)) { int rtm_state = method()->method_data()->rtm_state(); - if (method_has_option(CompileCommand::NoRTMLockEliding) || ((rtm_state & NoRTM) != 0)) { + if (method_has_option(CompileCommandEnum::NoRTMLockEliding) || ((rtm_state & NoRTM) != 0)) { // Don't generate RTM lock eliding code. set_rtm_state(NoRTM); - } else if (method_has_option(CompileCommand::UseRTMLockEliding) || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) { + } else if (method_has_option(CompileCommandEnum::UseRTMLockEliding) || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) { // Generate RTM lock eliding code without abort ratio calculation code. set_rtm_state(UseRTM); } else if (UseRTMDeopt) { diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 0b60a674b4978..8f49c1616726e 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -29,7 +29,6 @@ #include "ci/compilerInterface.hpp" #include "code/debugInfoRec.hpp" #include "compiler/compiler_globals.hpp" -#include "compiler/compilerOracle.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerEvent.hpp" #include "compiler/cHeapStringHolder.hpp" @@ -46,6 +45,7 @@ #include "runtime/timerTrace.hpp" #include "runtime/vmThread.hpp" #include "utilities/ticks.hpp" +#include "utilities/vmEnums.hpp" class AbstractLockNode; class AddPNode; @@ -678,7 +678,7 @@ class Compile : public Phase { void set_has_monitors(bool v) { _has_monitors = v; } // check the CompilerOracle for special behaviours for this compile - bool method_has_option(enum CompileCommand option) { + bool method_has_option(CompileCommandEnum option) { return method() != nullptr && method()->has_option(option); } diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 9ad77658072f7..f8dc972d06836 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -41,6 +41,7 @@ #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "compiler/compilationPolicy.hpp" +#include "compiler/compilerOracle.hpp" #include "compiler/directivesParser.hpp" #include "compiler/methodMatcher.hpp" #include "gc/shared/concurrentGCBreakpoints.hpp" @@ -1988,9 +1989,9 @@ static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jst ThreadToNativeFromVM ttnfv(thread); const char* flag_name = env->GetStringUTFChars(name, nullptr); CHECK_JNI_EXCEPTION_(env, false); - enum CompileCommand option = CompilerOracle::string_to_option(flag_name); + CompileCommandEnum option = CompilerOracle::string_to_option(flag_name); env->ReleaseStringUTFChars(name, flag_name); - if (option == CompileCommand::Unknown) { + if (option == CompileCommandEnum::Unknown) { return false; } if (!CompilerOracle::option_matches_type(option, *value)) { diff --git a/src/hotspot/share/utilities/vmEnums.hpp b/src/hotspot/share/utilities/vmEnums.hpp index e3d298f24bc0c..79d540762ddff 100644 --- a/src/hotspot/share/utilities/vmEnums.hpp +++ b/src/hotspot/share/utilities/vmEnums.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ // you don't use their members directly. This way you don't need to include the // complex header files that have the full definitions of these enums. +enum class CompileCommandEnum : int; enum class JavaThreadStatus : int; enum class JVMFlagOrigin : int; enum JVMFlagsEnum : int;