You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by 孙 岚 <re...@hotmail.com> on 2016/10/11 04:14:11 UTC

About the compiler optimization of Groovy

Hi dev list,

      Are there any compiler optimizations in Groovy? e.g. Tail Recursion, Loop Unrolling, etc.

      If no compiler optimizations done, how about providing some AST Transformation or even adding a compilation phase named optimization? The optimization phase does nothing for now, but we can implement some plugin mechanism to load optimization plugin dynamically.

       Any thoughts?

Cheers,
Daniel.Sun


Re: About the compiler optimization of Groovy

Posted by daniel_sun <re...@hotmail.com>.
Hi Jochen,

> Tail recursion: see TailRecursive. But I don't see this as an optimization 
Yeah, that is what I want :)

> instead of first creating a GString and then cast it to String, we could
> instead produce the String right away
We could try to optimize it in the later release.

> As for a plugin mechanism... not global transforms? 
They should be a global transforms, which have switch to control turning on
or turning off.

Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/About-the-compiler-optimization-of-Groovy-tp5736034p5736071.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: About the compiler optimization of Groovy

Posted by Jochen Theodorou <bl...@gmx.org>.

On 11.10.2016 06:14, \u5b59 \u5c9a wrote:
> Hi dev list,
>
>       Are there any compiler optimizations in Groovy? e.g. Tail
> Recursion, Loop Unrolling, etc.
>
>       If no compiler optimizations done, how about providing some AST
> Transformation or even adding a compilation phase named optimization?
> The optimization phase does nothing for now, but we can implement some
> plugin mechanism to load optimization plugin dynamically.

Tail recursion: see TailRecursive. But I don't see this as an optimization

As for loop unrolling and such... since we have a JIT, I would not do 
the classic optimizations like loop unrolling. You could say that all 
the static compiler does are optimizations to some extend. But in 
general we would have to discuss each and every optimization if it makes 
a difference or if their nature is having bad side effects.

One optimization I could think of is for example:

String s = "sad$sdq"

instead of first creating a GString and then cast it to String, we could 
instead produce the String right away. A variation would for example be 
a method returning String but you use a GString to produce the string. 
And with a little bit of flow analysis we could even optimize

def s = "sad$sdq"

in some cases. A new phase would probably be a breaking change, so I 
don't know about that. As for a plugin mechanism... not global transforms?

bye Jochen