Skip to content
Closed
17 changes: 7 additions & 10 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,11 @@ bool nmethod::is_maybe_on_stack() {
void nmethod::inc_decompile_count() {
if (!is_compiled_by_c2() && !is_compiled_by_jvmci()) return;
// Could be gated by ProfileTraps, but do not bother...
#if INCLUDE_JVMCI
if (is_jvmci_hosted()) {
return;
}
#endif
Method* m = method();
if (m == nullptr) return;
MethodData* mdo = m->method_data();
Expand Down Expand Up @@ -2056,16 +2061,8 @@ bool nmethod::make_not_entrant(ChangeReason change_reason) {
}

if (update_recompile_counts()) {
#if INCLUDE_JVMCI
if (jvmci_nmethod_data() != nullptr && !jvmci_nmethod_data()->is_default()) {
// Non-default (i.e., non-CompileBroker) compilations are
// not subject to the recompilation cutoff
} else
#endif
{
// Mark the method as decompiled.
inc_decompile_count();
}
// Mark the method as decompiled.
inc_decompile_count();
}

BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/code/nmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,12 @@ class nmethod : public CodeBlob {
JVMCINMethodData* jvmci_nmethod_data() const {
return jvmci_data_size() == 0 ? nullptr : (JVMCINMethodData*) jvmci_data_begin();
}

// Returns true if a JVMCI compiled method is non-default,
// i.e., not triggered by CompilerBroker
bool is_jvmci_hosted() const {
return jvmci_nmethod_data() != nullptr && !jvmci_nmethod_data()->is_default();
}
#endif

void oops_do(OopClosure* f) { oops_do(f, false); }
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
JVMCICompileState* compile_state = JVMCIENV->compile_state();
bool failing_dep_is_call_site;
result = validate_compile_task_dependencies(dependencies, compile_state, &failure_detail, failing_dep_is_call_site);
if (result != JVMCI::ok) {
if (install_default && result != JVMCI::ok) {
// While not a true deoptimization, it is a preemptive decompile.
MethodData* mdp = method()->method_data();
if (mdp != nullptr && !failing_dep_is_call_site) {
Expand Down
13 changes: 5 additions & 8 deletions src/hotspot/share/runtime/deoptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@
#include "jfr/jfrEvents.hpp"
#include "jfr/metadata/jfrSerializer.hpp"
#endif
#if INCLUDE_JVMCI
#include "jvmci/jvmciRuntime.hpp"
#endif

uint64_t DeoptimizationScope::_committed_deopt_gen = 0;
uint64_t DeoptimizationScope::_active_deopt_gen = 1;
Expand Down Expand Up @@ -2366,6 +2363,11 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr
ShouldNotReachHere();
}

#if INCLUDE_JVMCI
if (nm->is_jvmci_hosted()) {
update_trap_state = false;
}
#endif
// Setting +ProfileTraps fixes the following, on all platforms:
// The result is infinite heroic-opt-uncommon-trap/deopt/recompile cycles, since the
// recompile relies on a MethodData* to record heroic opt failures.
Expand Down Expand Up @@ -2476,11 +2478,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr
trap_mdo->inc_tenure_traps();
}
}
#if INCLUDE_JVMCI
if (nm->jvmci_nmethod_data() != nullptr && !nm->jvmci_nmethod_data()->is_default()) {
inc_recompile_count = false;
}
#endif
if (inc_recompile_count) {
trap_mdo->inc_overflow_recompile_count();
if ((uint)trap_mdo->overflow_recompile_count() >
Expand Down