Skip to content

Commit 08bdeed

Browse files
author
Kim Barrett
committed
8345269: Fix -Wzero-as-null-pointer-constant warnings in ppc code
Reviewed-by: mdoerr, mbaesken
1 parent e4a34e9 commit 08bdeed

9 files changed

+34
-43
lines changed

src/hotspot/cpu/ppc/assembler_ppc.hpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,10 @@ class Address {
3939
intptr_t _disp; // Displacement.
4040

4141
public:
42-
Address(Register b, Register i, address d = 0)
43-
: _base(b), _index(i), _disp((intptr_t)d) {
44-
assert(i == noreg || d == 0, "can't have both");
45-
}
46-
47-
Address(Register b, address d = 0)
48-
: _base(b), _index(noreg), _disp((intptr_t)d) {}
49-
5042
Address(Register b, ByteSize d)
5143
: _base(b), _index(noreg), _disp((intptr_t)d) {}
5244

53-
Address(Register b, intptr_t d)
45+
Address(Register b, intptr_t d = 0)
5446
: _base(b), _index(noreg), _disp(d) {}
5547

5648
Address(Register b, RegisterOrConstant roc)

src/hotspot/cpu/ppc/frame_ppc.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void frame::patch_pc(Thread* thread, address pc) {
287287
p2i(&((address*) _sp)[-1]), p2i(((address*) _sp)[-1]), p2i(pc));
288288
}
289289
assert(!Continuation::is_return_barrier_entry(*pc_addr), "return barrier");
290-
assert(_pc == *pc_addr || pc == *pc_addr || 0 == *pc_addr,
290+
assert(_pc == *pc_addr || pc == *pc_addr || nullptr == *pc_addr,
291291
"must be (pc: " INTPTR_FORMAT " _pc: " INTPTR_FORMAT " pc_addr: " INTPTR_FORMAT
292292
" *pc_addr: " INTPTR_FORMAT " sp: " INTPTR_FORMAT ")",
293293
p2i(pc), p2i(_pc), p2i(pc_addr), p2i(*pc_addr), p2i(sp()));
@@ -318,10 +318,10 @@ void frame::patch_pc(Thread* thread, address pc) {
318318
bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
319319
assert(is_interpreted_frame(), "Not an interpreted frame");
320320
// These are reasonable sanity checks
321-
if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
321+
if (fp() == nullptr || (intptr_t(fp()) & (wordSize-1)) != 0) {
322322
return false;
323323
}
324-
if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
324+
if (sp() == nullptr || (intptr_t(sp()) & (wordSize-1)) != 0) {
325325
return false;
326326
}
327327
int min_frame_slots = (parent_ijava_frame_abi_size + ijava_state_size) / sizeof(intptr_t);

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3296,7 +3296,7 @@ void MacroAssembler::get_vm_result_2(Register metadata_result) {
32963296

32973297
Register MacroAssembler::encode_klass_not_null(Register dst, Register src) {
32983298
Register current = (src != noreg) ? src : dst; // Klass is in dst if no src provided.
3299-
if (CompressedKlassPointers::base() != 0) {
3299+
if (CompressedKlassPointers::base() != nullptr) {
33003300
// Use dst as temp if it is free.
33013301
sub_const_optimized(dst, current, CompressedKlassPointers::base(), R0);
33023302
current = dst;
@@ -3356,11 +3356,11 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src) {
33563356
if (src == noreg) src = dst;
33573357
Register shifted_src = src;
33583358
if (CompressedKlassPointers::shift() != 0 ||
3359-
(CompressedKlassPointers::base() == 0 && src != dst)) { // Move required.
3359+
(CompressedKlassPointers::base() == nullptr && src != dst)) { // Move required.
33603360
shifted_src = dst;
33613361
sldi(shifted_src, src, CompressedKlassPointers::shift());
33623362
}
3363-
if (CompressedKlassPointers::base() != 0) {
3363+
if (CompressedKlassPointers::base() != nullptr) {
33643364
add_const_optimized(dst, shifted_src, CompressedKlassPointers::base(), R0);
33653365
}
33663366
}

src/hotspot/cpu/ppc/nativeInst_ppc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool NativeInstruction::is_sigill_not_entrant_at(address addr) {
5656
void NativeInstruction::verify() {
5757
// Make sure code pattern is actually an instruction address.
5858
address addr = addr_at(0);
59-
if (addr == 0 || ((intptr_t)addr & 3) != 0) {
59+
if (addr == nullptr || ((intptr_t)addr & 3) != 0) {
6060
fatal("not an instruction address");
6161
}
6262
}
@@ -115,7 +115,7 @@ void NativeCall::set_destination_mt_safe(address dest, bool assert_lock) {
115115
// does not provide this information. The branch will be patched
116116
// later during a final fixup, when all necessary information is
117117
// available.
118-
if (trampoline_stub_addr == 0)
118+
if (trampoline_stub_addr == nullptr)
119119
return;
120120

121121
// Patch the constant in the call's trampoline stub.

src/hotspot/cpu/ppc/ppc.ad

+3-3
Original file line numberDiff line numberDiff line change
@@ -3338,7 +3338,7 @@ encode %{
33383338
// The trampoline stub.
33393339
// No entry point given, use the current pc.
33403340
// Make sure branch fits into
3341-
if (entry_point == 0) entry_point = __ pc();
3341+
if (entry_point == nullptr) entry_point = __ pc();
33423342

33433343
// Put the entry point as a constant into the constant pool.
33443344
const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none);
@@ -3377,7 +3377,7 @@ encode %{
33773377
enc_class enc_java_dynamic_call_sched(method meth) %{
33783378
if (!ra_->C->output()->in_scratch_emit_size()) {
33793379
// Create a call trampoline stub for the given method.
3380-
const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method;
3380+
const address entry_point = !($meth$$method) ? nullptr : (address)$meth$$method;
33813381
const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none);
33823382
if (entry_point_const == nullptr) {
33833383
ciEnv::current()->record_out_of_memory_failure();
@@ -3610,7 +3610,7 @@ encode %{
36103610
MachNode *mtctr = new CallLeafDirect_mtctrNode();
36113611

36123612
assert(loadConLNodes_Entry._last != nullptr, "entry must exist");
3613-
mtctr->add_req(0, loadConLNodes_Entry._last);
3613+
mtctr->add_req(nullptr, loadConLNodes_Entry._last);
36143614

36153615
mtctr->_opnds[0] = new iRegLdstOper();
36163616
mtctr->_opnds[1] = new iRegLdstOper();

src/hotspot/cpu/ppc/relocInfo_ppc.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ void Relocation::pd_set_call_destination(address x) {
9494

9595
address* Relocation::pd_address_in_code() {
9696
ShouldNotReachHere();
97-
return 0;
9897
}
9998

10099
address Relocation::pd_get_address_from_code() {

src/hotspot/cpu/ppc/stubGenerator_ppc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ class StubGenerator: public StubCodeGenerator {
622622
// Don't generate, rather use C++ code.
623623
address generate_verify_oop() {
624624
// this is actually a `FunctionDescriptor*'.
625-
address start = 0;
625+
address start = nullptr;
626626

627627
#if !defined(PRODUCT)
628628
start = CAST_FROM_FN_PTR(address, verify_oop_helper);

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -2615,15 +2615,15 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
26152615
address pc_before_fence = __ pc();
26162616
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
26172617
assert(__ pc() - pc_before_fence == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
2618-
assert(branch_table[vtos] == 0, "can't compute twice");
2618+
assert(branch_table[vtos] == nullptr, "can't compute twice");
26192619
branch_table[vtos] = __ pc(); // non-volatile_entry point
26202620
__ stop("vtos unexpected");
26212621
#endif
26222622

26232623
__ align(32, 28, 28); // Align load.
26242624
// __ bind(Ldtos);
26252625
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2626-
assert(branch_table[dtos] == 0, "can't compute twice");
2626+
assert(branch_table[dtos] == nullptr, "can't compute twice");
26272627
branch_table[dtos] = __ pc(); // non-volatile_entry point
26282628
__ lfdx(F15_ftos, Rclass_or_obj, Roffset);
26292629
__ push(dtos);
@@ -2644,7 +2644,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
26442644
__ align(32, 28, 28); // Align load.
26452645
// __ bind(Lftos);
26462646
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2647-
assert(branch_table[ftos] == 0, "can't compute twice");
2647+
assert(branch_table[ftos] == nullptr, "can't compute twice");
26482648
branch_table[ftos] = __ pc(); // non-volatile_entry point
26492649
__ lfsx(F15_ftos, Rclass_or_obj, Roffset);
26502650
__ push(ftos);
@@ -2665,7 +2665,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
26652665
__ align(32, 28, 28); // Align load.
26662666
// __ bind(Litos);
26672667
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2668-
assert(branch_table[itos] == 0, "can't compute twice");
2668+
assert(branch_table[itos] == nullptr, "can't compute twice");
26692669
branch_table[itos] = __ pc(); // non-volatile_entry point
26702670
__ lwax(R17_tos, Rclass_or_obj, Roffset);
26712671
__ push(itos);
@@ -2678,7 +2678,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
26782678
__ align(32, 28, 28); // Align load.
26792679
// __ bind(Lltos);
26802680
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2681-
assert(branch_table[ltos] == 0, "can't compute twice");
2681+
assert(branch_table[ltos] == nullptr, "can't compute twice");
26822682
branch_table[ltos] = __ pc(); // non-volatile_entry point
26832683
__ ldx(R17_tos, Rclass_or_obj, Roffset);
26842684
__ push(ltos);
@@ -2691,7 +2691,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
26912691
__ align(32, 28, 28); // Align load.
26922692
// __ bind(Lbtos);
26932693
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2694-
assert(branch_table[btos] == 0, "can't compute twice");
2694+
assert(branch_table[btos] == nullptr, "can't compute twice");
26952695
branch_table[btos] = __ pc(); // non-volatile_entry point
26962696
__ lbzx(R17_tos, Rclass_or_obj, Roffset);
26972697
__ extsb(R17_tos, R17_tos);
@@ -2705,7 +2705,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
27052705
__ align(32, 28, 28); // Align load.
27062706
// __ bind(Lztos); (same code as btos)
27072707
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2708-
assert(branch_table[ztos] == 0, "can't compute twice");
2708+
assert(branch_table[ztos] == nullptr, "can't compute twice");
27092709
branch_table[ztos] = __ pc(); // non-volatile_entry point
27102710
__ lbzx(R17_tos, Rclass_or_obj, Roffset);
27112711
__ push(ztos);
@@ -2719,7 +2719,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
27192719
__ align(32, 28, 28); // Align load.
27202720
// __ bind(Lctos);
27212721
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2722-
assert(branch_table[ctos] == 0, "can't compute twice");
2722+
assert(branch_table[ctos] == nullptr, "can't compute twice");
27232723
branch_table[ctos] = __ pc(); // non-volatile_entry point
27242724
__ lhzx(R17_tos, Rclass_or_obj, Roffset);
27252725
__ push(ctos);
@@ -2732,7 +2732,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
27322732
__ align(32, 28, 28); // Align load.
27332733
// __ bind(Lstos);
27342734
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2735-
assert(branch_table[stos] == 0, "can't compute twice");
2735+
assert(branch_table[stos] == nullptr, "can't compute twice");
27362736
branch_table[stos] = __ pc(); // non-volatile_entry point
27372737
__ lhax(R17_tos, Rclass_or_obj, Roffset);
27382738
__ push(stos);
@@ -2745,7 +2745,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
27452745
__ align(32, 28, 28); // Align load.
27462746
// __ bind(Latos);
27472747
__ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
2748-
assert(branch_table[atos] == 0, "can't compute twice");
2748+
assert(branch_table[atos] == nullptr, "can't compute twice");
27492749
branch_table[atos] = __ pc(); // non-volatile_entry point
27502750
do_oop_load(_masm, Rclass_or_obj, Roffset, R17_tos, Rscratch, /* nv temp */ Rflags, IN_HEAP);
27512751
__ verify_oop(R17_tos);
@@ -2932,15 +2932,15 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
29322932
address pc_before_release = __ pc();
29332933
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
29342934
assert(__ pc() - pc_before_release == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
2935-
assert(branch_table[vtos] == 0, "can't compute twice");
2935+
assert(branch_table[vtos] == nullptr, "can't compute twice");
29362936
branch_table[vtos] = __ pc(); // non-volatile_entry point
29372937
__ stop("vtos unexpected");
29382938
#endif
29392939

29402940
__ align(32, 28, 28); // Align pop.
29412941
// __ bind(Ldtos);
29422942
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2943-
assert(branch_table[dtos] == 0, "can't compute twice");
2943+
assert(branch_table[dtos] == nullptr, "can't compute twice");
29442944
branch_table[dtos] = __ pc(); // non-volatile_entry point
29452945
__ pop(dtos);
29462946
if (!is_static) {
@@ -2958,7 +2958,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr
29582958
__ align(32, 28, 28); // Align pop.
29592959
// __ bind(Lftos);
29602960
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2961-
assert(branch_table[ftos] == 0, "can't compute twice");
2961+
assert(branch_table[ftos] == nullptr, "can't compute twice");
29622962
branch_table[ftos] = __ pc(); // non-volatile_entry point
29632963
__ pop(ftos);
29642964
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
29742974
__ align(32, 28, 28); // Align pop.
29752975
// __ bind(Litos);
29762976
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2977-
assert(branch_table[itos] == 0, "can't compute twice");
2977+
assert(branch_table[itos] == nullptr, "can't compute twice");
29782978
branch_table[itos] = __ pc(); // non-volatile_entry point
29792979
__ pop(itos);
29802980
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
29902990
__ align(32, 28, 28); // Align pop.
29912991
// __ bind(Lltos);
29922992
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
2993-
assert(branch_table[ltos] == 0, "can't compute twice");
2993+
assert(branch_table[ltos] == nullptr, "can't compute twice");
29942994
branch_table[ltos] = __ pc(); // non-volatile_entry point
29952995
__ pop(ltos);
29962996
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
30063006
__ align(32, 28, 28); // Align pop.
30073007
// __ bind(Lbtos);
30083008
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
3009-
assert(branch_table[btos] == 0, "can't compute twice");
3009+
assert(branch_table[btos] == nullptr, "can't compute twice");
30103010
branch_table[btos] = __ pc(); // non-volatile_entry point
30113011
__ pop(btos);
30123012
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
30223022
__ align(32, 28, 28); // Align pop.
30233023
// __ bind(Lztos);
30243024
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
3025-
assert(branch_table[ztos] == 0, "can't compute twice");
3025+
assert(branch_table[ztos] == nullptr, "can't compute twice");
30263026
branch_table[ztos] = __ pc(); // non-volatile_entry point
30273027
__ pop(ztos);
30283028
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
30393039
__ align(32, 28, 28); // Align pop.
30403040
// __ bind(Lctos);
30413041
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
3042-
assert(branch_table[ctos] == 0, "can't compute twice");
3042+
assert(branch_table[ctos] == nullptr, "can't compute twice");
30433043
branch_table[ctos] = __ pc(); // non-volatile_entry point
30443044
__ pop(ctos);
30453045
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
30553055
__ align(32, 28, 28); // Align pop.
30563056
// __ bind(Lstos);
30573057
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
3058-
assert(branch_table[stos] == 0, "can't compute twice");
3058+
assert(branch_table[stos] == nullptr, "can't compute twice");
30593059
branch_table[stos] = __ pc(); // non-volatile_entry point
30603060
__ pop(stos);
30613061
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
30713071
__ align(32, 28, 28); // Align pop.
30723072
// __ bind(Latos);
30733073
__ release(); // Volatile entry point (one instruction before non-volatile_entry point).
3074-
assert(branch_table[atos] == 0, "can't compute twice");
3074+
assert(branch_table[atos] == nullptr, "can't compute twice");
30753075
branch_table[atos] = __ pc(); // non-volatile_entry point
30763076
__ pop(atos);
30773077
if (!is_static) { pop_and_check_object(Rclass_or_obj); } // kills R11_scratch1

src/hotspot/cpu/ppc/vm_version_ppc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ void VM_Version::check_virtualizations() {
423423

424424
while (fgets(line, sizeof(line), fp) != nullptr) {
425425
if (strncmp(line, system_type, strlen(system_type)) == 0) {
426-
if (strstr(line, "qemu") != 0) {
426+
if (strstr(line, "qemu") != nullptr) {
427427
Abstract_VM_Version::_detected_virtualization = PowerKVM;
428428
fclose(fp);
429429
return;

0 commit comments

Comments
 (0)