Skip to content

Commit

Permalink
8340620: Fix -Wzero-as-null-pointer-constant warnings for CompressedOops
Browse files Browse the repository at this point in the history
Reviewed-by: shade, stefank, mli, amitkumar
  • Loading branch information
Kim Barrett committed Sep 27, 2024
1 parent 6587909 commit 25e8929
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/hotspot/cpu/ppc/ppc.ad
Original file line number Diff line number Diff line change
Expand Up @@ -6598,7 +6598,7 @@ instruct encodeP_not_null_Ex(iRegNdst dst, iRegPsrc src) %{
instruct encodeP_not_null_base_null(iRegNdst dst, iRegPsrc src) %{
match(Set dst (EncodeP src));
predicate(CompressedOops::shift() != 0 &&
CompressedOops::base() ==0);
CompressedOops::base() == nullptr);

format %{ "SRDI $dst, $src, #3 \t// encodeP, $src != nullptr" %}
size(4);
Expand Down Expand Up @@ -6695,7 +6695,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{
predicate((n->bottom_type()->is_oopptr()->ptr() != TypePtr::NotNull &&
n->bottom_type()->is_oopptr()->ptr() != TypePtr::Constant) &&
CompressedOops::shift() != 0 &&
CompressedOops::base() != 0);
CompressedOops::base() != nullptr);
ins_cost(4 * DEFAULT_COST); // Should be more expensive than decodeN_Disjoint_isel_Ex.
effect(TEMP crx);

Expand All @@ -6707,7 +6707,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{
instruct decodeN_nullBase(iRegPdst dst, iRegNsrc src) %{
match(Set dst (DecodeN src));
predicate(CompressedOops::shift() != 0 &&
CompressedOops::base() == 0);
CompressedOops::base() == nullptr);

format %{ "SLDI $dst, $src, #3 \t// DecodeN (zerobased)" %}
size(4);
Expand Down Expand Up @@ -6825,7 +6825,7 @@ instruct decodeN_notNull_addBase_Ex(iRegPdst dst, iRegNsrc src) %{
predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull ||
n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
CompressedOops::shift() != 0 &&
CompressedOops::base() != 0);
CompressedOops::base() != nullptr);
ins_cost(2 * DEFAULT_COST);

format %{ "DecodeN $dst, $src \t// $src != nullptr, postalloc expanded" %}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/s390/s390.ad
Original file line number Diff line number Diff line change
Expand Up @@ -4628,7 +4628,7 @@ instruct encodeP(iRegN dst, iRegP src, flagsReg cr) %{
match(Set dst (EncodeP src));
effect(KILL cr);
predicate((n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull) &&
(CompressedOops::base() == 0 ||
(CompressedOops::base() == nullptr ||
CompressedOops::base_disjoint() ||
!ExpandLoadingBaseEncode));
ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
Expand All @@ -4651,7 +4651,7 @@ instruct encodeP_NN(iRegN dst, iRegP src, flagsReg cr) %{
match(Set dst (EncodeP src));
effect(KILL cr);
predicate((n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull) &&
(CompressedOops::base() == 0 ||
(CompressedOops::base() == nullptr ||
CompressedOops::base_disjoint() ||
!ExpandLoadingBaseEncode_NN));
ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/compressedOops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void CompressedOops::initialize(const ReservedHeapSpace& heap_space) {
}
if ((uint64_t)heap_space.end() <= OopEncodingHeapMax) {
// Did reserve heap below 32Gb. Can use base == 0;
set_base(0);
set_base(nullptr);
} else {
set_base((address)heap_space.compressed_oop_base());
}
Expand Down Expand Up @@ -115,7 +115,7 @@ CompressedOops::Mode CompressedOops::mode() {
return DisjointBaseNarrowOop;
}

if (base() != 0) {
if (base() != nullptr) {
return HeapBasedNarrowOop;
}

Expand Down Expand Up @@ -166,7 +166,7 @@ void CompressedOops::print_mode(outputStream* st) {

st->print(", Compressed Oops mode: %s", mode_to_string(mode()));

if (base() != 0) {
if (base() != nullptr) {
st->print(": " PTR_FORMAT, p2i(base()));
}

Expand Down

0 comments on commit 25e8929

Please sign in to comment.