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

Optimize Core #267

Merged
merged 8 commits into from
May 14, 2023
Merged

Optimize Core #267

merged 8 commits into from
May 14, 2023

Conversation

b-studios
Copy link
Collaborator

This PR builds on the work by @fritzladwig and supersedes #206.

It performs (in this order)

  1. Deadcode elimination
  2. Inlines uniquely used blocks (functions and objects).
  3. Normalizes a bit (return(run(e)) = e, and so on)

It does not implement a static argument transformation. We need to reimplement that later at some point. Ideally on a CPS representation. We should also look into the standard shrinking techniques (https://www.cs.princeton.edu/~appel/papers/shrink.pdf) at that point.

It turned out that the simplifications were "too good" and loops became fully direct style (test: raytracer.effekt). In order to work around this issue in the JS backend, I introduced a new microphase that patches up recursive (non-guarded) function calls by thunking them under a trivial val _ = return (); recursive(). In the JS implementation this will cause a frame to be pushed on the monadic trampoline, which effectively makes recursive calls stack safe.

@b-studios
Copy link
Collaborator Author

Thanks @fritzladwig for your work again! It might look like I re-implemented everything, but that was much easier after you having implemented it already once.

@b-studios b-studios mentioned this pull request May 14, 2023
@b-studios b-studios merged commit 8e7acfa into master May 14, 2023
2 checks passed
@b-studios b-studios deleted the feature/optimize-core branch May 14, 2023 13:59
@b-studios
Copy link
Collaborator Author

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

PR Analysis

  • 🎯 Main theme: Optimizing the Core of the Effekt language
  • 📌 Type of PR: Enhancement
  • Focused PR: True
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • General suggestions: The PR is well-structured and the changes are focused on optimizing the core of the Effekt language. However, it would be beneficial to add tests to ensure that the optimizations do not introduce any regressions.

  • 🤖 Code feedback:

How to use

Tag me in a comment '@CodiumAI-Agent' and add one of the following commands:
/review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option.
/describe: Modify the PR title and description based on the contents of the PR.
/improve: Suggest improvements to the code in the PR.
/ask <QUESTION>: Pose a question about the PR.

To edit any configuration parameter from 'configuration.toml', add --config_path=new_value
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, use the /config command.

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

Successfully merging this pull request may close these issues.

None yet

2 participants