8345269: Fix -Wzero-as-null-pointer-constant warnings in ppc code

Reviewed-by: mdoerr, mbaesken
This commit is contained in:
Kim Barrett 2024-12-11 19:37:01 +00:00
parent e4a34e96cd
commit 08bdeedfd3
9 changed files with 34 additions and 43 deletions

View File

@ -39,18 +39,10 @@ class Address {
intptr_t _disp; // Displacement.
public:
Address(Register b, Register i, address d = 0)
: _base(b), _index(i), _disp((intptr_t)d) {
assert(i == noreg || d == 0, "can't have both");
}
Address(Register b, address d = 0)
: _base(b), _index(noreg), _disp((intptr_t)d) {}
Address(Register b, ByteSize d)
: _base(b), _index(noreg), _disp((intptr_t)d) {}
Address(Register b, intptr_t d)
Address(Register b, intptr_t d = 0)
: _base(b), _index(noreg), _disp(d) {}
Address(Register b, RegisterOrConstant roc)

View File

@ -287,7 +287,7 @@ void frame::patch_pc(Thread* thread, address pc) {
p2i(&((address*) _sp)[-1]), p2i(((address*) _sp)[-1]), p2i(pc));
}
assert(!Continuation::is_return_barrier_entry(*pc_addr), "return barrier");
assert(_pc == *pc_addr || pc == *pc_addr || 0 == *pc_addr,
assert(_pc == *pc_addr || pc == *pc_addr || nullptr == *pc_addr,
"must be (pc: " INTPTR_FORMAT " _pc: " INTPTR_FORMAT " pc_addr: " INTPTR_FORMAT
" *pc_addr: " INTPTR_FORMAT " sp: " INTPTR_FORMAT ")",
p2i(pc), p2i(_pc), p2i(pc_addr), p2i(*pc_addr), p2i(sp()));
@ -318,10 +318,10 @@ void frame::patch_pc(Thread* thread, address pc) {
bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
assert(is_interpreted_frame(), "Not an interpreted frame");
// These are reasonable sanity checks
if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
if (fp() == nullptr || (intptr_t(fp()) & (wordSize-1)) != 0) {
return false;
}
if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
if (sp() == nullptr || (intptr_t(sp()) & (wordSize-1)) != 0) {
return false;
}
int min_frame_slots = (parent_ijava_frame_abi_size + ijava_state_size) / sizeof(intptr_t);

View File

@ -3296,7 +3296,7 @@ void MacroAssembler::get_vm_result_2(Register metadata_result) {
Register MacroAssembler::encode_klass_not_null(Register dst, Register src) {
Register current = (src != noreg) ? src : dst; // Klass is in dst if no src provided.
if (CompressedKlassPointers::base() != 0) {
if (CompressedKlassPointers::base() != nullptr) {
// Use dst as temp if it is free.
sub_const_optimized(dst, current, CompressedKlassPointers::base(), R0);
current = dst;
@ -3356,11 +3356,11 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src) {
if (src == noreg) src = dst;
Register shifted_src = src;
if (CompressedKlassPointers::shift() != 0 ||
(CompressedKlassPointers::base() == 0 && src != dst)) { // Move required.
(CompressedKlassPointers::base() == nullptr && src != dst)) { // Move required.
shifted_src = dst;
sldi(shifted_src, src, CompressedKlassPointers::shift());
}
if (CompressedKlassPointers::base() != 0) {
if (CompressedKlassPointers::base() != nullptr) {
add_const_optimized(dst, shifted_src, CompressedKlassPointers::base(), R0);
}
}

View File

@ -56,7 +56,7 @@ bool NativeInstruction::is_sigill_not_entrant_at(address addr) {
void NativeInstruction::verify() {
// Make sure code pattern is actually an instruction address.
address addr = addr_at(0);
if (addr == 0 || ((intptr_t)addr & 3) != 0) {
if (addr == nullptr || ((intptr_t)addr & 3) != 0) {
fatal("not an instruction address");
}
}
@ -115,7 +115,7 @@ void NativeCall::set_destination_mt_safe(address dest, bool assert_lock) {
// does not provide this information. The branch will be patched
// later during a final fixup, when all necessary information is
// available.
if (trampoline_stub_addr == 0)
if (trampoline_stub_addr == nullptr)
return;
// Patch the constant in the call's trampoline stub.

View File

@ -3338,7 +3338,7 @@ encode %{
// The trampoline stub.
// No entry point given, use the current pc.
// Make sure branch fits into
if (entry_point == 0) entry_point = __ pc();
if (entry_point == nullptr) entry_point = __ pc();
// Put the entry point as a constant into the constant pool.
const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none);
@ -3377,7 +3377,7 @@ encode %{
enc_class enc_java_dynamic_call_sched(method meth) %{
if (!ra_->C->output()->in_scratch_emit_size()) {
// Create a call trampoline stub for the given method.
const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method;
const address entry_point = !($meth$$method) ? nullptr : (address)$meth$$method;
const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none);
if (entry_point_const == nullptr) {
ciEnv::current()->record_out_of_memory_failure();
@ -3610,7 +3610,7 @@ encode %{
MachNode *mtctr = new CallLeafDirect_mtctrNode();
assert(loadConLNodes_Entry._last != nullptr, "entry must exist");
mtctr->add_req(0, loadConLNodes_Entry._last);
mtctr->add_req(nullptr, loadConLNodes_Entry._last);
mtctr->_opnds[0] = new iRegLdstOper();
mtctr->_opnds[1] = new iRegLdstOper();

View File

@ -94,7 +94,6 @@ void Relocation::pd_set_call_destination(address x) {
address* Relocation::pd_address_in_code() {
ShouldNotReachHere();
return 0;
}
address Relocation::pd_get_address_from_code() {

View File

@ -622,7 +622,7 @@ class StubGenerator: public StubCodeGenerator {
// Don't generate, rather use C++ code.
address generate_verify_oop() {
// this is actually a `FunctionDescriptor*'.
address start = 0;
address start = nullptr;
#if !defined(PRODUCT)
start = CAST_FROM_FN_PTR(address, verify_oop_helper);

View File

@ -2615,7 +2615,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
address pc_before_fence = __ pc();
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(__ pc() - pc_before_fence == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
assert(branch_table[vtos] == 0, "can't compute twice");
assert(branch_table[vtos] == nullptr, "can't compute twice");
branch_table[vtos] = __ pc(); // non-volatile_entry point
__ stop("vtos unexpected");
#endif
@ -2623,7 +2623,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Ldtos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[dtos] == 0, "can't compute twice");
assert(branch_table[dtos] == nullptr, "can't compute twice");
branch_table[dtos] = __ pc(); // non-volatile_entry point
__ lfdx(F15_ftos, Rclass_or_obj, Roffset);
__ push(dtos);
@ -2644,7 +2644,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Lftos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ftos] == 0, "can't compute twice");
assert(branch_table[ftos] == nullptr, "can't compute twice");
branch_table[ftos] = __ pc(); // non-volatile_entry point
__ lfsx(F15_ftos, Rclass_or_obj, Roffset);
__ push(ftos);
@ -2665,7 +2665,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Litos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[itos] == 0, "can't compute twice");
assert(branch_table[itos] == nullptr, "can't compute twice");
branch_table[itos] = __ pc(); // non-volatile_entry point
__ lwax(R17_tos, Rclass_or_obj, Roffset);
__ push(itos);
@ -2678,7 +2678,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Lltos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ltos] == 0, "can't compute twice");
assert(branch_table[ltos] == nullptr, "can't compute twice");
branch_table[ltos] = __ pc(); // non-volatile_entry point
__ ldx(R17_tos, Rclass_or_obj, Roffset);
__ push(ltos);
@ -2691,7 +2691,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Lbtos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[btos] == 0, "can't compute twice");
assert(branch_table[btos] == nullptr, "can't compute twice");
branch_table[btos] = __ pc(); // non-volatile_entry point
__ lbzx(R17_tos, Rclass_or_obj, Roffset);
__ extsb(R17_tos, R17_tos);
@ -2705,7 +2705,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Lztos); (same code as btos)
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ztos] == 0, "can't compute twice");
assert(branch_table[ztos] == nullptr, "can't compute twice");
branch_table[ztos] = __ pc(); // non-volatile_entry point
__ lbzx(R17_tos, Rclass_or_obj, Roffset);
__ push(ztos);
@ -2719,7 +2719,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Lctos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ctos] == 0, "can't compute twice");
assert(branch_table[ctos] == nullptr, "can't compute twice");
branch_table[ctos] = __ pc(); // non-volatile_entry point
__ lhzx(R17_tos, Rclass_or_obj, Roffset);
__ push(ctos);
@ -2732,7 +2732,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Lstos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[stos] == 0, "can't compute twice");
assert(branch_table[stos] == nullptr, "can't compute twice");
branch_table[stos] = __ pc(); // non-volatile_entry point
__ lhax(R17_tos, Rclass_or_obj, Roffset);
__ push(stos);
@ -2745,7 +2745,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align load.
// __ bind(Latos);
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[atos] == 0, "can't compute twice");
assert(branch_table[atos] == nullptr, "can't compute twice");
branch_table[atos] = __ pc(); // non-volatile_entry point
do_oop_load(_masm, Rclass_or_obj, Roffset, R17_tos, Rscratch, /* nv temp */ Rflags, IN_HEAP);
__ verify_oop(R17_tos);
@ -2932,7 +2932,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
address pc_before_release = __ pc();
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(__ pc() - pc_before_release == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
assert(branch_table[vtos] == 0, "can't compute twice");
assert(branch_table[vtos] == nullptr, "can't compute twice");
branch_table[vtos] = __ pc(); // non-volatile_entry point
__ stop("vtos unexpected");
#endif
@ -2940,7 +2940,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Ldtos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[dtos] == 0, "can't compute twice");
assert(branch_table[dtos] == nullptr, "can't compute twice");
branch_table[dtos] = __ pc(); // non-volatile_entry point
__ pop(dtos);
if (!is_static) {
@ -2958,7 +2958,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Lftos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ftos] == 0, "can't compute twice");
assert(branch_table[ftos] == nullptr, "can't compute twice");
branch_table[ftos] = __ pc(); // non-volatile_entry point
__ pop(ftos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
@ -2974,7 +2974,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Litos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[itos] == 0, "can't compute twice");
assert(branch_table[itos] == nullptr, "can't compute twice");
branch_table[itos] = __ pc(); // non-volatile_entry point
__ pop(itos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
@ -2990,7 +2990,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Lltos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ltos] == 0, "can't compute twice");
assert(branch_table[ltos] == nullptr, "can't compute twice");
branch_table[ltos] = __ pc(); // non-volatile_entry point
__ pop(ltos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
@ -3006,7 +3006,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Lbtos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[btos] == 0, "can't compute twice");
assert(branch_table[btos] == nullptr, "can't compute twice");
branch_table[btos] = __ pc(); // non-volatile_entry point
__ pop(btos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
@ -3022,7 +3022,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Lztos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ztos] == 0, "can't compute twice");
assert(branch_table[ztos] == nullptr, "can't compute twice");
branch_table[ztos] = __ pc(); // non-volatile_entry point
__ pop(ztos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
@ -3039,7 +3039,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Lctos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[ctos] == 0, "can't compute twice");
assert(branch_table[ctos] == nullptr, "can't compute twice");
branch_table[ctos] = __ pc(); // non-volatile_entry point
__ pop(ctos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1..
@ -3055,7 +3055,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Lstos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[stos] == 0, "can't compute twice");
assert(branch_table[stos] == nullptr, "can't compute twice");
branch_table[stos] = __ pc(); // non-volatile_entry point
__ pop(stos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
@ -3071,7 +3071,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
__ align(32, 28, 28); // Align pop.
// __ bind(Latos);
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
assert(branch_table[atos] == 0, "can't compute twice");
assert(branch_table[atos] == nullptr, "can't compute twice");
branch_table[atos] = __ pc(); // non-volatile_entry point
__ pop(atos);
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // kills R11_scratch1

View File

@ -423,7 +423,7 @@ void VM_Version::check_virtualizations() {
while (fgets(line, sizeof(line), fp) != nullptr) {
if (strncmp(line, system_type, strlen(system_type)) == 0) {
if (strstr(line, "qemu") != 0) {
if (strstr(line, "qemu") != nullptr) {
Abstract_VM_Version::_detected_virtualization = PowerKVM;
fclose(fp);
return;