mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-24 13:04:33 +02:00
7148486: At a method handle call returning with an exception may call the runtime with misaligned stack (x64)
Stack must be realigned when calling the runtime for exception propagation at a call. Reviewed-by: kvn, never
This commit is contained in:
parent
4012f6cd34
commit
c815908774
2 changed files with 26 additions and 6 deletions
|
@ -47,6 +47,12 @@ int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address e
|
||||||
assert(!(oop_result1->is_valid() || oop_result2->is_valid()) || oop_result1 != oop_result2, "registers must be different");
|
assert(!(oop_result1->is_valid() || oop_result2->is_valid()) || oop_result1 != oop_result2, "registers must be different");
|
||||||
assert(oop_result1 != thread && oop_result2 != thread, "registers must be different");
|
assert(oop_result1 != thread && oop_result2 != thread, "registers must be different");
|
||||||
assert(args_size >= 0, "illegal args_size");
|
assert(args_size >= 0, "illegal args_size");
|
||||||
|
bool align_stack = false;
|
||||||
|
#ifdef _LP64
|
||||||
|
// At a method handle call, the stack may not be properly aligned
|
||||||
|
// when returning with an exception.
|
||||||
|
align_stack = (stub_id() == Runtime1::handle_exception_from_callee_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _LP64
|
#ifdef _LP64
|
||||||
mov(c_rarg0, thread);
|
mov(c_rarg0, thread);
|
||||||
|
@ -59,11 +65,21 @@ int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address e
|
||||||
push(thread);
|
push(thread);
|
||||||
#endif // _LP64
|
#endif // _LP64
|
||||||
|
|
||||||
|
int call_offset;
|
||||||
|
if (!align_stack) {
|
||||||
set_last_Java_frame(thread, noreg, rbp, NULL);
|
set_last_Java_frame(thread, noreg, rbp, NULL);
|
||||||
|
} else {
|
||||||
|
address the_pc = pc();
|
||||||
|
call_offset = offset();
|
||||||
|
set_last_Java_frame(thread, noreg, rbp, the_pc);
|
||||||
|
andptr(rsp, -(StackAlignmentInBytes)); // Align stack
|
||||||
|
}
|
||||||
|
|
||||||
// do the call
|
// do the call
|
||||||
call(RuntimeAddress(entry));
|
call(RuntimeAddress(entry));
|
||||||
int call_offset = offset();
|
if (!align_stack) {
|
||||||
|
call_offset = offset();
|
||||||
|
}
|
||||||
// verify callee-saved register
|
// verify callee-saved register
|
||||||
#ifdef ASSERT
|
#ifdef ASSERT
|
||||||
guarantee(thread != rax, "change this code");
|
guarantee(thread != rax, "change this code");
|
||||||
|
@ -78,7 +94,7 @@ int StubAssembler::call_RT(Register oop_result1, Register oop_result2, address e
|
||||||
}
|
}
|
||||||
pop(rax);
|
pop(rax);
|
||||||
#endif
|
#endif
|
||||||
reset_last_Java_frame(thread, true, false);
|
reset_last_Java_frame(thread, true, align_stack);
|
||||||
|
|
||||||
// discard thread and arguments
|
// discard thread and arguments
|
||||||
NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
|
NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
|
||||||
|
|
|
@ -3620,8 +3620,12 @@ void OptoRuntime::generate_exception_blob() {
|
||||||
//
|
//
|
||||||
// address OptoRuntime::handle_exception_C(JavaThread* thread)
|
// address OptoRuntime::handle_exception_C(JavaThread* thread)
|
||||||
|
|
||||||
__ set_last_Java_frame(noreg, noreg, NULL);
|
// At a method handle call, the stack may not be properly aligned
|
||||||
|
// when returning with an exception.
|
||||||
|
address the_pc = __ pc();
|
||||||
|
__ set_last_Java_frame(noreg, noreg, the_pc);
|
||||||
__ mov(c_rarg0, r15_thread);
|
__ mov(c_rarg0, r15_thread);
|
||||||
|
__ andptr(rsp, -(StackAlignmentInBytes)); // Align stack
|
||||||
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
|
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
|
||||||
|
|
||||||
// Set an oopmap for the call site. This oopmap will only be used if we
|
// Set an oopmap for the call site. This oopmap will only be used if we
|
||||||
|
@ -3632,9 +3636,9 @@ void OptoRuntime::generate_exception_blob() {
|
||||||
|
|
||||||
OopMapSet* oop_maps = new OopMapSet();
|
OopMapSet* oop_maps = new OopMapSet();
|
||||||
|
|
||||||
oop_maps->add_gc_map( __ pc()-start, new OopMap(SimpleRuntimeFrame::framesize, 0));
|
oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
|
||||||
|
|
||||||
__ reset_last_Java_frame(false, false);
|
__ reset_last_Java_frame(false, true);
|
||||||
|
|
||||||
// Restore callee-saved registers
|
// Restore callee-saved registers
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue