Google I/O 2008 - Dalvik Virtual Machine Internals
715 16 168491
Dalvik VM Internals
Dan Bornstein (Google)
Dalvik — the virtual machine with the unusual name — runs your code on Android. Join us to learn about the motivation for its design and get some details about how it works. You'll also walk away with a few tips for how to write code that works well with the platform. Be prepared for a deep dive into technical details. Questions encouraged!
By chubot 2017-09-20
This is a great post. I like how they walked through all the steps and especially the "perf" tool.
Ruby has a patch to do the same thing -- increase sharing by moving reference counts out of the object itself:
First post in a long series:
I think these patches or something similar may have made it into Ruby 2.0:
The Dalvik VM (now replaced by ART) also did this to run on phones with 64 MiB of memory:
I think PHP might do it too. It feels like Python should be doing this as well.
By anonymous 2017-09-20
I can't find a reference, but I think Sun decided for the stack-based bytecode approach because it makes it easy to run the JVM on an architecture with few registers (e.g. IA32).
- avoid instruction dispatch
- avoid unnecessary memory access
- consume instruction stream efficiently (higher semantic density per instruction)
and on slide 36:
- 30% fewer instructions
- 35% fewer code units
- 35% more bytes in the instructions stream
- but we get to consume two at a time
According to Bornstein this is "a general expectation what you could find when you convert a set of class files to dex files".
The relevant part of the presentation video starts at 25:00.