提交 21b0475a 编写于 作者: K kvn

6958254: -XX:+VerifyOops is broken on x86

Summary: save and restore r10 in verify_oop().
Reviewed-by: never
上级 11a59890
...@@ -7643,6 +7643,9 @@ void MacroAssembler::verify_oop(Register reg, const char* s) { ...@@ -7643,6 +7643,9 @@ void MacroAssembler::verify_oop(Register reg, const char* s) {
// Pass register number to verify_oop_subroutine // Pass register number to verify_oop_subroutine
char* b = new char[strlen(s) + 50]; char* b = new char[strlen(s) + 50];
sprintf(b, "verify_oop: %s: %s", reg->name(), s); sprintf(b, "verify_oop: %s: %s", reg->name(), s);
#ifdef _LP64
push(rscratch1); // save r10, trashed by movptr()
#endif
push(rax); // save rax, push(rax); // save rax,
push(reg); // pass register argument push(reg); // pass register argument
ExternalAddress buffer((address) b); ExternalAddress buffer((address) b);
...@@ -7653,6 +7656,7 @@ void MacroAssembler::verify_oop(Register reg, const char* s) { ...@@ -7653,6 +7656,7 @@ void MacroAssembler::verify_oop(Register reg, const char* s) {
// call indirectly to solve generation ordering problem // call indirectly to solve generation ordering problem
movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address())); movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
call(rax); call(rax);
// Caller pops the arguments (oop, message) and restores rax, r10
} }
...@@ -7767,6 +7771,9 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) { ...@@ -7767,6 +7771,9 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
char* b = new char[strlen(s) + 50]; char* b = new char[strlen(s) + 50];
sprintf(b, "verify_oop_addr: %s", s); sprintf(b, "verify_oop_addr: %s", s);
#ifdef _LP64
push(rscratch1); // save r10, trashed by movptr()
#endif
push(rax); // save rax, push(rax); // save rax,
// addr may contain rsp so we will have to adjust it based on the push // addr may contain rsp so we will have to adjust it based on the push
// we just did // we just did
...@@ -7789,7 +7796,7 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) { ...@@ -7789,7 +7796,7 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
// call indirectly to solve generation ordering problem // call indirectly to solve generation ordering problem
movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address())); movptr(rax, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address()));
call(rax); call(rax);
// Caller pops the arguments and restores rax, from the stack // Caller pops the arguments (addr, message) and restores rax, r10.
} }
void MacroAssembler::verify_tlab() { void MacroAssembler::verify_tlab() {
......
...@@ -914,6 +914,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -914,6 +914,7 @@ class StubGenerator: public StubCodeGenerator {
// * [tos + 5]: error message (char*) // * [tos + 5]: error message (char*)
// * [tos + 6]: object to verify (oop) // * [tos + 6]: object to verify (oop)
// * [tos + 7]: saved rax - saved by caller and bashed // * [tos + 7]: saved rax - saved by caller and bashed
// * [tos + 8]: saved r10 (rscratch1) - saved by caller
// * = popped on exit // * = popped on exit
address generate_verify_oop() { address generate_verify_oop() {
StubCodeMark mark(this, "StubRoutines", "verify_oop"); StubCodeMark mark(this, "StubRoutines", "verify_oop");
...@@ -934,6 +935,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -934,6 +935,7 @@ class StubGenerator: public StubCodeGenerator {
// After previous pushes. // After previous pushes.
oop_to_verify = 6 * wordSize, oop_to_verify = 6 * wordSize,
saved_rax = 7 * wordSize, saved_rax = 7 * wordSize,
saved_r10 = 8 * wordSize,
// Before the call to MacroAssembler::debug(), see below. // Before the call to MacroAssembler::debug(), see below.
return_addr = 16 * wordSize, return_addr = 16 * wordSize,
...@@ -983,15 +985,17 @@ class StubGenerator: public StubCodeGenerator { ...@@ -983,15 +985,17 @@ class StubGenerator: public StubCodeGenerator {
// return if everything seems ok // return if everything seems ok
__ bind(exit); __ bind(exit);
__ movptr(rax, Address(rsp, saved_rax)); // get saved rax back __ movptr(rax, Address(rsp, saved_rax)); // get saved rax back
__ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back
__ pop(c_rarg3); // restore c_rarg3 __ pop(c_rarg3); // restore c_rarg3
__ pop(c_rarg2); // restore c_rarg2 __ pop(c_rarg2); // restore c_rarg2
__ pop(r12); // restore r12 __ pop(r12); // restore r12
__ popf(); // restore flags __ popf(); // restore flags
__ ret(3 * wordSize); // pop caller saved stuff __ ret(4 * wordSize); // pop caller saved stuff
// handle errors // handle errors
__ bind(error); __ bind(error);
__ movptr(rax, Address(rsp, saved_rax)); // get saved rax back __ movptr(rax, Address(rsp, saved_rax)); // get saved rax back
__ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back
__ pop(c_rarg3); // get saved c_rarg3 back __ pop(c_rarg3); // get saved c_rarg3 back
__ pop(c_rarg2); // get saved c_rarg2 back __ pop(c_rarg2); // get saved c_rarg2 back
__ pop(r12); // get saved r12 back __ pop(r12); // get saved r12 back
...@@ -1009,6 +1013,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -1009,6 +1013,7 @@ class StubGenerator: public StubCodeGenerator {
// * [tos + 17] error message (char*) // * [tos + 17] error message (char*)
// * [tos + 18] object to verify (oop) // * [tos + 18] object to verify (oop)
// * [tos + 19] saved rax - saved by caller and bashed // * [tos + 19] saved rax - saved by caller and bashed
// * [tos + 20] saved r10 (rscratch1) - saved by caller
// * = popped on exit // * = popped on exit
__ movptr(c_rarg0, Address(rsp, error_msg)); // pass address of error message __ movptr(c_rarg0, Address(rsp, error_msg)); // pass address of error message
...@@ -1021,7 +1026,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -1021,7 +1026,7 @@ class StubGenerator: public StubCodeGenerator {
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64))); __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64)));
__ mov(rsp, r12); // restore rsp __ mov(rsp, r12); // restore rsp
__ popa(); // pop registers (includes r12) __ popa(); // pop registers (includes r12)
__ ret(3 * wordSize); // pop caller saved stuff __ ret(4 * wordSize); // pop caller saved stuff
return start; return start;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册