Skip to content

Use more precise types in function environments #2041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2025
Merged

Conversation

vouillon
Copy link
Member

@vouillon vouillon commented Jun 12, 2025

This refines the type of locals based on the expression they are initialized with. The main motivation for this is that the environment types get refined as well, which binaryen is not able to do. In turn, some casts become unnecessary. On ocamlc.byte, we get the following number of casts:

Before After
37949 35553

@vouillon vouillon added the wasm label Jun 12, 2025
@hhugo
Copy link
Member

hhugo commented Jun 12, 2025

Do you plan to remove unnecessary cast ?

@vouillon vouillon changed the title Refine the type of locals based on the expression they are initialized with Use more precise types in function environments Jun 12, 2025
@vouillon
Copy link
Member Author

Do you plan to remove unnecessary cast ?

Binaryen takes care of this.

We change the type of the local into a nullable type if we cannot use a
placeholder value
As a byproduct, the environment types get refined as well.
@vouillon vouillon merged commit 0ea2d6f into master Jun 13, 2025
26 checks passed
@vouillon vouillon deleted the local-types branch June 13, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants