JVM vs DVM:
Vs
1.Conceptually,
there is little difference from an application level between a DVM and a
JVM. Architecturally, there is a major difference between the register-based
DVM and the stack-based JVM.
Both use
a VM code model. However, the DVM uses register-based 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.
2) 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.
3). 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 kernel.
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).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 Dalvikbytecode.
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.
Dalvik
Virtual machine (DVM) is Register Architecture, designed to run on low memory,
uses its own byte code and runs .Dex file (Dalvik Executable File).
Java
Virtual Machine (JVM) is Stack Architecture, 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
proprietary file format called DEX that contains Dalvikbytecode.
Difference between .class and .dex file format
● In DEX
all the classes of the application are packed into one file.
● All the
classes in the same DEX file share field, method, etc if they are same.
● Classes
from the same DEX file are loaded by the same class loader instance.
Difference
between .class and .dex file The dx tool eliminate all the redundant
information that is present in the classes. The initial loading and parsing
procedures that happens again and again are eliminated.
In
general, a Java .class file contains a number of different method signatures
used in the code. These signatures are duplicated if referenced in different
Java classes.In other words, each of these classes references to the methods
that takes the same arguments and the same return type. So, each one of these
classes will have to include the same method signatures and hence the efforts
of parsing the files are duplicated. In addition to this, there is a large
number of strings included that labels the internal bits of the class
files.
In the
dex conversion all of the separate constant pools are collapsed into a single
shared constant pool. This way not only is redundant information eliminated but
storage space to store the shared constant pool is also conserved.
Please Send Your Comments To ambilpura.sunil@gmail.com
Stay Tune For Next Tutorial... JSON Parsing In Android:
|

No comments:
Post a Comment