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

Function inlining in closLang #338

Open
myreen opened this issue Oct 10, 2017 · 1 comment
Open

Function inlining in closLang #338

myreen opened this issue Oct 10, 2017 · 1 comment
Assignees

Comments

@myreen
Copy link
Contributor

myreen commented Oct 10, 2017

Currently, all function inlining happens in BVL. However, there are certain functions that would need to be inlined before closures are compiled. In particular functions that take functions as arguments, such as opt_map below.

fun opt_map f opt = 
  case opt of 
    NONE => NONE
  | SOME x => SOME (f x);

Example: for the call to foo in opt_map foo x to be optimised, the definition of opt_map needs to be expanded.

I suggest this optimisation is implemented by reusing clos_number and clos_known. These should be run first, then any small function should have its definition inserted into the known-annotated application. A few minor passes might then be needed in the same way as bvl_inline currently combines several passes to clean up the raw inline result.

Note that inlining destroys one of the important properties of clos_number (namely that every closure creation has a unique number), so clos_number and clos_known would need to be run again to reset the numbering and redo the known annotations.

If this optimisation is done well, then it might make bvl_inline obsolete.

@myreen myreen assigned myreen and unassigned myreen Oct 10, 2017
@myreen
Copy link
Contributor Author

myreen commented Oct 16, 2017

We can probably avoid rerunning clos_number and clos_known if we are happy to use a slightly weaker property: closures are allowed to have the same closure number if their bodies are identical. It would be neat if we could avoid rerunning the clos_number and clos_known passes after inlining.

@myreen myreen assigned hrutvik and abxy and unassigned hrutvik Oct 17, 2017
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

3 participants