On 11.10.2016 06:14, 孙 岚 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

Reply via email to