Android 7.0 adds a just-in-time (JIT) compiler with code profiling to Android runtime (ART) that constantly improves the performance of Android apps as they run. The JIT compiler complements ART's current ahead-of-time (AOT) compiler and improves runtime performance, saves storage space, and speeds app updates and system updates.
The JIT compiler also improves upon the AOT compiler by avoiding system slowdown during automatic application updates or recompilation of applications during OTAs. This feature should require minimal device integration on the part of manufacturers.
JIT and AOT use the same compiler with an almost identical set of optimizations. The generated code might not be the same but it depends. JIT makes uses of runtime type information and can do better inlining. Also, with JIT we sometimes do OSR compilation (on stack replacement) which will again generate a bit different code.
Figure 1. JIT architecture - how it works
JIT compilation works in this manner:
Figure 2. Profile-guided compilation
Figure 3. How the daemon works
The Google Play service is an example used by other apps. These application tend to behave more like shared libraries.
See the following high-level overview of how JIT works in the next diagram.
Figure 4. JIT data flow
This means:
adb root
adb shell stop
adb shell setprop dalvik.vm.extra-opts -verbose:jit
adb shell start
adb root
adb shell stop
adb shell setprop dalvik.vm.usejit false
adb shell start
Check $ adb shell cmd package compile
for usage. A few common use cases:
adb shell cmd package compile -m speed-profile -f my-package
adb shell cmd package compile -m speed -f my-package
adb shell cmd package compile -m speed-profile -f -a
adb shell cmd package compile -m speed -f -a
adb shell cmd package compile --reset my-package
adb shell cmd package compile --reset -a