deduplicating lambda methods

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Mar 21 12:48:32 UTC 2018



On 21/03/18 12:24, B. Blaser wrote:
> On 19 March 2018 at 22:31, Maurizio Cimadamore
> <maurizio.cimadamore at oracle.com> wrote:
>> [...]
>>
>> Also, a side note: we have learned during condy-folding that rewriting trees
>> is not always the right approach - if you are compiling with -g, you might
>> need the trees to remain in place (as you want the compiler to perform less
>> aggressive folding) - so I'm not sure the compiler will always be able to
>> rely on constants to be rewritten in the constant folding phase.
>>
>> Maurizio
> This makes me think we could disable dedup with '-g' to preserve full
> debug-ability (as next), is this partially what you meant?
Yes and no, but I agree that it's better to conservatively disable 
deduplication with -g.

Maurizio
>
> Bernard
>
>
> $ diff -u ./src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java.r03
> ./src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
> --- ./src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java.r03
>     2018-03-21 12:51:14.338021489 +0100
> +++ ./src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
>     2018-03-21 12:51:56.209495093 +0100
> @@ -113,6 +113,8 @@
>       /** force serializable representation, for stress testing **/
>       private final boolean forceSerializable;
>
> +    private final boolean debug;
> +
>       /** Flag for alternate metafactories indicating the lambda object
> is intended to be serializable */
>       public static final int FLAG_SERIALIZABLE = 1 << 0;
>
> @@ -149,6 +151,7 @@
>           dumpLambdaToMethodStats =
> options.isSet("debug.dumpLambdaToMethodStats");
>           attr = Attr.instance(context);
>           forceSerializable = options.isSet("forceSerializable");
> +        debug = options.isSet(Option.G) ||
> options.isSet(Option.G_CUSTOM, "source");
>       }
>       // </editor-fold>
>
> @@ -365,7 +368,7 @@
>           lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl));
>
>           boolean dedupe = false;
> -        if (!localContext.isSerializable()) {
> +        if (!localContext.isSerializable() && !debug) {
>               DedupedLambda dedupedLambda = new
> DedupedLambda(lambdaDecl.sym, lambdaDecl.body);
>               DedupedLambda existing =
> kInfo.dedupedLambdas.putIfAbsent(dedupedLambda, dedupedLambda);
>               if (existing != null) {



More information about the amber-dev mailing list