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

Create function engine #1821

Closed
1 task done
emilyaherbert opened this issue Jun 2, 2022 · 1 comment
Closed
1 task done

Create function engine #1821

emilyaherbert opened this issue Jun 2, 2022 · 1 comment
Labels
big this task is hard and will take a while blocked compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: medium

Comments

@emilyaherbert
Copy link
Contributor

emilyaherbert commented Jun 2, 2022

In order to stop inlining function bodies and eliminate duplicated monomorphization during type checking, we will need to have the ability to refer to function bodies abstractly. Using a function engine during type checking would allow us to do this.

For example, given an untyped function declaration add(a: u64, b: u64) -> u64, we would create a typed function declaration and add it to the function engine. During calls to add instead of inlining the function body, we add a reference Body(add, vec!(u64, u64)), and that will serve as a pointer to the body of add. The return type for the call to add would be ReturnType(add, vec!(u64, u64)).

Given an untyped function declaration sub<T>(a: T, b: T) -> T, we would create a typed function declaration and add it to the function engine. During calls to sub(0u8, 1u8) instead of inlining the function body, we add a reference Body(sub, vec!(u8, u8)). The return type for the call to sub would be ReturnType(sub, vec!(u8, u8)). We do not perform monomorphization at this time.

After type checking has completed, before IR. An additional pass (we will expand upon the pass added here #1820) will be used to resolve all types, monomorphize functions, and resolve all function bodies. During this pass, references like Body(sub, vec!(u8, u8)) will be used to locate the definition of sub that takes types u8, u8 (or monomorphize sub and create one, if it does not already exist).

The implementation of the function engine will eventually be expanded to a declaration engine (#1692), which will be used to implement #1819.

Blocked by:

Closes:

Unblocks:

@emilyaherbert
Copy link
Contributor Author

Closing in favor of #1692

Repository owner moved this from Todo to Done in Fuel Network Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big this task is hard and will take a while blocked compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: medium
Projects
Archived in project
Development

No branches or pull requests

1 participant