|
Authored by: Anonymous on Monday, May 21 2012 @ 06:16 PM EDT |
A Java VM is stack-based. Dalvik is register-based.
The difference has to do with how the bytecode instructions do their work.
In compiled Java code, the bytecode instructions push temporary values
on a stack, and/or take their arguments off a stack.
So code like X = Y + 5;
In a Java VM, it would produce something like this:
- An instruction to get field Y's value, and push it on the stack
- An instruction to push the number 5 on the stack
- An instruction to pop two numbers off the stack and add them together,
pushing the result on the stack
- An instruction to pop a number off the stack and store it into field X.
That is stack-based bytecode.
In Dalvik (register-based), you would instead have something sort of like
this:
- An instruction to get field Y's value and put it in register 4.
- An instruction to put the number 5 into register 1.
- An instruction to add together registers 4 and 1, and store the result in
register 6.
- An instruction to store the result from register 6 into the field X.
Anyway, you can see that the details are different, but both types of
instruction set allow you to carry out any kind of computations.
In order to "simulate execution" of Java bytecodes, you would need to
pretend to execute them and keep track of what happens to the stack. To
simulate execution of Dalvik bytecodes, you would have to simulate the
register file. But the optimization Oracle is challenging with their '104
patent is performed on Java bytecodes by the dex compiler tool, so it
would need to simulate that stack in order to "simulate execution" of
the
instructions being optimized (the Java bytecode instructions).[ Reply to This | Parent | # ]
|
|
Authored by: jjs on Monday, May 21 2012 @ 06:19 PM EDT |
correction - it's Sun/Oracle's JVM that's stack-based, dalvik
is register-based (which is better for small memory and slow
memory, what you find in embedded devices).
A stack is like the stack of plates in a buffet line at an
"all you can eat" restaurant. You add by dumping plates in
the top, and you can only remove from the top.
---
(Note IANAL, I don't play one on TV, etc, consult a practicing attorney, etc,
etc)
[ Reply to This | Parent | # ]
|
|
|
|
|