[ACCEPTED]-What are the differences between LLVM and java bytecode?-llvm
Assuming you mean JVM rather than Java:
The 14 LLVM is a low level register-based virtual machine. It 13 is designed to abstract the underlying hardware 12 and draw a clean line between a compiler 11 back-end (machine code generation) and front-end 10 (parsing, etc.).
The JVM is a much higher 9 level stack-based virtual machine. The JVM 8 provides garbage collection, has the notion 7 of objects and virtual method calls and 6 more. Thus, the JVM provides much higher 5 level infrastructure for language interoperability 4 (much like Microsoft's CLR).
(It is possible 3 to build these abstractions over LLVM just 2 as it is possible to build them on top of 1 C.)
It's too bad this question got off on the 16 wrong foot. I came to it looking for a more 15 detailed comparison.
The biggest difference 14 between JVM bytecode and and LLVM bitcode 13 is that JVM instructions are stack-oriented, whereas 12 LLVM bitcode is not. This means that rather 11 than loading values into registers, JVM 10 bytecode loads values onto a stack and computes 9 values from there. I believe that an advantage 8 of this is that the compiler doesn't have 7 to allocate registers, but I'm not sure.
LLVM 6 bitcode is closer to machine-level code, but 5 isn't bound by a particular architecture. For 4 instance, I think that LLVM bitcode can 3 make use of an arbitrary number of logical 2 registers. Maybe someone more familiar 1 with LLVM can speak up here?
JVM bytecodes and LLVM bytecodes have similarities 32 and differences. In terms of similarities, these 31 are two intermediate program representations. Thus, they 30 can represent programs written in different 29 programming languages. As an example, there 28 are frontends that translate Java, Closure, Scala, etc 27 into JVM bytecodes, and there are frontends 26 that translate C, C++, Swift, Julia, Rust, etc 25 into LLVM bytecodes.
This said, JVM bytecodes 24 and LLVM bytecodes are very different in 23 purpose and in design. Historically, JVM 22 bytecodes have been designed to be distributed 21 over a network, e.g., the Internet, and 20 interpreted in the local computer, via a 19 virtual machine. That's one of the reasons 18 why it's stack based: usually, stack-based 17 bytecodes are smaller.
Perhaps, in its beginnings, the 16 LLVM bytecodes have also been thought to 15 be interpreted, but if it happened, its 14 purpose has changed over time. So, LLVM 13 bytecodes are a program representation meant 12 to be analyzed and optimized. It is encoded 11 in the Static Single Assignment format, which 10 is more like a mathematical abstraction 9 of a program than an actual, executable, assembly. So, there 8 are instructions like phi-functions in the 7 LLVM IR that do not have a direct equivalent 6 in typical computer architectures, for instance. Thus, although 5 it is possible to interpret LLVM bytecodes 4 (there is a tool called lli that's part 3 of the LLVM toolchain, that does that), that's 2 not the most important way in which the 1 LLVM IR is used.
More Related questions