Skip to content

[NFC] Rename Type::isNull to Type::isBottomRef - #9288

Merged
tlively merged 4 commits into
mainfrom
is-bottom-ref-nfc
Oct 21, 2026
Merged

tlively merged 4 commits into
mainfrom
is-bottom-ref-nfc

Conversation

@tlively

@tlively tlively commented Oct 20, 2026

Copy link
Copy Markdown
Member

Rename Type::isNull to Type::isBottomRef to make it clear that it checks for any reference to a bottom heap type (including uninhabited non-nullable ones) and already checks that the type is a reference, and clean up redundant checks at call sites.

Rename Type::isNullable and Type::isNonNullable to Type::isNullableRef and Type::isNonNullableRef to make it clear that they already check that the type is a reference, and remove redundant isRef() checks at call sites.
Rename Type::isNull to Type::isBottomRef to make it clear that it checks for any reference to a bottom heap type (including uninhabited non-nullable ones) and already checks that the type is a reference, and clean up redundant checks at call sites.
@tlively
tlively requested a review from a team as a code owner October 20, 2026 20:24
@tlively
tlively requested review from kripken and stevenfontanella and removed request for a team October 20, 2026 20:24

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request renames the isNull() method on Type to isBottomRef() and updates its usages across the codebase to clarify that it checks for a bottom reference type. The review feedback suggests improving code readability and reducing redundancy in DeadArgumentElimination.cpp and heap-types.cpp by using the existing GCTypeUtils::isUninhabitable helper function instead of manual checks.

Comment thread src/passes/DeadArgumentElimination.cpp Outdated
Comment on lines +553 to +554
bool wasReturnUninhabitable =
func->getResults().isNull() && func->getResults().isNonNullableRef();
func->getResults().isBottomRef() && func->getResults().isNonNullableRef();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

We can simplify this check by using the existing helper function GCTypeUtils::isUninhabitable from ir/gc-type-utils.h (you may need to include ir/gc-type-utils.h if it is not already included). This improves readability and reduces redundancy.

Suggested change
bool wasReturnUninhabitable =
func->getResults().isNull() && func->getResults().isNonNullableRef();
func->getResults().isBottomRef() && func->getResults().isNonNullableRef();
bool wasReturnUninhabitable =
GCTypeUtils::isUninhabitable(func->getResults());

for (size_t i = 0; i < children.size(); ++i) {
auto child = children[i];
if (child.isNonNullableRef() && child.getHeapType().isBottom()) {
if (child.isNonNullableRef() && child.isBottomRef()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

We can simplify this check by using the helper function GCTypeUtils::isUninhabitable(child) here as well, which makes the code more expressive.

Suggested change
if (child.isNonNullableRef() && child.isBottomRef()) {
if (GCTypeUtils::isUninhabitable(child)) {

@kripken

kripken commented Oct 20, 2026

Copy link
Copy Markdown
Member

...I kind of feel the same about this as the other case? "is null" obviously includes "is a reference" because that is what a null is.

I think shorter names are generally better. They are easier to read, save time, and more pleasant.

@tlively

tlively commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

The important change here isn't the addition of Ref but rather the change from Null to Bottom. The old name isNull does not clearly communicate that it will return true for a non-nullable bottom reference.

Base automatically changed from is-nullable-ref-nfc to main October 20, 2026 21:51
# Conflicts:
#	src/ir/gc-type-utils.h
#	src/passes/DeadArgumentElimination.cpp
#	src/passes/OptimizeInstructions.cpp
#	src/tools/fuzzing/heap-types.cpp
#	src/wasm/literal.cpp
@kripken

kripken commented Oct 21, 2026

Copy link
Copy Markdown
Member

Well, again I don't quite see things the same (it is a null type, just non-nullable; yes that is weird) but I won't object strongly.

@tlively
tlively merged commit 0d52844 into main Oct 21, 2026
16 checks passed
@tlively
tlively deleted the is-bottom-ref-nfc branch October 21, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants