# HG changeset patch # User shade # Date 1582142303 -3600 # Wed Feb 19 20:58:23 2020 +0100 # Node ID b1cd9f9945504be94258c2759921ec52facb541c # Parent 46bb1175b837d182c59f4412feb6afa66d919350 8239492: [x86] Turn MacroAssembler::verify_oop into macro recording file and line diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp @@ -304,7 +304,7 @@ __ addptr(rsp, 2 * BytesPerWord); // Verify result - __ verify_oop(rax, "Bad oop"); + __ verify_oop(rax); // Move result into place if (ref != rax) { diff --git a/src/hotspot/cpu/x86/interp_masm_x86.cpp b/src/hotspot/cpu/x86/interp_masm_x86.cpp --- a/src/hotspot/cpu/x86/interp_masm_x86.cpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp @@ -51,7 +51,7 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { Label update, next, none; - verify_oop(obj); + interp_verify_oop(obj, atos, __FILE__, __LINE__); testptr(obj, obj); jccb(Assembler::notZero, update); @@ -349,7 +349,7 @@ switch (state) { case atos: movptr(rax, oop_addr); movptr(oop_addr, (int32_t)NULL_WORD); - verify_oop(rax, state); break; + interp_verify_oop(rax, state, __FILE__, __LINE__); break; case ltos: movptr(rax, val_addr); break; case btos: // fall through case ztos: // fall through @@ -370,7 +370,7 @@ switch (state) { case atos: movptr(rax, oop_addr); movptr(oop_addr, NULL_WORD); - verify_oop(rax, state); break; + interp_verify_oop(rax, state, __FILE__, __LINE__); break; case ltos: movl(rdx, val_addr1); // fall through case btos: // fall through @@ -656,11 +656,11 @@ case vtos: /* nothing to do */ break; default: ShouldNotReachHere(); } - verify_oop(rax, state); + interp_verify_oop(rax, state, __FILE__, __LINE__); } void InterpreterMacroAssembler::push(TosState state) { - verify_oop(rax, state); + interp_verify_oop(rax, state, __FILE__, __LINE__); switch (state) { case atos: push_ptr(); break; case btos: @@ -722,7 +722,7 @@ case vtos: /* nothing to do */ break; default : ShouldNotReachHere(); } - verify_oop(rax, state); + interp_verify_oop(rax, state, __FILE__, __LINE__); } @@ -745,7 +745,7 @@ void InterpreterMacroAssembler::push(TosState state) { - verify_oop(rax, state); + interp_verify_oop(rax, state, __FILE__, __LINE__); switch (state) { case atos: push_ptr(rax); break; case btos: // fall through @@ -844,7 +844,7 @@ bind(L); } if (verifyoop) { - verify_oop(rax, state); + interp_verify_oop(rax, state, __FILE__, __LINE__); } address* const safepoint_table = Interpreter::safept_table(state); @@ -1959,9 +1959,9 @@ -void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { +void InterpreterMacroAssembler::interp_verify_oop(Register reg, TosState state, const char* file, int line) { if (state == atos) { - MacroAssembler::verify_oop(reg); + MacroAssembler::_verify_oop(reg, "broken oop", file, line); } } diff --git a/src/hotspot/cpu/x86/interp_masm_x86.hpp b/src/hotspot/cpu/x86/interp_masm_x86.hpp --- a/src/hotspot/cpu/x86/interp_masm_x86.hpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.hpp @@ -280,7 +280,7 @@ // Debugging // only if +VerifyOops && state == atos - void verify_oop(Register reg, TosState state = atos); + void interp_verify_oop(Register reg, TosState state, const char* file, int line); // only if +VerifyFPU && (state == ftos || state == dtos) void verify_FPU(int stack_depth, TosState state = ftos); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -2447,7 +2447,7 @@ void MacroAssembler::get_vm_result(Register oop_result, Register java_thread) { movptr(oop_result, Address(java_thread, JavaThread::vm_result_offset())); movptr(Address(java_thread, JavaThread::vm_result_offset()), NULL_WORD); - verify_oop(oop_result, "broken oop in call_VM_base"); + verify_oop(oop_result); } void MacroAssembler::get_vm_result_2(Register metadata_result, Register java_thread) { @@ -4638,7 +4638,7 @@ } } -void MacroAssembler::verify_oop(Register reg, const char* s) { +void MacroAssembler::_verify_oop(Register reg, const char* s, const char* file, int line) { if (!VerifyOops) return; // Pass register number to verify_oop_subroutine @@ -4646,7 +4646,7 @@ { ResourceMark rm; stringStream ss; - ss.print("verify_oop: %s: %s", reg->name(), s); + ss.print("verify_oop: %s: %s (%s:%d)", reg->name(), s, file, line); b = code_string(ss.as_string()); } BLOCK_COMMENT("verify_oop {"); @@ -4728,7 +4728,7 @@ } -void MacroAssembler::verify_oop_addr(Address addr, const char* s) { +void MacroAssembler::_verify_oop_addr(Address addr, const char* s, const char* file, int line) { if (!VerifyOops) return; // Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord); @@ -4737,7 +4737,7 @@ { ResourceMark rm; stringStream ss; - ss.print("verify_oop_addr: %s", s); + ss.print("verify_oop_addr: %s (%s:%d)", s, file, line); b = code_string(ss.as_string()); } #ifdef _LP64 @@ -5333,7 +5333,7 @@ #ifdef ASSERT verify_heapbase("MacroAssembler::encode_heap_oop: heap base corrupted?"); #endif - verify_oop(r, "broken oop in encode_heap_oop"); + verify_oop(r); if (CompressedOops::base() == NULL) { if (CompressedOops::shift() != 0) { assert (LogMinObjAlignmentInBytes == CompressedOops::shift(), "decode alg wrong"); @@ -5358,7 +5358,7 @@ bind(ok); } #endif - verify_oop(r, "broken oop in encode_heap_oop_not_null"); + verify_oop(r); if (CompressedOops::base() != NULL) { subq(r, r12_heapbase); } @@ -5379,7 +5379,7 @@ bind(ok); } #endif - verify_oop(src, "broken oop in encode_heap_oop_not_null2"); + verify_oop(src); if (dst != src) { movq(dst, src); } @@ -5408,7 +5408,7 @@ addq(r, r12_heapbase); bind(done); } - verify_oop(r, "broken oop in decode_heap_oop"); + verify_oop(r); } void MacroAssembler::decode_heap_oop_not_null(Register r) { diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -600,13 +600,16 @@ // only if +VerifyOops // TODO: Make these macros with file and line like sparc version! - void verify_oop(Register reg, const char* s = "broken oop"); - void verify_oop_addr(Address addr, const char * s = "broken oop addr"); + + void _verify_oop(Register reg, const char* s, const char * file, int line); + void _verify_oop_addr(Address addr, const char* s, const char * file, int line); // TODO: verify method and klass metadata (compare against vptr?) void _verify_method_ptr(Register reg, const char * msg, const char * file, int line) {} void _verify_klass_ptr(Register reg, const char * msg, const char * file, int line){} +#define verify_oop(reg) _verify_oop(reg, "broken oop ", __FILE__, __LINE__) +#define verify_oop_addr(addr) _verify_oop_addr(addr, "broken oop addr ", __FILE__, __LINE__) #define verify_method_ptr(reg) _verify_method_ptr(reg, "broken method " #reg, __FILE__, __LINE__) #define verify_klass_ptr(reg) _verify_klass_ptr(reg, "broken klass " #reg, __FILE__, __LINE__) diff --git a/src/hotspot/share/gc/z/zVerify.cpp b/src/hotspot/share/gc/z/zVerify.cpp --- a/src/hotspot/share/gc/z/zVerify.cpp +++ b/src/hotspot/share/gc/z/zVerify.cpp @@ -36,7 +36,7 @@ #define BAD_OOP_ARG(o, p) "Bad oop " PTR_FORMAT " found at " PTR_FORMAT, p2i(o), p2i(p) -static void verify_oop(oop* p) { +static void z_verify_oop(oop* p) { const oop o = RawAccess<>::oop_load(p); if (o != NULL) { const uintptr_t addr = ZOop::to_address(o); @@ -45,7 +45,7 @@ } } -static void verify_possibly_weak_oop(oop* p) { +static void z_verify_possibly_weak_oop(oop* p) { const oop o = RawAccess<>::oop_load(p); if (o != NULL) { const uintptr_t addr = ZOop::to_address(o); @@ -57,7 +57,7 @@ class ZVerifyRootClosure : public ZRootsIteratorClosure { public: virtual void do_oop(oop* p) { - verify_oop(p); + z_verify_oop(p); } virtual void do_oop(narrowOop*) { @@ -76,11 +76,11 @@ virtual void do_oop(oop* p) { if (_verify_weaks) { - verify_possibly_weak_oop(p); + z_verify_possibly_weak_oop(p); } else { // We should never encounter finalizable oops through strong // paths. This assumes we have only visited strong roots. - verify_oop(p); + z_verify_oop(p); } }