 Hello, this is Arpit from MTechOne. I am going to present the topic, the difference between the Dalvik virtual machine versus the Java virtual machine. So I will go through the presentation in the following order. First one, I will cover the introduction about the virtual machine, then the Dalvik virtual machine, Java virtual machine, examples and the comparison between these two and I will explain the difference between these two with the help of experimental evolution. Now the first topic is the virtual machine. So where does the need of virtual machine came into play? So in earlier days, what we used to do is write a program in the same, we compile the program, write the program and run the program in the same platform in which we are using. But to eliminate this one, what we are having is virtual machine so that we can distribute the program in an architectural, brutal format. That means we can write a program in some other platform and run that program in some other platform. Now, as you all are working with the Android OS, so you know very well about that, but I would like to explain further. Android OS is a kind of software stack which is consists of Java application which is running on Java framework, but the difference is that it is using Dalvik virtual machine which other Java based, which other Java based operating system is not using. And that Dalvik virtual machine is using Dalvik executable code which other Java based operating system are using that JVM. Like I will explain in this diagram, okay I will explain, means this is a complete framework of Android and here we are having Android runtime which is using code libraries which are of Java and the Dalvik virtual machine. So here comes the difference. Earlier we used to have JVM, Java virtual machine running over here which is at the bottom of Java code libraries. Now what is JVM? So it is a virtual machine which is used by Google and it is run on Android devices. So the Dalvik virtual machine is same as that of Java virtual machine, but the difference lies in the fact that it is using .deck file as it is executable while the JVM is using Java byte codes. So first of all what we do is we first compile our Java program so that we get a .class file and using a tool named DX we convert that class file into a .deck file which is used as an executable so that we can run an application. Now why we are using Dalvik virtual machine? What is the means advantages of Dalvik virtual machine? First one is it provides application portability which is also provided by the JVM. And second one is it is using .deck which is much simplified as compared to our Java byte code which is used by JVM. So here comes the difference and the third one is minimal memory footprint as it is using less memory I will explain it further why it is using less memory so this advantage comes. Now the deck format what exactly is deck format? So what we are having is we are having a tool DX which converts the class file into deck file and here what happened with the Java byte code is when we are having a Java code when it gets compiled then for all of the classes a separate class file is created but this is not happening in the case of deck file. When we compile a Java code then many class file, multiple class file can be merged and they can be put in a deck format deck file. So if we compare it as size wise then it is quite less as compared to the Java byte code. So that is why it is using less memory it is same as this one. So once we are having our deck file so we can use it for it for Dalvik virtual machine as it knows only deck file and yeah here is the difference means a class file contains only one class a deck file contains multiple classes now Zygote. So what is the problem in this is in Android OS each application has its own instance of VM means it is using each application is using different instance of VM. So we have to manage the different instance of VM so for that purpose Android is using a concept called Zygote so that they can share the code between different VM instances as well as for the fast startup of different VM instances we need this one Zygote. So basically this is used to make a switch between the different VMs and to make the startup fast. Now the Java virtual machine as you all know that this virtual machine is can execute the Java byte code and this is having a standard class library that is having that implements the basic Java JPS and it is always marketed as write once or run anywhere as you all know it is platform independent language. In this one in JDM the source code is compiling to Java byte code which is stored as a class file and it can be used further over different platforms and yeah here is an example that if we are in a Java code if we are having five classes then once it gets compiled then we are getting five dot class file as output. So means the overall summary is that we are getting a different class file for each of the classes. So here is the comparison between these two virtual machine the first one is the register based other one is the stack based I will come later what is meant by register and stack based but for that time you better know that it is register based means it is faster and it executes dot that file while it executes dot class file and the third one is important that it is using the constant pool and where it stores all the fields and methods of that class file of various class file and when it is referred they are referred with the help of an index while in the JDM we are maintaining a different we are maintaining a heterogeneous constant pool for each of the classes means for different classes we are having a different field methods similar like this one here is a dot jar package which is having like different classes. So for each classes we are maintaining a class field class field method attributes and heterogeneous constant pool for each of the classes while for dot apk which is a similar container for dot deck file it is having the means it is not storing these things means for each of the classes it is storing once and they are referred as with the help of an index later on. Now they are disadvantageous of deck file so what is the disadvantage is since we are using this constant pool over and over again so we have to maintain logical pointers so here is an overhead of maintaining that pointers and the second one is JDM is simple to write means it back end wise if we see the code wise then it is quite simpler than as compared to DVM Dalvik virtual machine. Now I will explain the difference between the stack versus register with the help of on the basis of cost and the cost of executing a VM instruction depends on mainly three things first one is dispatching the instruction dispatching the next VM instruction then accessing the operands and perform the computation. Dispatching the instruction means fetching the next VM instruction and then jumps to the corresponding segment. So suppose if we have an example A equal to B plus C so for stack this JDM what we have the instruction is like I load C I load B add and then store but for virtual machine it is like I add A, B, C so as compared to this the number of instruction are quite less in register based while the size of the instruction is more as compared to that stack based. So that is the kind of trade off between the size of the instruction and the number of instruction between these two. Now operand accessing that in stack based the operands are from relative to the stack pointer means with the help of a stack pointer we can access them but in register based we have to make them access appears through explicitly that means we have to make them explicit we have to refer them explicit so like so because of this the size of instruction becomes larger while the number of instruction becomes less. So since the size is increasing that is the reason why stack architecture is more popular that time but later on we find out that the increase in size is as compared to the number of instruction decrease won't affect means like that the overall I will explain through graph I think it is better. In stack based the local variable is access using an index while the operand stack is access using an stack pointer while in case of register based JBM there is no concept of stack so everything is access with the help of registers only like this one here we have this is stack based JBM we have local variables frame data and operand stack and it is access with the help of index and it is access with the help of stack pointers while this one in virtual register that means Dalvik virtual machine kind of we are having we access both local variables and operand stack with the help of index only. Now since if we want to translate from stack to register then we need to means translate all the implicit operands to the explicit operands. So what we do is if this is our stack based byte code which is having I load I load I ahead and I store so for register based what we do is for load we move from R1 to R10 register 1 to register 10 then for this R2 to R11 and then add and then store here we are sorry here we are what we are doing is we are putting the variables from local variable to the operand stack while in a store we are putting back from the operand stack to the local variable that I think you should all know what exactly that means. Now since here we are having move instruction so it is getting redundant for load also we are having move instruction for store also we are having move instruction. So to remove that redundancy we have complete propagation so we are having forward complete propagation backward complete propagation so if we are having this type of instruction which we have which we got after translating it into the register based JBM so for instead of moving the R1 to R10 and R2 to R11 when we do forward complete propagation so we can write R10 and R11 like R1 and R2 means with the help of forward complete propagation we replace these two by these two and with the help of backward complete propagation since we are moving the value of R10 to R3 so instead of here R10 we will write R3. So these four instruction are merged and combined to form a single instruction so that is the power of this experimental evaluation shows that we are having that when we use register based architecture so the overall decrease in the number of instruction is 47 percent means we have to execute 47 percent less instruction is compared to the stack based architecture but the overall size of each instruction is getting 25 percent larger for register based architecture so but when we compare these two then we find out that having executing 47 percent less instruction is much better than having means that we can accept this 47 percent with this means 25 percent so using register based is quite better and in graph also we see that this is blue lines are code size so when we find out that these all are approximate to 25 percent.