Skip Headers
Oracle® Java Micro Edition Embedded Client Customization Guide
Release 1.1
  Go To Table Of Contents


6 Ahead-of-Time Compilation

This chapter describes how to reduce device startup time with ahead-of-time compilation (AOT, also called precompilation). In some cases, precompiling can also improve system responsiveness by preventing dynamic compilation of methods you have compiled ahead of time. Precompilation is an optimization technique to use after application development is complete.

This chapter includes these topics:


AOT compilation is not available for x86-based platforms.

How Ahead-of-Time Compilation Works

When the virtual machine starts, it loads the precompiled methods specified in a file named in a command line option. To the degree that these methods are called during system startup, startup time can be reduced by not interpreting, and, in some cases, not dynamically compiling, the methods. To the degree that the precompiled methods are not called during startup, startup time is increased by the time spent loading precompiled methods that are not used. Determining the Methods to Precompile describes how to determine which methods are called during startup.

There is no separate precompiler tool. Invoking cvm with these -Xjit: suboptions triggers precompilation:

If you change the method list, invoke cvm with -Xjit:recompileAOT=true to rebuild the precompiled method file.

To direct the virtual machine to load the precompiled methods in the default lib/cvm.aot, invoke cvm without -Xjit:aotxxx suboptions. To direct the virtual machine to read compiled methods from a different location, use aotFile=file.

To run without precompiled methods, invoke cvm with -Xjit:aot=false.

Determining the Methods to Precompile

To determine a set of methods that yields the best performance when precompiled, experiment with different combinations and measure their effect on performance. You can combine entries from multiple runs to optimize for multiple applications.

To create a list of candidate methods, run your application with -Xjit:generateAOTList=compiledMethodsFile. When the run completes, compiledMethodsFile contains a list of the methods that were compiled in the run, in other words, hot methods. The methods are listed in the order they were compiled. compiledMethodsFile is in method list format, so you can specify it as the argument to -Xjit:aotMethodList. However, you should first edit the file, commenting out methods that you do not want precompiled. The generated compiledMethodsFile is a template and a starting point. Experiment to create the final method list file.