Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Arpit Jain Mtech1. Outline Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation."— Presentation transcript:

1 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 Android OS is a software stack consisting of java app running on a java app framework on top of java core library running on dalvik VM. Android uses dalvik virtual machine. Compile java code to dalvik executables and that is run on dalvik VM.

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 Dalvik VMJava VM Register BasedStack Based Executes.dex fileExecutes.class file It uses shared, type-specific constant pools as it’s primary mechanism for conserving memory. Rather than store these values throughout the class, they are always referred to by their index in the constant pool. In the case of the.class file, each class has its own private, heterogeneous constant pool.

14

15 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

16 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

17 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)

18 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.

19 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.

20 Contd...

21 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:

22 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.

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

24 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.

25 Contd...

26 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.


Download ppt "Arpit Jain Mtech1. Outline Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation."

Similar presentations


Ads by Google