Skip to content

Commit

Permalink
8316197: Make tracing of inline cache available in unified logging
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, dholmes
  • Loading branch information
Yi-Fan Tsai authored and pull[bot] committed Mar 15, 2024
1 parent 1d0e781 commit 8329998
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 29 deletions.
5 changes: 3 additions & 2 deletions src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "code/compiledIC.hpp"
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
Expand Down Expand Up @@ -90,9 +91,9 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
address stub = find_stub();
guarantee(stub != nullptr, "stub not found");

if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
log_trace(inlinecache)("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
p2i(instruction_address()),
callee->name_and_sig_as_C_string());
}
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/cpu/arm/compiledIC_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "code/icBuffer.hpp"
#include "code/nativeInst.hpp"
#include "code/nmethod.hpp"
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
Expand Down Expand Up @@ -105,9 +106,9 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
address stub = find_stub();
guarantee(stub != nullptr, "stub not found");

if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
log_trace(inlinecache)("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
p2i(instruction_address()),
callee->name_and_sig_as_C_string());
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/ppc/compiledIC_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
address stub = find_stub();
guarantee(stub != nullptr, "stub not found");

if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
log_trace(inlinecache)("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
p2i(instruction_address()),
callee->name_and_sig_as_C_string());
}
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/cpu/riscv/compiledIC_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "code/compiledIC.hpp"
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
Expand Down Expand Up @@ -88,9 +89,9 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
address stub = find_stub();
guarantee(stub != nullptr, "stub not found");

if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
log_trace(inlinecache)("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
p2i(instruction_address()),
callee->name_and_sig_as_C_string());
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/s390/compiledIC_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
address stub = find_stub();
guarantee(stub != nullptr, "stub not found");

if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
log_trace(inlinecache)("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
p2i(instruction_address()),
callee->name_and_sig_as_C_string());
}
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/cpu/x86/compiledIC_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "code/compiledIC.hpp"
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepoint.hpp"
Expand Down Expand Up @@ -84,9 +85,9 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
address stub = find_stub();
guarantee(stub != nullptr, "stub not found");

if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
log_trace(inlinecache)("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
p2i(instruction_address()),
callee->name_and_sig_as_C_string());
}
Expand Down
25 changes: 13 additions & 12 deletions src/hotspot/share/code/compiledIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecod
}
}

if (TraceICs) {
{
ResourceMark rm;
assert(call_info->selected_method() != nullptr, "Unexpected null selected method");
tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT,
log_trace(inlinecache)("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT,
p2i(instruction_address()), call_info->selected_method()->print_value_string(), p2i(entry));
}

Expand Down Expand Up @@ -364,10 +364,11 @@ bool CompiledIC::is_call_to_interpreted() const {

bool CompiledIC::set_to_clean(bool in_use) {
assert(CompiledICLocker::is_safe(_method), "mt unsafe call");
if (TraceInlineCacheClearing || TraceICs) {
if (TraceInlineCacheClearing) {
tty->print_cr("IC@" INTPTR_FORMAT ": set to clean", p2i(instruction_address()));
print();
}
log_trace(inlinecache)("IC@" INTPTR_FORMAT ": set to clean", p2i(instruction_address()));

address entry = _call->get_resolve_call_stub(is_optimized());

Expand Down Expand Up @@ -433,9 +434,9 @@ bool CompiledIC::set_to_monomorphic(CompiledICInfo& info) {
methodHandle method (thread, (Method*)info.cached_metadata());
_call->set_to_interpreted(method, info);

if (TraceICs) {
ResourceMark rm(thread);
tty->print_cr ("IC@" INTPTR_FORMAT ": monomorphic to interpreter: %s",
{
ResourceMark rm(thread);
log_trace(inlinecache)("IC@" INTPTR_FORMAT ": monomorphic to interpreter: %s",
p2i(instruction_address()),
method->print_value_string());
}
Expand All @@ -449,9 +450,9 @@ bool CompiledIC::set_to_monomorphic(CompiledICInfo& info) {
// LSan appears unable to follow malloc-based memory consistently when embedded as an
// immediate in generated machine code. So we have to ignore it.
LSAN_IGNORE_OBJECT(holder);
if (TraceICs) {
{
ResourceMark rm(thread);
tty->print_cr ("IC@" INTPTR_FORMAT ": monomorphic to interpreter via icholder ", p2i(instruction_address()));
log_trace(inlinecache)("IC@" INTPTR_FORMAT ": monomorphic to interpreter via icholder ", p2i(instruction_address()));
}
}
} else {
Expand Down Expand Up @@ -479,10 +480,10 @@ bool CompiledIC::set_to_monomorphic(CompiledICInfo& info) {
}
}

if (TraceICs) {
{
ResourceMark rm(thread);
assert(info.cached_metadata() == nullptr || info.cached_metadata()->is_klass(), "must be");
tty->print_cr ("IC@" INTPTR_FORMAT ": monomorphic to compiled (rcvr klass = %s) %s",
log_trace(inlinecache)("IC@" INTPTR_FORMAT ": monomorphic to compiled (rcvr klass = %s) %s",
p2i(instruction_address()),
(info.cached_metadata() != nullptr) ? ((Klass*)info.cached_metadata())->print_value_string() : "nullptr",
(safe) ? "" : " via stub");
Expand Down Expand Up @@ -606,9 +607,9 @@ bool CompiledDirectStaticCall::is_call_to_interpreted() const {
}

void CompiledStaticCall::set_to_compiled(address entry) {
if (TraceICs) {
{
ResourceMark rm;
tty->print_cr("%s@" INTPTR_FORMAT ": set_to_compiled " INTPTR_FORMAT,
log_trace(inlinecache)("%s@" INTPTR_FORMAT ": set_to_compiled " INTPTR_FORMAT,
name(),
p2i(instruction_address()),
p2i(entry));
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/logging/logTag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class outputStream;
LOG_TAG(iklass) \
LOG_TAG(indy) \
LOG_TAG(init) \
LOG_TAG(inlinecache)\
LOG_TAG(inlining) \
LOG_TAG(install) \
LOG_TAG(interpreter) \
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,6 @@ const int ObjectAlignmentInBytes = 8;
develop(bool, TraceBytecodes, false, \
"Trace bytecode execution") \
\
develop(bool, TraceICs, false, \
"Trace inline cache changes") \
\
notproduct(bool, TraceInvocationCounterOverflow, false, \
"Trace method invocation counter overflow") \
\
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/compiler/arguments/TestTraceICs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/*
* @test
* @bug 8217447
* @summary Test running TraceICs enabled.
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TraceICs
* @summary Test running with log:inlinecache=trace enabled.
* @run main/othervm -Xlog:inlinecache=trace
* compiler.arguments.TestTraceICs
*/

Expand Down

0 comments on commit 8329998

Please sign in to comment.