Skip to content

Avoid closure creation in hot code #3290

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

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

nicolasstucki
Copy link
Contributor

Unfortunately the inlining solution of #3267 fails here as the closure is impure an hence evaluated before the inlined block of code.

@odersky
Copy link
Contributor

odersky commented Oct 8, 2017

In what sense is the closure impure?

@nicolasstucki
Copy link
Contributor Author

After some investigation I discovered the issue, it has nothing to do with pureness.

The problem is that DottyPredef.assert is only inlined when the code is compiled by dotty-bootstrapped (and not by dotty-nonbootstrapped). As dotty-bootstrapped is compiled with dotty-nonbootstrapped it does not get the asserts inlined. We would need a dotty-bootstrapped-bootstrapped to have this working.

I would suggest adding special casing this assert and adding the optimization by hand as it is in hot code. We should discuss what to do with the other ones later.

@smarter
Copy link
Member

smarter commented Oct 9, 2017

Or you could compile the bootstrapped compiler with the non-bootstrapped compiler as usual but with the bootstrapped library on the Scala classpath

@allanrenucci allanrenucci merged commit 6e917f7 into scala:master Oct 9, 2017
@allanrenucci allanrenucci deleted the hot-assert-closure branch December 14, 2017 19:23
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.

4 participants