Skip to content

Conversation

kripken
Copy link
Member

@kripken kripken commented Sep 26, 2025

We can write a null (it would trap, but it looks like a write in the opt), but
cannot read a null, so we must cast.

@kripken kripken requested a review from tlively September 26, 2025 21:21
;; function result is non-nullable.
(ref.get_desc $A
(struct.new_default $A
(ref.null none)
Copy link
Member

Choose a reason for hiding this comment

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

We could do even better in this case by ignoring null writes to the descriptor in the first place. Then if there is another location that writes a real value, we can still optimize all the reads to return the real value.

However, we'll still need the current code to fix up the case where the single written value is a nullable global, but the output of the ref.get_cast is required to be non-null.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, I added a TODO

@kripken kripken merged commit 3ae83ab into WebAssembly:main Sep 26, 2025
16 checks passed
@kripken kripken deleted the cfp.nn branch September 26, 2025 22:48
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.

2 participants