groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesper Steen Møller <>
Subject Re: About the native-lambda branch
Date Mon, 15 Jan 2018 10:10:11 GMT
Hi Daniel

> On 15 Jan 2018, at 10.53, Daniel Sun <> wrote:
> Hi Jochen,
>     `ArrayIndexOutOfBoundsException` is fixed. I encounter another
> problem(i.e. How to load arguments according to some specified order): I
> want to load local variables[1] according to the order in which the local
> variables appear in lambda body.

Don't do that :-)

Instead, you need to determine which method arguments and locals variables are needed by the
lambda, and simply push all those in the declaration order. If they occur multiple times,
you will need to filter anyway.

That's much easier than making the order dependent on the usage.

Also, you should really try to make some lower level tests, which tests the escape analysis
directly, since you have so many different cases to look out for:
 - lambda use 'this' (explicitly or implicitly - controls whether the lambda implementation
function should be static or not, and whether the this reference should be passed to the lambda)
 - lambda captures the enclosing method's parameters (passed as straight value if (effectively)
final, or as a Reference if it changes)
 - lambda captures the enclosing method's local variables (ditto)
In case of lambdas nested in lambdas: Now you will have to address deal with inner lambdas
capturing outer lambda's parameters and/or locals)

Shuffling/optimizing the order of the captured values is not worth it -- the JIT compiler
will deal with it anyway.

Good luck!


View raw message