Groovy has a performance problem, compared with Java, due to its dynamic nature, while there are several requests for performance improvement.
Implementing just-in-time compiler is a proper way to help boosting performance of Groovy. It would be great to have a Groovy module (in this case a JVMTI agent) to help transform/redefine Groovy classes during runtime.
As of Groovy 1.6-beta series, its performance has been improved but there are still problems occurred from primitive operations. All operand and results are heavily boxed and unboxed when primitive variables are used. The current implementation of GJIT provides the algorithm to unwrap almost binary operations back to be primitive. Thus, it can speed Groovy performance up when dealing with arithmetic calculation.
This is the completely re-written version of GJIT. Basically, GJIT can be thought as a Hotspot-like compiler for Groovy. However it is working outside JVM, and not a part of the virtual machine. GJIT uses JVMTI, the virtual machine tool interface, to:
- Transform a class when it is being loaded, based on the assumption that the default metaclass provides the default behaviour.
- Redefine the class with the original one, when the metaclass of this class is modified.
Due to the use of JVMTI, GJIT supports Java 5 or later.
to your Java command line to use GJIT.
Missing Features and Known Bugs
- Primitive casts have not been processed properly.
- Class redefinition is not built in yet, it needs to tweak MetaClassImpl.