8245107: Use Unified Logging in trace_method_handle_stub()
Reviewed-by: coleenp, mdoerr
This commit is contained in:
parent
0201a33dd6
commit
f148915d54
@ -32,6 +32,7 @@
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "interpreter/interpreterRuntime.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
@ -482,24 +483,29 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
|
||||
intptr_t mh_reg = (intptr_t)saved_regs[R5_mh->encoding()];
|
||||
const char* mh_reg_name = "R5_mh";
|
||||
if (!has_mh) mh_reg_name = "R5";
|
||||
tty->print_cr("MH %s %s=" PTR_FORMAT " sp=(" PTR_FORMAT "+" INTX_FORMAT ") stack_size=" INTX_FORMAT " bp=" PTR_FORMAT,
|
||||
adaptername, mh_reg_name, mh_reg,
|
||||
(intptr_t)entry_sp, (intptr_t)saved_sp - (intptr_t)entry_sp, (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp);
|
||||
if (!has_mh) {
|
||||
mh_reg_name = "R5";
|
||||
}
|
||||
log_info(methodhandles)("MH %s %s=" PTR_FORMAT " sp=(" PTR_FORMAT "+" INTX_FORMAT ") stack_size=" INTX_FORMAT " bp=" PTR_FORMAT,
|
||||
adaptername, mh_reg_name, mh_reg,
|
||||
(intptr_t)entry_sp, (intptr_t)saved_sp - (intptr_t)entry_sp, (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp);
|
||||
|
||||
if (last_sp != saved_sp && last_sp != NULL)
|
||||
tty->print_cr("*** last_sp=" INTPTR_FORMAT, p2i(last_sp));
|
||||
if (Verbose) {
|
||||
if (last_sp != saved_sp && last_sp != NULL) {
|
||||
log_info(methodhandles)("*** last_sp=" INTPTR_FORMAT, p2i(last_sp));
|
||||
}
|
||||
LogTarget(Trace, methodhandles) lt;
|
||||
if (lt.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
tty->print(" reg dump: ");
|
||||
LogStream ls(lt);
|
||||
ls.print(" reg dump: ");
|
||||
int i;
|
||||
for (i = 0; i < trace_mh_nregs; i++) {
|
||||
if (i > 0 && i % 4 == 0)
|
||||
tty->print("\n + dump: ");
|
||||
ls.print("\n + dump: ");
|
||||
const char* reg_name = trace_mh_regs[i]->name();
|
||||
tty->print(" %s: " INTPTR_FORMAT, reg_name, p2i((void *)saved_regs[i]));
|
||||
ls.print(" %s: " INTPTR_FORMAT, reg_name, p2i((void*)saved_regs[i]));
|
||||
}
|
||||
tty->cr();
|
||||
ls.cr();
|
||||
|
||||
{
|
||||
// dump last frame (from JavaThread::print_frame_layout)
|
||||
@ -527,14 +533,14 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
}
|
||||
|
||||
// Note: the unextended_sp may not be correct
|
||||
tty->print_cr(" stack layout:");
|
||||
values.print(p);
|
||||
ls.print_cr(" stack layout:");
|
||||
values.print_on(p, &ls);
|
||||
}
|
||||
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
mh->print_on(&ls);
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
java_lang_invoke_MethodHandle::form(mh)->print_on(&ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
@ -490,25 +491,27 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
bool has_mh = (strstr(adaptername, "/static") == NULL &&
|
||||
strstr(adaptername, "linkTo") == NULL); // static linkers don't have MH
|
||||
const char* mh_reg_name = has_mh ? "R23_method_handle" : "G23";
|
||||
tty->print_cr("MH %s %s=" INTPTR_FORMAT " sp=" INTPTR_FORMAT,
|
||||
log_info(methodhandles)("MH %s %s=" INTPTR_FORMAT " sp=" INTPTR_FORMAT,
|
||||
adaptername, mh_reg_name, p2i(mh), p2i(entry_sp));
|
||||
|
||||
if (Verbose) {
|
||||
LogTarget(Trace, methodhandles) lt;
|
||||
if (lt.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
tty->print_cr("Registers:");
|
||||
LogStream ls(lt);
|
||||
ls.print_cr("Registers:");
|
||||
const int abi_offset = frame::abi_reg_args_size / 8;
|
||||
for (int i = R3->encoding(); i <= R12->encoding(); i++) {
|
||||
Register r = as_Register(i);
|
||||
int count = i - R3->encoding();
|
||||
// The registers are stored in reverse order on the stack (by save_volatile_gprs(R1_SP, abi_reg_args_size)).
|
||||
tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[abi_offset + count]);
|
||||
ls.print("%3s=" PTR_FORMAT, r->name(), saved_regs[abi_offset + count]);
|
||||
if ((count + 1) % 4 == 0) {
|
||||
tty->cr();
|
||||
ls.cr();
|
||||
} else {
|
||||
tty->print(", ");
|
||||
ls.print(", ");
|
||||
}
|
||||
}
|
||||
tty->cr();
|
||||
ls.cr();
|
||||
|
||||
{
|
||||
// dumping last frame with frame::describe
|
||||
@ -542,14 +545,14 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
|
||||
values.describe(-1, saved_regs, "raw top of stack");
|
||||
|
||||
tty->print_cr("Stack layout:");
|
||||
values.print(p);
|
||||
ls.print_cr("Stack layout:");
|
||||
values.print_on(p, &ls);
|
||||
}
|
||||
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
mh->print_on(&ls);
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
java_lang_invoke_MethodHandle::form(mh)->print_on(&ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
@ -555,16 +556,17 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
bool has_mh = (strstr(adaptername, "/static") == NULL &&
|
||||
strstr(adaptername, "linkTo") == NULL); // Static linkers don't have MH.
|
||||
const char* mh_reg_name = has_mh ? "Z_R4_mh" : "Z_R4";
|
||||
tty->print_cr("MH %s %s=" INTPTR_FORMAT " sender_sp=" INTPTR_FORMAT " args=" INTPTR_FORMAT,
|
||||
adaptername, mh_reg_name,
|
||||
p2i(mh), p2i(sender_sp), p2i(args));
|
||||
log_info(methodhandles)("MH %s %s=" INTPTR_FORMAT " sender_sp=" INTPTR_FORMAT " args=" INTPTR_FORMAT,
|
||||
adaptername, mh_reg_name,
|
||||
p2i(mh), p2i(sender_sp), p2i(args));
|
||||
|
||||
if (Verbose) {
|
||||
LogTarget(Trace, methodhandles) lt;
|
||||
if (lt.is_enabled()) {
|
||||
// Dumping last frame with frame::describe.
|
||||
|
||||
ResourceMark rm;
|
||||
LogStream ls(lt);
|
||||
JavaThread* p = JavaThread::active();
|
||||
|
||||
ResourceMark rm;
|
||||
PRESERVE_EXCEPTION_MARK; // May not be needed by safer and unexpensive here.
|
||||
FrameValues values;
|
||||
|
||||
@ -614,12 +616,12 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
}
|
||||
|
||||
// Note: the unextended_sp may not be correct.
|
||||
tty->print_cr(" stack layout:");
|
||||
values.print(p);
|
||||
ls.print_cr(" stack layout:");
|
||||
values.print_on(p, &ls);
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
mh->print_on(&ls);
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
java_lang_invoke_MethodHandle::form(mh)->print_on(&ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "interpreter/interpreterRuntime.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
@ -506,13 +507,13 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
bool has_mh = (strstr(adaptername, "/static") == NULL &&
|
||||
strstr(adaptername, "linkTo") == NULL); // static linkers don't have MH
|
||||
const char* mh_reg_name = has_mh ? "rcx_mh" : "rcx";
|
||||
tty->print_cr("MH %s %s=" PTR_FORMAT " sp=" PTR_FORMAT,
|
||||
adaptername, mh_reg_name,
|
||||
p2i(mh), p2i(entry_sp));
|
||||
log_info(methodhandles)("MH %s %s=" PTR_FORMAT " sp=" PTR_FORMAT, adaptername, mh_reg_name, p2i(mh), p2i(entry_sp));
|
||||
|
||||
if (Verbose) {
|
||||
LogTarget(Trace, methodhandles) lt;
|
||||
if (lt.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
tty->print_cr("Registers:");
|
||||
LogStream ls(lt);
|
||||
ls.print_cr("Registers:");
|
||||
const int saved_regs_count = RegisterImpl::number_of_registers;
|
||||
for (int i = 0; i < saved_regs_count; i++) {
|
||||
Register r = as_Register(i);
|
||||
@ -521,20 +522,20 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
assert(RegisterImpl::number_of_registers == 16, "sanity");
|
||||
if (r == rsp) {
|
||||
// rsp is actually not stored by pusha(), compute the old rsp from saved_regs (rsp after pusha): saved_regs + 16 = old rsp
|
||||
tty->print("%3s=" PTR_FORMAT, r->name(), (intptr_t)(&saved_regs[16]));
|
||||
ls.print("%3s=" PTR_FORMAT, r->name(), (intptr_t)(&saved_regs[16]));
|
||||
} else {
|
||||
tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]);
|
||||
ls.print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]);
|
||||
}
|
||||
#else
|
||||
tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]);
|
||||
ls.print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]);
|
||||
#endif
|
||||
if ((i + 1) % 4 == 0) {
|
||||
tty->cr();
|
||||
ls.cr();
|
||||
} else {
|
||||
tty->print(", ");
|
||||
ls.print(", ");
|
||||
}
|
||||
}
|
||||
tty->cr();
|
||||
ls.cr();
|
||||
|
||||
// Note: We want to allow trace_method_handle from any call site.
|
||||
// While trace_method_handle creates a frame, it may be entered
|
||||
@ -585,13 +586,13 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
}
|
||||
values.describe(-1, entry_sp, "raw top of stack");
|
||||
|
||||
tty->print_cr("Stack layout:");
|
||||
values.print(p);
|
||||
ls.print_cr("Stack layout:");
|
||||
values.print_on(p, &ls);
|
||||
}
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
mh->print_on(&ls);
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
java_lang_invoke_MethodHandle::form(mh)->print_on(&ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1288,7 +1288,7 @@ void FrameValues::validate() {
|
||||
}
|
||||
#endif // ASSERT
|
||||
|
||||
void FrameValues::print(JavaThread* thread) {
|
||||
void FrameValues::print_on(JavaThread* thread, outputStream* st) {
|
||||
_values.sort(compare);
|
||||
|
||||
// Sometimes values like the fp can be invalid values if the
|
||||
@ -1321,14 +1321,14 @@ void FrameValues::print(JavaThread* thread) {
|
||||
for (int i = max_index; i >= min_index; i--) {
|
||||
FrameValue fv = _values.at(i);
|
||||
while (cur > fv.location) {
|
||||
tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(cur), *cur);
|
||||
st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(cur), *cur);
|
||||
cur--;
|
||||
}
|
||||
if (last == fv.location) {
|
||||
const char* spacer = " " LP64_ONLY(" ");
|
||||
tty->print_cr(" %s %s %s", spacer, spacer, fv.description);
|
||||
st->print_cr(" %s %s %s", spacer, spacer, fv.description);
|
||||
} else {
|
||||
tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
|
||||
st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
|
||||
last = fv.location;
|
||||
cur--;
|
||||
}
|
||||
|
@ -440,7 +440,8 @@ class FrameValues {
|
||||
#ifdef ASSERT
|
||||
void validate();
|
||||
#endif
|
||||
void print(JavaThread* thread);
|
||||
void print(JavaThread* thread) { print_on(thread, tty); }
|
||||
void print_on(JavaThread* thread, outputStream* out);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user