Methods and systems for platform-independent selective ahead-of-time
compilation are herein described. A method selector comprising a
profiling tool and heuristic selects a subset of methods for
ahead-of-time compilation. The profiling tool ranks a set of methods
according to predetermined criteria, and the heuristic identifies the
subset of methods from the set of methods. An ahead-of-time compiler
comprises a first unit and a second unit. The first unit converts, for
each selected method, bytecodes corresponding to the selected method to a
platform-independent intermediate representation. The second unit
optimizes the platform-independent intermediate representation of each
selected method, wherein each optimized intermediate representation is
stored with a corresponding selected method. A virtual machine on a
device converts an optimized intermediate representation associated with
a selected method loaded onto the device to platform-dependent machine
code.