Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8313713: Allow CompileCommand flag to specify compilation level #20

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hotspot/share/c1/c1_GraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3588,7 +3588,7 @@ const char* GraphBuilder::check_can_parse(ciMethod* callee) const {

// negative filter: should callee NOT be inlined? returns null, ok to inline, or rejection msg
const char* GraphBuilder::should_not_inline(ciMethod* callee) const {
if ( compilation()->directive()->should_not_inline(callee)) return "disallowed by CompileCommand";
if ( compilation()->directive()->should_not_inline(callee, compilation()->env()->comp_level())) return "disallowed by CompileCommand";
if ( callee->dont_inline()) return "don't inline by annotation";
return nullptr;
}
Expand Down Expand Up @@ -3918,7 +3918,7 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, bool ign
}

// now perform tests that are based on flag settings
bool inlinee_by_directive = compilation()->directive()->should_inline(callee);
bool inlinee_by_directive = compilation()->directive()->should_inline(callee, compilation()->env()->comp_level());
if (callee->force_inline() || inlinee_by_directive) {
if (inline_level() > MaxForceInlineLevel ) INLINE_BAILOUT("MaxForceInlineLevel");
if (recursive_inline_level(callee) > C1MaxRecursiveInlineLevel) INLINE_BAILOUT("recursive inlining too deep");
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/c1/c1_LIRGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3217,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(CompileCommandEnum::CompileThresholdScaling, scale)) {
if (_method->has_option_value(CompileCommandEnum::CompileThresholdScaling, compilation()->env()->comp_level(), 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);
Expand Down Expand Up @@ -3258,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(CompileCommandEnum::CompileThresholdScaling, scale)) {
if (_method->has_option_value(CompileCommandEnum::CompileThresholdScaling, compilation()->env()->comp_level(), 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);
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/ci/ciMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
#endif // COMPILER2

// Check for blackhole intrinsic and then populate the intrinsic ID.
CompilerOracle::tag_blackhole_if_possible(h_m);
CompilerOracle::tag_blackhole_if_possible(h_m, CURRENT_ENV->comp_level());
_intrinsic_id = h_m->intrinsic_id();

ciEnv *env = CURRENT_ENV;
Expand Down Expand Up @@ -1063,21 +1063,21 @@ MethodCounters* ciMethod::ensure_method_counters() {
// ------------------------------------------------------------------
// ciMethod::has_option
//
bool ciMethod::has_option(CompileCommandEnum option) {
bool ciMethod::has_option(CompileCommandEnum option, int comp_level) {
check_is_loaded();
VM_ENTRY_MARK;
methodHandle mh(THREAD, get_Method());
return CompilerOracle::has_option(mh, option);
return CompilerOracle::has_option(mh, option, comp_level);
}

// ------------------------------------------------------------------
// ciMethod::has_option_value
//
bool ciMethod::has_option_value(CompileCommandEnum option, double& value) {
bool ciMethod::has_option_value(CompileCommandEnum option, int comp_level, double& value) {
check_is_loaded();
VM_ENTRY_MARK;
methodHandle mh(THREAD, get_Method());
return CompilerOracle::has_option_value(mh, option, value);
return CompilerOracle::has_option_value(mh, option, comp_level, value);
}
// ------------------------------------------------------------------
// ciMethod::can_be_compiled
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(CompileCommandEnum option);
bool has_option_value(CompileCommandEnum option, double& value);
bool has_option(CompileCommandEnum option, int comp_level);
bool has_option_value(CompileCommandEnum option, int comp_level, double& value);
bool can_be_compiled();
bool can_be_parsed() const { return _can_be_parsed; }
bool has_compiled_code();
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,15 +1688,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, CompileCommandEnum::PrintDebugInfo)) {
if (printmethod || PrintDebugInfo || CompilerOracle::has_option(mh, CompileCommandEnum::PrintDebugInfo, _comp_level)) {
print_scopes();
tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
}
if (printmethod || PrintRelocations || CompilerOracle::has_option(mh, CompileCommandEnum::PrintRelocations)) {
if (printmethod || PrintRelocations || CompilerOracle::has_option(mh, CompileCommandEnum::PrintRelocations, _comp_level)) {
print_relocations();
tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
}
if (printmethod || PrintDependencies || CompilerOracle::has_option(mh, CompileCommandEnum::PrintDependencies)) {
if (printmethod || PrintDependencies || CompilerOracle::has_option(mh, CompileCommandEnum::PrintDependencies, _comp_level)) {
print_dependencies_on(tty);
tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/compiler/compilationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, CompileCommandEnum::CompileThresholdScaling, threshold_scaling)) {
if (CompilerOracle::has_option_value(method, CompileCommandEnum::CompileThresholdScaling, cur_level, threshold_scaling)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: should this be cur_level or next_level?

scale *= threshold_scaling;
}
switch(cur_level) {
Expand Down Expand Up @@ -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, CompileCommandEnum::CompileThresholdScaling, threshold_scaling)) {
if (CompilerOracle::has_option_value(method, CompileCommandEnum::CompileThresholdScaling, cur_level, threshold_scaling)) {
scale *= threshold_scaling;
}
switch(cur_level) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,17 +1333,17 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
return nullptr;
}

#if INCLUDE_JVMCI
AbstractCompiler *comp = CompileBroker::compiler(comp_level);
assert(comp != nullptr, "Ensure we have a compiler");

#if INCLUDE_JVMCI
if (comp->is_jvmci() && !JVMCI::can_initialize_JVMCI()) {
// JVMCI compilation is not yet initializable.
return nullptr;
}
#endif

DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp_level);
// CompileBroker::compile_method can trap and can have pending async exception.
nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, directive, THREAD);
DirectivesStack::release(directive);
Expand Down Expand Up @@ -1547,7 +1547,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, CompileCommandEnum::CompileThresholdScaling, scale) && scale == 0)) {
if (excluded || (CompilerOracle::has_option_value(method, CompileCommandEnum::CompileThresholdScaling, comp_level, scale) && scale == 0)) {
bool quietly = CompilerOracle::be_quiet();
if (PrintCompilation && !quietly) {
// This does not happen quietly...
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/compiler/compileTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ void CompileTask::initialize(int compile_id,
_time_started = 0;
_compile_reason = compile_reason;
_nm_content_size = 0;
AbstractCompiler* comp = compiler();
_directive = DirectivesStack::getMatchingDirective(method, comp);
_directive = DirectivesStack::getMatchingDirective(method, comp_level);
_nm_insts_size = 0;
_nm_total_size = 0;
_failure_reason = nullptr;
Expand Down
Loading
Loading