Author: Norris Boyd

# Optimization

## Optimization settings

The currently supported optimization settings are:

-1

Interpretive mode is always used. The compilation time is minimized at the expense of runtime performance. No class files are generated, which may improve memory usage depending on your system.

If the optimization package is not available, then optimization acts as if it is always -1.

0

No optimizations are performed. The bytecode compiler runs fastest in this mode, but the generated byte code is less efficient.

1-9

All optimizations are performed. Simple data & type flow analysis is performed to determine which JavaScript variables can be allocated to Java VM registers, and which variables are used only as Numbers. Local common sub-expressions are collapsed (currently this only happens for property lookup, but in the future more expressions may be optimized). All local variables and parameters are allocated to Java VM registers. Function call targets are speculatively pre-cached (based on the name used in the source) so that dispatching can be direct, pending runtime confirmation of the actual target. Arguments are passed as Object/Number pairs to reduce conversion overhead.

Note:

1. Some language features (indirect calls to eval, use of the arguments property of function objects) were previously not supported in higher optimization levels. These features have been removed from the language in ECMA, so higher optimization levels are now conformant.
2. Future versions may allocate more aggressive optimizations to higher optimization levels. For compatibility with future versions, use level 1. For maximal optimization, use level 9, but retest your application when upgrading to new versions.

back to top