Does LLVM have java frontend?

Hi,

Does LLVM have java frontend which can change Java bytecode to LLVM IR?

Thanks a lot!

Best,

Linhai

There was such a front end as an option (called “portable mode”) in the ART compiler for Android, but it’s no longer used, I believe mostly because it was thought to be too slow to use on-device during app install or OS upgrade. Of course it’s from Dalvik bytecodes not JDK ones.

It’s also worth noting that a Java front end is largely useless in isolation. AoT-compiled Java will depend on a load of run-time infrastructure (for GC, cast-to-interface, down-cast, reflection, and so on). In interpreted or JIT’d Java implementations, these are all highly specific to the JVM implementation (things like the layouts of classes are a bit more portable, but object layouts are very variable. For example, a lot of JVMs - but not all - put non-pointer fields before the class pointer so that the GC won’t pull them into the cache).

You can have a Java bytecode to VMKit compiler, or a Java bytecode to OpenJDK compiler, but a stand-alone Java compiler in isolation is a largely meaningless concept.

David

It’s also worth noting that a Java front end is largely useless in isolation. AoT-compiled Java will depend on a load of run-time infrastructure (for GC, cast-to-interface, down-cast, reflection, and so on). In interpreted or JIT’d Java implementations, these are all highly specific to the JVM implementation (things like the layouts of classes are a bit more portable, but object layouts are very variable. For example, a lot of JVMs - but not all - put non-pointer fields before the class pointer so that the GC won’t pull them into the cache).

You can have a Java bytecode to VMKit compiler, or a Java bytecode to OpenJDK compiler, but a stand-alone Java compiler in isolation is a largely meaningless concept.

David