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

Make lazy vals and object native image friendly #14780

Merged
merged 2 commits into from
May 16, 2022

Conversation

romanowski
Copy link
Contributor

@romanowski romanowski commented Mar 25, 2022

Currently, creating a graal native image from scala 3 code is really cubersome, custom configuration needs to be provided for each object and lazy val. It is caused by reflection in LazyVals object.

This PR inlines reflection within each class and in this form Graal is able to inline such calls without any additional config.

Before each PR for each lazy val (object are also implemented as lazy vals) similar code is added to the static initializer for the class:

<0bitmap$1> = scala.runtime.LazyVals.getOffset (getClass, "<0bitmap$1>")

This PR changes it into:

<0bitmap$1> = scala.runtime.LazyVals.getOffsetStatic (getClass.getDeclaredFiels( "<0bitmap$1>"))

@smarter smarter added the needs-minor-release This PR cannot be merged until the next minor release label Mar 25, 2022
@smarter smarter added this to the 3.2.0-RC1 milestone Mar 25, 2022
@Kordyjan Kordyjan self-assigned this Mar 28, 2022
@Kordyjan Kordyjan self-requested a review March 28, 2022 09:35
@anatoliykmetyuk
Copy link
Contributor

anatoliykmetyuk commented Apr 4, 2022

We need to coordinate with #14545 since they might conflict. We need to merge them sequentially, then rebase the second one to be merged to see what breaks. Also if this one is merged second, we'll have to re-test it manually.

Also maybe we can look at bytecode tests to see if we can use them to test this PR.

romanowski and others added 2 commits May 12, 2022 12:14
Currently, creating a graal native image from scala 3 code is really cubersome, custom configuration needs to be provided for each object and lazy val. It is caused by reflection in LazyVals object.

This PR inlines reflection within each class and in this form Graal is able to inline such calls without any additional config.
@szymon-rd szymon-rd marked this pull request as ready for review May 12, 2022 14:41
@Kordyjan Kordyjan merged commit 31be2b0 into scala:main May 16, 2022
szymon-rd added a commit that referenced this pull request Oct 28, 2022
Cleaned up version of #14545

Implementing the new lazy vals scheme mentioned in
#6979, fixing
#7140

New PR to avoid force pushing to main branch of the previous author.

Fixes #15149 as well
Applied #14780
@Kordyjan Kordyjan modified the milestones: 3.2.0-RC1, 3.2.0 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This PR cannot be merged until the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants