deduplicating lambda methods
B. Blaser
bsrbnd at gmail.com
Thu Mar 29 10:32:16 UTC 2018
On 28 March 2018 at 23:51, B. Blaser <bsrbnd at gmail.com> wrote:
> On 28 March 2018 at 20:09, Maurizio Cimadamore
> <maurizio.cimadamore at oracle.com> wrote:
>>
>> To me this seems to suggest that, if we want to get better results out of
>> the dedup machinery, we have to up our lowering game, so that we don't do
>> excessive generation of fresh symbols. Right now we don't cache .class
>> symbols and also metafactory calls with same static args and BSM - and
>> that's the problem you are seeing, I believe.
>
> You're right. The fix below tries to cache meta-factory calls, solving
> the following de-duplication problem:
> r1 = () -> {
> Runnable r2 = () -> {};
> };
Running javac tests, I note that the cache key isn't precise enough.
Any idea of what a good key would be?
Bernard
> Bernard
>
> diff -r 9925be430918
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
> Wed Mar 28 14:24:17 2018 +0100
> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
> Wed Mar 28 23:24:59 2018 +0200
> @@ -226,6 +226,8 @@
>
> private Map<DedupedLambda, DedupedLambda> dedupedLambdas;
>
> + private Map<Name, DynamicMethodSymbol> dynMethSyms = new HashMap<>();
> +
> /**
> * list of deserialization cases
> */
> @@ -1220,7 +1222,8 @@
> staticArgs.toArray());
>
> JCFieldAccess qualifier =
> make.Select(make.QualIdent(site.tsym), bsmName);
> - qualifier.sym = dynSym;
> + DynamicMethodSymbol existing =
> kInfo.dynMethSyms.putIfAbsent(methName, dynSym);
> + qualifier.sym = existing != null ? existing : dynSym;
> qualifier.type = indyType.getReturnType();
>
> JCMethodInvocation proxyCall = make.Apply(List.nil(),
> qualifier, indyArgs);
>
>> Maurizio
>>
>>>
>>> Bernard
>>>
>>>> Maurizio
More information about the amber-dev
mailing list