lambda support for Graal

Christian Thalinger christian.thalinger at oracle.com
Thu Apr 4 15:11:28 PDT 2013


On Apr 4, 2013, at 11:33 AM, "Frost, Gary" <Gary.Frost at amd.com> wrote:

> Christian
> 
> When you say 'so the methods are inlined' below,  do you mean the lambda$$XX(args) method getting inlined at the call site?

Well, Andreas said that ;-)

> 
> If so, for our Sumatra/Graal experiments we would prefer if these were not inlined ;) 
> 
> At present our experiments are dependent on  intercepting the call site  and dispatching to the GPU.  If this were heavily inlined we would need a way to detect it and un-inline (outline? ;))

If the invokedynamic support is in Graal then invokedynamic call sites will be inlined.  I'm not a Lambda expert but I thought invokedynamic is only used to set up the lambda and not actually call it (someone will correct me).

How are you handling the invokedynamic instruction right now?

-- Chris

> 
> So given
> class MyClass{
>   void m(){ 
>      T capture;
>      XXXX.parallel().forEach(arg1, arg2 -> { /* uses capture */});
>   }
> }
> 
> Javac creates a synthetic method added at the call site
> 
> class MyClass{
>    void m(){ 
>      T capture;
>      XXXX.parallel().forEach(arg1, arg2 -> { /* uses capture */});
>   }
>   private synthetic lambda$$<n>(capture, arg1, arg2){
>         /* lambda code using  capture */
>   } 
> }
> 
> And some 'magic' Bootstrapclass/method handle stuff to create an object which allows us to combine the reference to this new method as well as the args and the captured values from the call to the implementation of forEach(...)
> 
> Is your intent to try to inline the actual lambda$$<n> method above?  
> 
> Certainly for Sumatra we would like to opt-out of the inlining of the lambda$$<n>() at this stage.
> 
> Gary 
> 
> -----Original Message-----
> From: graal-dev-bounces at openjdk.java.net [mailto:graal-dev-bounces at openjdk.java.net] On Behalf Of Christian Thalinger
> Sent: Thursday, April 04, 2013 1:09 PM
> To: Andreas Woess
> Cc: graal-dev at openjdk.java.net
> Subject: Re: lambda support for Graal
> 
> 
> On Apr 3, 2013, at 6:52 PM, Andreas Woess <awx at gmx.at> wrote:
> 
>> Not much really. I've done some experimental hacking on that a while 
>> ago (and can provide you with a patch as a starting point). The main 
>> task is probably implementing the MH intrinsics in Graal, so that the 
>> methods are inlined.
> 
> Please.  A patch would be great.
> 
> -- Chris
> 
>> 
>> - andreas
>> 
>> On 2013-04-04 02:00, Christian Thalinger wrote:
>>> On Apr 3, 2013, at 1:42 PM, Doug Simon @ Oracle <doug.simon at oracle.com> wrote:
>>> 
>>>> On Apr 3, 2013, at 10:15 PM, "Venkatachalam, Vasanth" <Vasanth.Venkatachalam at amd.com> wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> Can someone explain what the plans for adding support to compile JDK8 lambda expressions?
>>>> We have no current plans for adding this support. As far as I am aware, we have not yet looked into what compiler support is needed for lambda expressions. Is it only a matter of supporting invokedynamic and MethodHandles?
>>> I'm going to work on this.  Next week I have a call with Thomas to figure out what is required.
>>> 
>>> -- Chris
>>> 
>>>>> We'll need this functionality soon for the work we're doing, namely generating HSAIL for parallelizable Java code marked with lambdas.
>>>> How does this marking show up in the class file/bytecode? It may be possible to do some kind of pattern matching.
>>>> 
>>>> -Doug
>> 
> 
> 
> 



More information about the graal-dev mailing list