What is the difference between DVM and JVM?

旧巷老猫 提交于 2019-11-27 09:13:58

问题


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


回答1:


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

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

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.

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.




回答2:


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.

More about it




回答3:


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.




回答4:


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.

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

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.

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

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***




回答5:


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




回答6:


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.




回答7:


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



来源:https://stackoverflow.com/questions/3446540/what-is-the-difference-between-dvm-and-jvm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!