Skip to content
Permalink
Browse files

8239492: [x86] Turn MacroAssembler::verify_oop into macro recording f…

…ile and line

Reviewed-by: rrich, vlivanov, pliden
  • Loading branch information
shipilev committed Feb 24, 2020
1 parent 8167fe9 commit 649a4d0613dbc19ab79f5a1b922e4548e09ef9e2
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -304,7 +304,7 @@ void ZBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce,
__ addptr(rsp, 2 * BytesPerWord);

// Verify result
__ verify_oop(rax, "Bad oop");
__ verify_oop(rax);

// Move result into place
if (ref != rax) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@ void InterpreterMacroAssembler::jump_to_entry(address entry) {
void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) {
Label update, next, none;

verify_oop(obj);
interp_verify_oop(obj, atos);

testptr(obj, obj);
jccb(Assembler::notZero, update);
@@ -349,7 +349,7 @@ void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
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); break;
case ltos: movptr(rax, val_addr); break;
case btos: // fall through
case ztos: // fall through
@@ -370,7 +370,7 @@ void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
switch (state) {
case atos: movptr(rax, oop_addr);
movptr(oop_addr, NULL_WORD);
verify_oop(rax, state); break;
interp_verify_oop(rax, state); break;
case ltos:
movl(rdx, val_addr1); // fall through
case btos: // fall through
@@ -656,11 +656,11 @@ void InterpreterMacroAssembler::pop(TosState state) {
case vtos: /* nothing to do */ break;
default: ShouldNotReachHere();
}
verify_oop(rax, state);
interp_verify_oop(rax, state);
}

void InterpreterMacroAssembler::push(TosState state) {
verify_oop(rax, state);
interp_verify_oop(rax, state);
switch (state) {
case atos: push_ptr(); break;
case btos:
@@ -722,7 +722,7 @@ void InterpreterMacroAssembler::pop(TosState state) {
case vtos: /* nothing to do */ break;
default : ShouldNotReachHere();
}
verify_oop(rax, state);
interp_verify_oop(rax, state);
}


@@ -745,7 +745,7 @@ void InterpreterMacroAssembler::push_d() {


void InterpreterMacroAssembler::push(TosState state) {
verify_oop(rax, state);
interp_verify_oop(rax, state);
switch (state) {
case atos: push_ptr(rax); break;
case btos: // fall through
@@ -844,7 +844,7 @@ void InterpreterMacroAssembler::dispatch_base(TosState state,
bind(L);
}
if (verifyoop) {
verify_oop(rax, state);
interp_verify_oop(rax, state);
}

address* const safepoint_table = Interpreter::safept_table(state);
@@ -1959,9 +1959,9 @@ void InterpreterMacroAssembler::profile_switch_case(Register index,



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);
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -280,7 +280,8 @@ class InterpreterMacroAssembler: public MacroAssembler {

// Debugging
// only if +VerifyOops && state == atos
void verify_oop(Register reg, TosState state = atos);
#define interp_verify_oop(reg, state) _interp_verify_oop(reg, state, __FILE__, __LINE__);
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);

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2447,7 +2447,7 @@ void MacroAssembler::super_call_VM_leaf(address entry_point, Register arg_0, Reg
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_msg(oop_result, "broken oop in call_VM_base");
}

void MacroAssembler::get_vm_result_2(Register metadata_result, Register java_thread) {
@@ -4638,15 +4638,15 @@ void MacroAssembler::cmov32(Condition cc, Register dst, Register src) {
}
}

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
const char* b = NULL;
{
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 @@ Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
}


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 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
{
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 @@ void MacroAssembler::encode_heap_oop(Register r) {
#ifdef ASSERT
verify_heapbase("MacroAssembler::encode_heap_oop: heap base corrupted?");
#endif
verify_oop(r, "broken oop in encode_heap_oop");
verify_oop_msg(r, "broken oop in encode_heap_oop");
if (CompressedOops::base() == NULL) {
if (CompressedOops::shift() != 0) {
assert (LogMinObjAlignmentInBytes == CompressedOops::shift(), "decode alg wrong");
@@ -5358,7 +5358,7 @@ void MacroAssembler::encode_heap_oop_not_null(Register r) {
bind(ok);
}
#endif
verify_oop(r, "broken oop in encode_heap_oop_not_null");
verify_oop_msg(r, "broken oop in encode_heap_oop_not_null");
if (CompressedOops::base() != NULL) {
subq(r, r12_heapbase);
}
@@ -5379,7 +5379,7 @@ void MacroAssembler::encode_heap_oop_not_null(Register dst, Register src) {
bind(ok);
}
#endif
verify_oop(src, "broken oop in encode_heap_oop_not_null2");
verify_oop_msg(src, "broken oop in encode_heap_oop_not_null2");
if (dst != src) {
movq(dst, src);
}
@@ -5408,7 +5408,7 @@ void MacroAssembler::decode_heap_oop(Register r) {
addq(r, r12_heapbase);
bind(done);
}
verify_oop(r, "broken oop in decode_heap_oop");
verify_oop_msg(r, "broken oop in decode_heap_oop");
}

void MacroAssembler::decode_heap_oop_not_null(Register r) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -599,14 +599,16 @@ class MacroAssembler: public Assembler {
// Debugging

// 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 " #reg, __FILE__, __LINE__)
#define verify_oop_msg(reg, msg) _verify_oop(reg, "broken oop " #reg ", " #msg, __FILE__, __LINE__)
#define verify_oop_addr(addr) _verify_oop_addr(addr, "broken oop addr " #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__)

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -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_oop(oop* p) {
}
}

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 @@ static void verify_possibly_weak_oop(oop* p) {
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 @@ class ZVerifyOopClosure : public ClaimMetadataVisitingOopIterateClosure, public

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);
}
}

0 comments on commit 649a4d0

Please sign in to comment.