deduplicating lambda methods

John Rose john.r.rose at oracle.com
Sat Mar 3 02:12:48 UTC 2018


On Mar 2, 2018, at 5:57 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> e -> k and k::m (for constants k)

Do'oh.  I meant to say "captured variables k".  They are
only constants in the sense of being final.  But *not*
compile time constants.

Brian's condy stuff handles true compile-time constants
like Integer.MAX_VALUE.  And it might use the same
off-the-shelf shared desugar methods I mentioned
before.

I suppose I should give examples of what cross-CU
method sharing.  Suppose the source file contains
a stereotyped lambda; pick a constant-returning one.
We can lower it several ways to either a method
reference, or a partial application (curry) of a method
reference:

() -> 42

LOWER==>

Foo::lamb$42
where
  private static int lamb$42() { return 42; } // in local CU

OR==>

curry LMF::intConstant on (42)

public static int intConstant(int x) { return x; } // in LMF

OR==>

curry Integer::intValue on (42)  // use a found method

OR==>

something outside the LMF,
  with MethodHandles.constant() and invokeExact

Perhaps the LMF can be used directly to do the
above curries.

— John


More information about the amber-dev mailing list