LLVM 和 java 字节码有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/454720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the differences between LLVM and java bytecode?
提问by
I dont understand the difference between LLVM and the java (bytecode), what are they?
我不明白 LLVM 和 java(字节码)之间的区别,它们是什么?
-edit- by 'what are they' i mean the differences between LLVM and java (bytecode) not what are LLVM and java.
-编辑-“它们是什么”我指的是 LLVM 和 java(字节码)之间的区别,而不是 LLVM 和 java。
回答by nimrodm
Assuming you mean JVM rather than Java:
假设您指的是 JVM 而不是 Java:
The LLVM is a low levelregister-based virtual machine. It is designed to abstract the underlying hardware and draw a clean line between a compiler back-end (machine code generation) and front-end (parsing, etc.).
LLVM 是一个低级的基于寄存器的虚拟机。它旨在抽象底层硬件并在编译器后端(机器代码生成)和前端(解析等)之间划清界限。
The JVM is a much higher level stack-based virtual machine. The JVM provides garbage collection, has the notion of objects and virtual method calls and more. Thus, the JVM provides much higher level infrastructure for language interoperability (much like Microsoft's CLR).
JVM 是一个更高级别的基于堆栈的虚拟机。JVM 提供垃圾收集、对象和虚拟方法调用等概念。因此,JVM 为语言互操作性提供了更高级别的基础结构(很像 Microsoft 的 CLR)。
(It is possible to build these abstractions over LLVM just as it is possible to build them on top of C.)
(可以在 LLVM 上构建这些抽象,就像可以在 C 之上构建它们一样。)
回答by Edd Barrett
Java is a programming language, which uses the JVM as a means of "Just in Time" (JIT) execution, whereas LLVM is a compiler construction kit aimed at developing new languages and front-ends for existing languages. LLVM doeshave a JIT engine, but it need not be used if you don't require it. You could throw out LLVM assembler, byte-code or platform specific assembler instead of using JIT execution.
Java 是一种编程语言,它使用 JVM 作为“即时”(JIT) 执行的手段,而 LLVM 是一种编译器构建工具包,旨在为现有语言开发新语言和前端。LLVM确实有一个 JIT 引擎,但如果您不需要它,则不必使用它。您可以丢弃 LLVM 汇编器、字节码或特定于平台的汇编器,而不是使用 JIT 执行。
回答by Owen
It's too bad this question got off on the wrong foot. I came to it looking for a more detailed comparison.
太糟糕了,这个问题走错了路。我来到它寻找更详细的比较。
The biggest difference between JVM bytecode and and LLVM bitcode is that JVM instructions are stack-oriented, whereas LLVM bitcode is not. This means that rather than loading values into registers, JVM bytecode loads values onto a stack and computes values from there. I believe that an advantage of this is that the compiler doesn't have to allocate registers, but I'm not sure.
JVM 字节码和 LLVM 位码之间的最大区别在于 JVM 指令是面向堆栈的,而 LLVM 位码不是。这意味着 JVM 字节码不是将值加载到寄存器中,而是将值加载到堆栈中并从那里计算值。我相信这样做的一个优点是编译器不必分配寄存器,但我不确定。
LLVM bitcode is closer to machine-level code, but isn't bound by a particular architecture. For instance, I think that LLVM bitcode can make use of an arbitrary number of logical registers. Maybe someone more familiar with LLVM can speak up here?
LLVM 位码更接近机器级代码,但不受特定架构的约束。例如,我认为 LLVM 位码可以使用任意数量的逻辑寄存器。也许更熟悉 LLVM 的人可以在这里发言?