The patch seems suitably minimal to me to meet the goals and not cause difficulty for future evolution of LMF (for which we have some plans, once some other VM work finishes up.)   Essentially, the disable-eager-initialization case disables the caching optimization for non-capturing lambdas, and we then just revert to the main lambda-capture path, which makes this fairly low risk.


On 10/28/2019 2:10 PM, Vojin Jovanovic wrote:
Hi all,

This email proposes a change to the LambdaMetaFactory that allows to disable 
eager initialization (with Unsafe) of generated lambdas. This is needed by the 
GraalVM Native Image, as initialization of lambdas during AOT compilation 
breaks our heap snapshotting (via initialization of interfaces with default 
methods that are super-types of a lambda). We have started from the original 
proposal that stores lambda instances in the static fields

   
https://github.com/graalvm/labs-openjdk-11/commit/00b9ecd85dedd0411837eee33635dd83e8b7def8

and initializes them with Unsafe as an optimization

    
https://github.com/graalvm/labs-openjdk-11/commit/273e8590a7b57c0c10d9213ca9e0ba581e2817b8

After the discussion with Brian Goetz, we have trimmed down to the following 
change:

   
https://bugs.openjdk.java.net/secure/attachment/85247/lambda-disable-initialization.diff

The evolution of this change can be found at the issue:

  https://bugs.openjdk.java.net/browse/JDK-8232806
Cheers,
- Vojin

Reply via email to