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

Improve monomorphization cache design for full optimality #2723

Closed
tritao opened this issue Sep 5, 2022 · 1 comment
Closed

Improve monomorphization cache design for full optimality #2723

tritao opened this issue Sep 5, 2022 · 1 comment
Assignees
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen

Comments

@tritao
Copy link
Contributor

tritao commented Sep 5, 2022

Attaching some context from @emilyaherbert how we we can do this:

In general, most generic functions are called without type arguments, so most of the time this check will fail, missing valid cache opportunities.

Right now when type checking a function application, the compiler:

  • retrieves the function
  • monomorphizes it
  • creates an error if an incorrect number of arguments are provided and early exists
  • type checks the arguments to the function, find the types of the arguments, and simultaneously unifies the types of the arguments with the expected types of the function parameters

Considering that most generic functions are called (and monomorphized) without type arguments, a good high-level design for using the cache might look like:

  • type check the arguments to the function, collect the types of the arguments
  • retrieve the function
  • potentially monomorphize, depending on the type of the arguments and the type arguments themselves
  • create an error if an incorrect number of arguments are provided and early exist
  • unify the types of the arguments with the types of the function parameters

This would allow us to use the types of the arguments in monormorphization

@tritao tritao added the compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen label Sep 5, 2022
@tritao tritao self-assigned this Sep 5, 2022
@emilyaherbert
Copy link
Contributor

Closing in favor of grouping this issue with #2636.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
None yet
Development

No branches or pull requests

2 participants