1 / 26

Dalvik Virtual Machine Vs Java Virtual Machine

Dalvik Virtual Machine Vs Java Virtual Machine. Arpit Jain Mtech1. Outline. Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation. Virtual Machine.

shlomo
Download Presentation

Dalvik Virtual Machine Vs Java Virtual Machine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dalvik Virtual Machine Vs Java Virtual Machine Arpit Jain Mtech1

  2. Outline • Introduction • Dalvik VM • Java VM • Examples • Comparisons • Experimental Evaluation

  3. Virtual Machine • Virtual machines (VMs) are commonly used to distribute programs in an architecture-neutral format, which can easily be interpreted or compiled.

  4. Android OS

  5. Android Framework

  6. Dalvik VM • Dalvik is the virtual machine (VM) in Google's Android operating system. It is the software that runs the apps on Android devices. • Programs are commonly written in Java and compiled to byte code. They are then converted from Java Virtual Machine-compatible .class files to Dalvik-compatible .dex (Dalvik Executable) files before installation on a device

  7. Dalvik VM • Provides application portability. • Runs optimised file format(.dex) and dalvik byte code. • Minimal memory footprint.

  8. DEX format • A tool called dx is used to convert some (but not all) Java .class files into the .dex format. Multiple classes are included in a single .dex file. Duplicate strings and other constants used in multiple class files are included only once in the .dex output to conserve space. • An uncompressed .dex file is typically a few percent smaller in size than a compressed .jar (Java Archive) derived from the same .class files.

  9. Dex file • On the Android platform, Java source code is still compiled into .class files. But after .class files are generated, the “dx” tool is used to convert the .class files into a .dex, or Dalvik Executable, file. • Whereas a .class file contains only one class, a .dex file contains multiple classes. • It is the .dex file that is executed on the Dalvik VM. The .dex file has been optimized for memory usage.

  10. Zygote • Since every application runs in its own instance of the VM, VM instances must be able to start quickly when a new application is launched and the memory footprint of the VM must be minimal. • Android uses a concept called the Zygote to enable both sharing of code across VM instances and to provide fast start up time of new VM instances.

  11. Java VM • A Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code execution component of the Java software platform. • A JVM is distributed along with a set of standard class libraries that implement the Java application programming interface (API). Appropriate APIs bundled together with JVM form the Java Runtime Environment. • Java has always been marketed as “write once, run anywhere.”

  12. Java VM • In standard Java environments, Java source code is compiled into Java bytecode, which is stored within .class files. The .class files are read by the JVM at runtime. • Each class in your Java code will result in one .class file. This means that if you have, say, one .java source file that contains one public class, one static inner class, and three anonymous classes, the compilation process (javac) will output 5 .class files.

  13. Comparisons

  14. Disadvantages of Dex • By allowing for classes to share constants pools, repetition of constant values is kept to a minimum. The consequence of the minimal repetition is that there are significantly more logical pointers or references within a .dex file compared to a .class file. • Simplicity of JVM implementation, ease of writing a compiler back-end

  15. STACK VERSUS REGISTERS The cost of executing a VM instruction in an interpreter consists of three components: • Dispatching the instruction • Accessing the operands • Performing the computation

  16. Dispatching instruction • It involves fetching next VM instruction and jump to the corresponding segment of interpreter code. • Example: A=B+C can be • ILOAD c, ILOAD b, IADD, ISTORE a(stack JVM) • IADD a, b, c (virtual register Machine)

  17. Operands Accessing • Location of operands appears explicit in register code, while in stack based operands are found relative to stack pointer. • So, average register instruction is longer than the corresponding stack instruction. • This is the reason why stack architecture is popular.

  18. Translating Stack to Register • In stack based JVM, local variable is accessed using an index, and the operands stack is accessed using stack pointer. So all variables are short lived. • While Register based JVM considers both local variables and operand stack as virtual register.

  19. Contd...

  20. Translating Stack to Register • So, most of the stack-based JVM instructions are translated to corresponding register based virtual machine instruction with implicit operands translated to explicit operand registers. • Example:

  21. Copy propagation • In stack based JVM, operands are pushed from local variables to operand stack before they can be used and result again back to local variable. • This causes redundancy in our register based JVM as instructions can directly use local variables without going through the stack.So we use forward and backward copy propagation to eliminate redundancy.

  22. Example Instruction after translation for register based JVM After forward and backward copy propagation

  23. Experimental Evaluation • Studies shows that a register-based architecture requires and average of 47% less executed VM instructions than the stack based. • On the other hand the register code is 25% larger than the corresponding stack code but this increased cost of fetching more VM instructions due to larger code size involves only 1.07% extra real machine loads per VM instruction which is negligible.

  24. Contd...

  25. References • [1] Virtual Machine Showdown: Stack Versus Registers by Yunhe Shi, David Gregg, Andrew Beatty Department of Computer Science University of Dublin, Trinity College Dublin 2, Ireland • [2] J. Park and S. mook Moon. Optimistic register coalescing, Mar. 30 1999. • [3] The dalvik virtual machine architecture by David Ehringer.

More Related