Skip to content
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

Reconsider when we are tagging and untagging values in low level code generation. #2176

Open
spotandjake opened this issue Oct 12, 2024 · 0 comments

Comments

@spotandjake
Copy link
Member

While working on #2173 I noticed that we tag a lot of our internal values while working with compcore, some instances of this are:

  • We tag the variant_id and other information on adt items
  • Comp.if_ consumes a grain bool as the argument meaning any internally generated if statements use grain bools

This really has no benefit in the case of the in memory items most of the time we are only thouching them in the runtime where we just untag them anyways and if we needed to provide it to a user we could tag it then, and in the case of code generation like if statements this means everytime we generate an if statement we need to include the logic for untagging which increases bundle size. It seems like it would be a better idea to insert an untagging operation around the if_ statement in the Anf tree phase depending on the circumstances, this would allow us to generate internal if statements such as those used in pattern matching without incurring tagging and untagging overhead.

Note: There are a lot of cases when binaryen can optimize these tagging operations away but when the values we are comparing come from memory it seems as though binaryen is not as good at optimizing out these tagging operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant