提交 77016965 编写于 作者: T twisti

7141329: Strange values of stack_size in -XX:+TraceMethodHandles output

Reviewed-by: kvn, never
上级 e3cecb62
...@@ -1018,41 +1018,26 @@ extern "C" void print_method_handle(oop mh); ...@@ -1018,41 +1018,26 @@ extern "C" void print_method_handle(oop mh);
void trace_method_handle_stub(const char* adaptername, void trace_method_handle_stub(const char* adaptername,
oop mh, oop mh,
intptr_t* saved_regs, intptr_t* saved_regs,
intptr_t* entry_sp, intptr_t* entry_sp) {
intptr_t* saved_sp,
intptr_t* saved_bp) {
// called as a leaf from native code: do not block the JVM! // called as a leaf from native code: do not block the JVM!
bool has_mh = (strstr(adaptername, "return/") == NULL); // return adapters don't have rcx_mh bool has_mh = (strstr(adaptername, "return/") == NULL); // return adapters don't have rcx_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, mh, entry_sp);
intptr_t* last_sp = (intptr_t*) saved_bp[frame::interpreter_frame_last_sp_offset];
intptr_t* base_sp = last_sp;
typedef MethodHandles::RicochetFrame RicochetFrame;
RicochetFrame* rfp = (RicochetFrame*)((address)saved_bp - RicochetFrame::sender_link_offset_in_bytes());
if (Universe::heap()->is_in((address) rfp->saved_args_base())) {
// Probably an interpreter frame.
base_sp = (intptr_t*) saved_bp[frame::interpreter_frame_monitor_block_top_offset];
}
intptr_t mh_reg = (intptr_t)mh;
const char* mh_reg_name = "rcx_mh";
if (!has_mh) mh_reg_name = "rcx";
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 - entry_sp), (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp);
if (Verbose) { if (Verbose) {
tty->print(" reg dump: "); tty->print_cr("Registers:");
int saved_regs_count = (entry_sp-1) - saved_regs; const int saved_regs_count = RegisterImpl::number_of_registers;
// 32 bit: rdi rsi rbp rsp; rbx rdx rcx (*) rax for (int i = 0; i < saved_regs_count; i++) {
int i; Register r = as_Register(i);
for (i = 0; i <= saved_regs_count; i++) { // The registers are stored in reverse order on the stack (by pusha).
if (i > 0 && i % 4 == 0 && i != saved_regs_count) { tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]);
if ((i + 1) % 4 == 0) {
tty->cr(); tty->cr();
tty->print(" + dump: "); } else {
tty->print(", ");
} }
tty->print(" %d: "PTR_FORMAT, i, saved_regs[i]);
} }
tty->cr(); tty->cr();
if (last_sp != saved_sp && last_sp != NULL)
tty->print_cr("*** last_sp="PTR_FORMAT, (intptr_t)last_sp);
{ {
// dumping last frame with frame::describe // dumping last frame with frame::describe
...@@ -1102,14 +1087,7 @@ void trace_method_handle_stub(const char* adaptername, ...@@ -1102,14 +1087,7 @@ void trace_method_handle_stub(const char* adaptername,
values.describe(-1, dump_sp, "sp for #1"); values.describe(-1, dump_sp, "sp for #1");
} }
// mark saved_sp if seems valid tty->print_cr("Stack layout:");
if (has_mh) {
if ((saved_sp >= dump_sp - UNREASONABLE_STACK_MOVE) && (saved_sp < dump_fp)) {
values.describe(-1, saved_sp, "*saved_sp");
}
}
tty->print_cr(" stack layout:");
values.print(p); values.print(p);
} }
if (has_mh) if (has_mh)
...@@ -1125,16 +1103,12 @@ struct MethodHandleStubArguments { ...@@ -1125,16 +1103,12 @@ struct MethodHandleStubArguments {
oopDesc* mh; oopDesc* mh;
intptr_t* saved_regs; intptr_t* saved_regs;
intptr_t* entry_sp; intptr_t* entry_sp;
intptr_t* saved_sp;
intptr_t* saved_bp;
}; };
void trace_method_handle_stub_wrapper(MethodHandleStubArguments* args) { void trace_method_handle_stub_wrapper(MethodHandleStubArguments* args) {
trace_method_handle_stub(args->adaptername, trace_method_handle_stub(args->adaptername,
args->mh, args->mh,
args->saved_regs, args->saved_regs,
args->entry_sp, args->entry_sp);
args->saved_sp,
args->saved_bp);
} }
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) { void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
...@@ -1157,20 +1131,18 @@ void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adapt ...@@ -1157,20 +1131,18 @@ void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adapt
__ fst_d(Address(rsp, 0)); __ fst_d(Address(rsp, 0));
} }
// incoming state: // Incoming state:
// rcx: method handle // rcx: method handle
// r13 or rsi: saved sp //
// To avoid calling convention issues, build a record on the stack and pass the pointer to that instead. // To avoid calling convention issues, build a record on the stack
// Note: fix the increment below if pushing more arguments // and pass the pointer to that instead.
__ push(rbp); // saved_bp
__ push(saved_last_sp_register()); // saved_sp
__ push(rbp); // entry_sp (with extra align space) __ push(rbp); // entry_sp (with extra align space)
__ push(rbx); // pusha saved_regs __ push(rbx); // pusha saved_regs
__ push(rcx); // mh __ push(rcx); // mh
__ push(rcx); // slot for adaptername __ push(rcx); // slot for adaptername
__ movptr(Address(rsp, 0), (intptr_t) adaptername); __ movptr(Address(rsp, 0), (intptr_t) adaptername);
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub_wrapper), rsp); __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub_wrapper), rsp);
__ increment(rsp, 6 * wordSize); // MethodHandleStubArguments __ increment(rsp, sizeof(MethodHandleStubArguments));
if (UseSSE >= 2) { if (UseSSE >= 2) {
__ movdbl(xmm0, Address(rsp, 0)); __ movdbl(xmm0, Address(rsp, 0));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册