LLVM vs Dalvik (Android) note II

Dalvik is the process virtual machine in Google's Android operating system. As we all known, Andorid right now is the most popular mobile platform.

  1. Code generation , Bitcode can be translated to native code by LLVM and during the process it also can call Native lib and be excuted by cpu. But for Dalvik ByteCode, it must be excuted under Dalvik VM. Even with Dalvik JIT compiler, there is only small part of Dalvik ByteCode TraceRun module can be translated to the native assembly. It is not like the native code generated by LLVM can be excuted 100% in native environment.

  2. Reuseability , LLVM can optimize BitCode into native code entirely. Now, Dalvik ByteCode only support runtime ByteCode JIT compiler. Once Dalvik program exits, all JIT compiled results are gone. It needs the Dalvik program be reloaded and then decide which part to be translated into native code by every ByteCode Trace-Run's counter.

  3. Space , Usually, Dalvik application APK nees 2 storage space, one for DEX , one for ODEX that stays in dalvik cache. But LLVM application don't need to do that.

  4. Computing Resource , The result from LLVM compiler can be excuted in a native way but Dalvik JIT needs Trace-Run Counter to decide recompiling. So from cpu runtim overhead, LLVM is more efficient.

  5. Security, LLVM suport inline assembly which is not allowed in Java world. This makes LLVM efficient but also some security problem around this.

Dalvik Compiling


LLVM Compiling