Skip to content

Commit 930455b

Browse files
shipilevVladimir Ivanov
andcommitted
8351640: Print reason for making method not entrant
Co-authored-by: Vladimir Ivanov <[email protected]> Reviewed-by: vlivanov, kvn
1 parent 895f64a commit 930455b

File tree

16 files changed

+68
-33
lines changed

16 files changed

+68
-33
lines changed

src/hotspot/share/c1/c1_Runtime1.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ JRT_ENTRY(void, Runtime1::deoptimize(JavaThread* current, jint trap_request))
795795
Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request);
796796

797797
if (action == Deoptimization::Action_make_not_entrant) {
798-
if (nm->make_not_entrant()) {
798+
if (nm->make_not_entrant("C1 deoptimize")) {
799799
if (reason == Deoptimization::Reason_tenured) {
800800
MethodData* trap_mdo = Deoptimization::get_method_data(current, method, true /*create_if_missing*/);
801801
if (trap_mdo != nullptr) {
@@ -1087,7 +1087,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, C1StubId stub_id ))
10871087
// safepoint, but if it's still alive then make it not_entrant.
10881088
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
10891089
if (nm != nullptr) {
1090-
nm->make_not_entrant();
1090+
nm->make_not_entrant("C1 code patch");
10911091
}
10921092

10931093
Deoptimization::deoptimize_frame(current, caller_frame.id());
@@ -1335,7 +1335,7 @@ void Runtime1::patch_code(JavaThread* current, C1StubId stub_id) {
13351335
// Make sure the nmethod is invalidated, i.e. made not entrant.
13361336
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
13371337
if (nm != nullptr) {
1338-
nm->make_not_entrant();
1338+
nm->make_not_entrant("C1 deoptimize for patching");
13391339
}
13401340
}
13411341

@@ -1463,7 +1463,7 @@ JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* current))
14631463

14641464
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
14651465
assert (nm != nullptr, "no more nmethod?");
1466-
nm->make_not_entrant();
1466+
nm->make_not_entrant("C1 predicate failed trap");
14671467

14681468
methodHandle m(current, nm->method());
14691469
MethodData* mdo = m->method_data();

src/hotspot/share/ci/ciReplay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ class CompileReplay : public StackObj {
802802
// Make sure the existence of a prior compile doesn't stop this one
803803
nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code();
804804
if (nm != nullptr) {
805-
nm->make_not_entrant();
805+
nm->make_not_entrant("CI replay");
806806
}
807807
replay_state = this;
808808
CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level,

src/hotspot/share/code/codeCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ void CodeCache::make_marked_nmethods_deoptimized() {
13611361
while(iter.next()) {
13621362
nmethod* nm = iter.method();
13631363
if (nm->is_marked_for_deoptimization() && !nm->has_been_deoptimized() && nm->can_be_deoptimized()) {
1364-
nm->make_not_entrant();
1364+
nm->make_not_entrant("marked for deoptimization");
13651365
nm->make_deoptimized();
13661366
}
13671367
}

src/hotspot/share/code/nmethod.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,21 +1964,27 @@ void nmethod::invalidate_osr_method() {
19641964
}
19651965
}
19661966

1967-
void nmethod::log_state_change() const {
1967+
void nmethod::log_state_change(const char* reason) const {
1968+
assert(reason != nullptr, "Must provide a reason");
1969+
19681970
if (LogCompilation) {
19691971
if (xtty != nullptr) {
19701972
ttyLocker ttyl; // keep the following output all in one block
1971-
xtty->begin_elem("make_not_entrant thread='%zu'",
1972-
os::current_thread_id());
1973+
xtty->begin_elem("make_not_entrant thread='%zu' reason='%s'",
1974+
os::current_thread_id(), reason);
19731975
log_identity(xtty);
19741976
xtty->stamp();
19751977
xtty->end_elem();
19761978
}
19771979
}
19781980

1979-
CompileTask::print_ul(this, "made not entrant");
1981+
ResourceMark rm;
1982+
stringStream ss(NEW_RESOURCE_ARRAY(char, 256), 256);
1983+
ss.print("made not entrant: %s", reason);
1984+
1985+
CompileTask::print_ul(this, ss.freeze());
19801986
if (PrintCompilation) {
1981-
print_on_with_msg(tty, "made not entrant");
1987+
print_on_with_msg(tty, ss.freeze());
19821988
}
19831989
}
19841990

@@ -1989,7 +1995,9 @@ void nmethod::unlink_from_method() {
19891995
}
19901996

19911997
// Invalidate code
1992-
bool nmethod::make_not_entrant() {
1998+
bool nmethod::make_not_entrant(const char* reason) {
1999+
assert(reason != nullptr, "Must provide a reason");
2000+
19932001
// This can be called while the system is already at a safepoint which is ok
19942002
NoSafepointVerifier nsv;
19952003

@@ -2047,7 +2055,7 @@ bool nmethod::make_not_entrant() {
20472055
assert(success, "Transition can't fail");
20482056

20492057
// Log the transition once
2050-
log_state_change();
2058+
log_state_change(reason);
20512059

20522060
// Remove nmethod from method.
20532061
unlink_from_method();

src/hotspot/share/code/nmethod.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ class nmethod : public CodeBlob {
631631
// alive. It is used when an uncommon trap happens. Returns true
632632
// if this thread changed the state of the nmethod or false if
633633
// another thread performed the transition.
634-
bool make_not_entrant();
635-
bool make_not_used() { return make_not_entrant(); }
634+
bool make_not_entrant(const char* reason);
635+
bool make_not_used() { return make_not_entrant("not used"); }
636636

637637
bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
638638
bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
@@ -945,7 +945,7 @@ class nmethod : public CodeBlob {
945945
// Logging
946946
void log_identity(xmlStream* log) const;
947947
void log_new_nmethod() const;
948-
void log_state_change() const;
948+
void log_state_change(const char* reason) const;
949949

950950
// Prints block-level comments, including nmethod specific block labels:
951951
void print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels=true) const;

src/hotspot/share/compiler/compilationPolicy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ void CompilationPolicy::compile(const methodHandle& mh, int bci, CompLevel level
796796
nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
797797
if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
798798
// Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
799-
osr_nm->make_not_entrant();
799+
osr_nm->make_not_entrant("OSR invalidation for compiling with C1");
800800
}
801801
compile(mh, bci, CompLevel_simple, THREAD);
802802
}
@@ -1201,7 +1201,7 @@ void CompilationPolicy::method_back_branch_event(const methodHandle& mh, const m
12011201
int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
12021202
print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
12031203
}
1204-
nm->make_not_entrant();
1204+
nm->make_not_entrant("OSR invalidation, back branch");
12051205
}
12061206
}
12071207
// Fix up next_level if necessary to avoid deopts

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ C2V_VMENTRY(void, reprofile, (JNIEnv* env, jobject, ARGUMENT_PAIR(method)))
13691369

13701370
nmethod* code = method->code();
13711371
if (code != nullptr) {
1372-
code->make_not_entrant();
1372+
code->make_not_entrant("JVMCI reprofile");
13731373
}
13741374

13751375
MethodData* method_data = method->method_data();
@@ -1809,7 +1809,7 @@ C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_
18091809
if (!fst.current()->is_compiled_frame()) {
18101810
JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected");
18111811
}
1812-
fst.current()->cb()->as_nmethod()->make_not_entrant();
1812+
fst.current()->cb()->as_nmethod()->make_not_entrant("JVMCI materialize virtual objects");
18131813
}
18141814
Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none);
18151815
// look for the frame again as it has been updated by deopt (pc, deopt state...)

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, JV
17751775

17761776
if (!deoptimize) {
17771777
// Prevent future executions of the nmethod but let current executions complete.
1778-
nm->make_not_entrant();
1778+
nm->make_not_entrant("JVMCI invalidate nmethod mirror");
17791779

17801780
// Do not clear the address field here as the Java code may still
17811781
// want to later call this method with deoptimize == true. That requires
@@ -1784,7 +1784,7 @@ void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, JV
17841784
// Deoptimize the nmethod immediately.
17851785
DeoptimizationScope deopt_scope;
17861786
deopt_scope.mark(nm);
1787-
nm->make_not_entrant();
1787+
nm->make_not_entrant("JVMCI invalidate nmethod mirror");
17881788
nm->make_deoptimized();
17891789
deopt_scope.deoptimize_marked();
17901790

src/hotspot/share/jvmci/jvmciRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,8 +2195,8 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
21952195
char *method_name = method->name_and_sig_as_C_string();
21962196
tty->print_cr("Replacing method %s", method_name);
21972197
}
2198-
if (old != nullptr ) {
2199-
old->make_not_entrant();
2198+
if (old != nullptr) {
2199+
old->make_not_entrant("JVMCI register method");
22002200
}
22012201

22022202
LogTarget(Info, nmethod, install) lt;

src/hotspot/share/oops/instanceKlass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3503,7 +3503,7 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) {
35033503
for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) {
35043504
nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true);
35053505
if (inv != nullptr && inv->is_in_use()) {
3506-
inv->make_not_entrant();
3506+
inv->make_not_entrant("OSR invalidation of lower levels");
35073507
}
35083508
}
35093509
}

0 commit comments

Comments
 (0)