Java DVM 和 JVM 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3446540/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 00:52:40  来源:igfitidea点击:

What is the difference between DVM and JVM?

javaandroidjvmdvm

提问by anish

What is difference between Java Virtual Machine and Dalvik Virtual Machine?

Java 虚拟机和 Dalvik 虚拟机有什么区别?

回答by sky

The jvm architecture is stack-based whereas the dvm architecture is register-based. Stack-based machines require more instructions(i.e. larger instruction set) than register-based machines for the same task. On the other side, each instruction in the register-based machines are larger.

jvm 架构是基于堆栈的,而 dvm 架构是基于寄存器的。对于相同的任务,基于堆栈的机器比基于寄存器的机器需要更多的指令(​​即更大的指令集)。另一方面,基于寄存器的机器中的每条指令都更大。

回答by DixonD

Conceptually, there is little difference from an application level between a DVM and a JVM. Architecturally, there is a major difference between the registerbased DVM and the stack-based JVM.

Both use a VM code model. However, the DVM uses registerbased opcodes that are comparable to the register-based bytecode instructions that most of the target platforms already execute. This includes architectures such as those available from ARM and MIPS and the x86-compatible architectures from Intel, AMD, and VIA Technologies.

Google developed Android and chose DVM for several reasons. First, there were licensing issues with most JVMs. Next, the DVM should be more efficient in terms of memory usage and performance on a register-based machine. DVM is also supposed to be more efficient when running multiple instances of the DVM. Applications are given their own instance. Hence, multiple active applications require multiple DVM instances. Like most Java implementations, the DVM has an automatic garbage collector.

从概念上讲,DVM 和 JVM 之间的应用程序级别几乎没有区别。在架构上,基于寄存器的 DVM 和基于堆栈的 JVM 之间存在重大差异。

两者都使用 VM 代码模型。但是,DVM 使用基于寄存器的操作码,这些操作码与大多数目标平台已经执行的基于寄存器的字节码指令相当。这包括诸如来自 ARM 和 MIPS 的架构以及来自 Intel、AMD 和 VIA Technologies 的 x86 兼容架构。

谷歌开发 Android 并选择 DVM 有几个原因。首先,大多数 JVM 都存在许可问题。接下来,DVM 在基于寄存器的机器上的内存使用和性能方面应该更高效。在运行多个 DVM 实例时,DVM 也应该更高效。应用程序有自己的实例。因此,多个活动应用程序需要多个 DVM 实例。像大多数 Java 实现一样,DVM 有一个自动垃圾收集器。

More about it

更多关于它

回答by Mayuri

DVM is Register based which is designed to run on low memory, uses its own byte code and runs .Dex file

DVM 是基于寄存器的,旨在在低内存上运行,使用自己的字节码并运行 .Dex 文件

JVM is Stack based which uses java byte code and runs .class file having JIT.

JVM 是基于堆栈的,它使用 Java 字节码并运行具有 JIT 的 .class 文件。

Java source code is compiled by the Java compiler into .class files. Then the dx (dexer) tool, part of the Android SDK processes the .class files into a file format called DEX that contains Dalvik bytecode. The dx tool eliminate all the redundant information that is present in the classes. In DEX all the classes of the application are packed into one file. DVM has been designed so that a device can run multiple instances of the VM efficiently.

Java 源代码由 Java 编译器编译成 .class 文件。然后 dx (dexer) 工具(Android SDK 的一部分)将 .class 文件处理为一种名为 DEX 的文件格式,其中包含 Dalvik 字节码。dx 工具消除了类中存在的所有冗余信息。在 DEX 中,应用程序的所有类都打包到一个文件中。DVM 的设计使设备可以高效地运行 VM 的多个实例。

stack-based machines must use instructions to load data on the stack and manipulate that data, and, thus, require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and, therefore, tend to be larger.

基于堆栈的机器必须使用指令将数据加载到堆栈上并操作该数据,因此需要比寄存器机器更多的指令来实现相同的高级代码,但寄存器机器中的指令必须对源寄存器和目标寄存器进行编码因此,往往更大。

回答by ramesh

Jvm will work based on byte code and the dvm will works based on optimized bytecode it is optimised for mobile platforms because mobile devices have low memory and low process that's why it is using the linux kernal.

JVM 将基于字节码工作,而 dvm 将基于优化的字节码工作,它针对移动平台进行了优化,因为移动设备具有低内存和低进程,这就是它使用 linux 内核的原因。

回答by Sheel

When a Java virtual machine start running a program, it needs memory to store many things, including bytecodes and other information it extracts from loaded class files, objects the program instantiates, parameters to methods, return values, local variables, and intermediate results of computations.

当 Java 虚拟机开始运行程序时,它需要内存来存储很多东西,包括字节码和它从加载的类文件中提取的其他信息、程序实例化的对象、方法的参数、返回值、局部变量和计算的中间结果.

The Java virtual machine organizes the memory it requires to execute a program into several runtime data areas.

Java 虚拟机将执行程序所需的内存组织到几个运行时数据区中。

Generally, stack-based machines must use instructions to load data on the stack and manipulate that data, and, thus, require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and, therefore, tend to be larger.

通常,基于堆栈的机器必须使用指令将数据加载到堆栈上并操作该数据,因此,实现相同的高级代码需要比寄存器机器更多的指令,但寄存器机器中的指令必须对源代码和数据进行编码。目标寄存器,因此往往更大。

This difference is primarily of importance to VM interpreters for whom opcode dispatch tends to be expensive and other factors are relevant for JIT Compilation.

这种差异对于 VM 解释器来说很重要,因为 VM 解释器的操作码调度往往很昂贵,并且其他因素与 JIT 编译相关。

Being optimized for low memory requirements, Dalvik has some specific characteristics that differentiate it from other standard VMs>>>>>

Dalvik 针对低内存要求进行了优化,具有一些使其与其他标准 VM 不同的特定特性>>>>

The VM was just slimmed down to use less space--->> Dalvik currently has no just-in-time-compiler (JIT), but Android 2.0 includes experimental source for one (disabled by default). The constant pool has been modified to use only32-bit indexes to simplify the interpreter. It uses its own bytecode, not Java bytecode***

VM 只是被精简以使用更少的空间--->> Dalvik 目前没有即时编译器 (JIT),但 Android 2.0 包含一个实验性源代码(默认情况下禁用)。常量池已被修改为仅使用 32 位索引以简化解释器。它使用自己的字节码,而不是 Java 字节码* **

回答by zerocool

The DVM differs from the JVM in a number of ways. First, it's a register-based machine, unlike the stack-based JVM. And instead of multiple class files bundled into a jar file, the DVM uses a single Dalvik executable (DEX) file with a different structure and opcodes

DVM 在许多方面与 JVM 不同。首先,它是一个基于寄存器的机器,与基于堆栈的 JVM 不同。DVM 没有将多个类文件捆绑到一个 jar 文件中,而是使用具有不同结构和操作码的单个 Dalvik 可执行 (DEX) 文件

回答by pulp_fiction

Here is a tabular comparison(Source: Mr. Atul):

这是一个表格比较(来源Atul 先生):

enter image description here

在此处输入图片说明

回答by Kaumadie Kariyawasam

Dalvik VM can't execute Java bytecode(.class) It has to be(.dex)

Dalvik VM 无法执行 Java 字节码(.class) 必须是(.dex)

Oracle JVM has stack based architecture & Dalvik has register based architecture.

Oracle JVM 具有基于堆栈的架构,而 Dalvik 具有基于寄存器的架构。

JVM suppost to multiple operating system. (it is open source) but DVM supported for Android Operating system (before comming android 5.o android used the DVM)

JVM 支持多种操作系统。(它是开源的)但 Android 操作系统支持 DVM(在 android 5.o 到来之前 android 使用了 DVM)