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

8349814: [leyden] Reduce uncommon traps in preload code #38

Open
wants to merge 11 commits into
base: premain
Choose a base branch
from
3 changes: 3 additions & 0 deletions src/hotspot/share/compiler/compiler_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@
product(bool, PrecompileOnlyAndExit, false, \
"Exit after precompilation step is over") \
\
product(bool, PreloadReduceTraps, true, DIAGNOSTIC, \
"Preload code should avoid traps as much as possible.") \
\
product(bool, PreloadBlocking, false, DIAGNOSTIC, \
"Preload code is processed with blocking. Startup would not " \
"proceed until all code preloaded code is done loading.") \
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4052,6 +4052,10 @@ bool Compile::too_many_traps(ciMethod* method,
if (method->has_trap_at(bci)) {
return true;
}
if (PreloadReduceTraps && for_preload()) {
// Preload code should not have traps, if possible.
return true;
}
ciMethodData* md = method->method_data();
if (md->is_empty()) {
// Assume the trap has not occurred, or that it occurred only
Expand All @@ -4077,6 +4081,10 @@ bool Compile::too_many_traps(ciMethod* method,
// Less-accurate variant which does not require a method and bci.
bool Compile::too_many_traps(Deoptimization::DeoptReason reason,
ciMethodData* logmd) {
if (PreloadReduceTraps && for_preload()) {
// Preload code should not have traps, if possible.
return true;
}
if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) {
// Too many traps globally.
// Note that we use cumulative trap_count, not just md->trap_count.
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/share/opto/graphKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,16 @@ Node* GraphKit::uncommon_trap(int trap_request,
trap_request), bci());
}

if (PreloadReduceTraps && Compile::current()->for_preload() &&
(action != Deoptimization::Action_none)) {
ResourceMark rm;
ciMethod* cim = Compile::current()->method();
log_info(scc)("Uncommon trap in preload code: reason=%s action=%s method=%s::%s bci=%d",
Deoptimization::trap_reason_name(reason), Deoptimization::trap_action_name(action),
cim->holder()->name()->as_klass_external_name(), cim->name()->as_klass_external_name(),
bci());
}

CompileLog* log = C->log();
if (log != nullptr) {
int kid = (klass == nullptr)? -1: log->identify(klass);
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/runtime/deoptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,14 @@ JRT_ENTRY_PROF(void, Deoptimization, uncommon_trap_inner, Deoptimization::uncomm
Events::log_deopt_message(current, "Uncommon trap: reason=%s action=%s pc=" INTPTR_FORMAT " method=%s @ %d %s",
reason_name, reason_action, pc,
tm->name_and_sig_as_C_string(), trap_bci, nm->compiler_name());

if (PreloadReduceTraps && nm->preloaded() && (action != Action_none)) {
// For performance reasons, preloaded nmethods should avoid deopts that lead to recompilations.
// Compiler logs all uncommon traps with -Xlog:scc. That log is noisy, and some traps may be
// legitimate. Here, we log the problems that really caused the deopts at runtime.
log_warning(deoptimization)("In preload code: reason=%s action=%s method=%s",
reason_name, reason_action, tm->name_and_sig_as_C_string());
}
}

// Print a bunch of diagnostics, if requested.
Expand Down