说中间代码在虚拟机中运行是否具有误导性

发布于 2024-09-08 15:06:34 字数 93 浏览 1 评论 0原文

如果我对所读内容的理解正确的话,虚拟机本质上是中间代码的编译器。 但从未说过 Delphi(作为非托管代码的示例)在其编译器中运行。 将虚拟机描述为编译器会不会更容易混淆?

If I am correct in understanding what I've read a virtual machine is essentially a compiler for intermediate code.
But it is never said that Delphi (as an example of unmanaged code) runs in its compiler.
Would it be less confusing to just describe a virtual machine as a compiler?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如果没有你 2024-09-15 15:06:34

传统编译器执行从源代码到目标代码的一次性转换。像 JVM 这样的虚拟机使用解释(字节码)和将字节码段编译为本机代码的即时编译器。将虚拟机整体描述为编译器是不准确的。

A traditional compiler does a one-time conversion from source code to object code. A virtual machine like the JVM uses a mixture of interpretation (of bytecode) and a just-in-time compiler that compiles segments of bytecode to native code. It's not accurate to describe a VM overall as a compiler.

酷炫老祖宗 2024-09-15 15:06:34

有一个编译器将源代码转换为VM代码(字节码),还有一个用于VM代码的JIT编译器->机器代码。 VM是源代码->标准的VM的编译目标,不一定是具体的实现。它可以用真机实现,这样就不需要进行JIT编译。

虚拟机更接近模拟器(或者如果你的 JIT 真的很愚蠢,那就是解释器:))

There's a compiler that translates source code to VM code (bytecode), and a JIT compiler for VM code -> machine code. The VM is the standard that the source code -> VM compiler targets, not necessarily the specific implementation. It could be implemented with a real machine, in which case it wouldn't need to do JIT compilation.

A VM is closer to an emulator (or if your JIT is really stupid, an interpreter :))

娇妻 2024-09-15 15:06:34

我认为人们试图用这个术语来表达的是虚拟机有一个额外的抽象层。因此,相同的代码,但每个平台的虚拟机允许它在该特定平台上运行。

I think what people are trying to capture with the terminology is that there's an extra layer of abstraction with virtual machines. So, same code, but the VM for each platform allows it to run on that specific platform.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文