Dalvik (software)

From Wikipedia, the free encyclopedia - View original article

Original author(s)Dan Bornstein
Operating systemLinux kernel
TypeVirtual machine
LicenseApache License 2.0
  (Redirected from Dalvik virtual machine)
Jump to: navigation, search
Original author(s)Dan Bornstein
Operating systemLinux kernel
TypeVirtual machine
LicenseApache License 2.0
Dalvik Executable
Filename extension.dex

Dalvik is the process virtual machine (VM) in Google's Android operating system. It is the software that runs the apps on Android devices. Dalvik is thus an integral part of Android, which is typically used on mobile devices such as mobile phones and tablet computers as well as more recently on embedded devices such as smart TVs and media streamers. Programs are commonly written in Java and compiled to bytecode. They are then converted from Java virtual machine-compatible Java class files to Dalvik-compatible .dex (Dalvik EXecutable) and odex (Optimized Dalvik EXecutable) files before installation on a device, giving rise to the related terms odexing and de-odexing. The compact Dalvik Executable format is designed to be suitable for systems that are constrained in terms of memory and processor speed.

Dalvik is open-source software. It was originally written by Dan Bornstein, who named it after the fishing village of Dalvík in Eyjafjörður, Iceland, where some of his ancestors lived.[1][2]


Unlike Java VMs, which are stack machines, the Dalvik VM uses a register-based architecture.

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. Java bytecode is also converted into an alternative instruction set used by the Dalvik VM. An uncompressed .dex file is typically a few percent smaller in size than a compressed .jar (Java Archive) derived from the same .class files.[3]

The Dalvik executables may be modified again when installed onto a mobile device. In order to gain further optimizations, byte order may be swapped in certain data, simple data structures and function libraries may be linked inline, and empty class objects may be short-circuited, for example.

As of Android 2.2, Dalvik has a just-in-time compiler.[4]

Being optimized for low memory requirements, Dalvik has some specific characteristics that differentiate it from other standard VMs:[5]

Moreover, according to Google, the design of Dalvik permits a device to run multiple instances of the VM efficiently.[6]

Class library[edit]

Dalvik does not align to Java SE nor Java ME class library profiles[7][8] (e.g., Java ME classes, AWT or Swing are not supported). Instead it uses its own library[9] built on a subset of the Apache Harmony Java implementation.

Optimization, odexing and de-odexing[edit]


The relative merits of stack machines versus register-based approaches are a subject of ongoing debate.[10]

Generally, stack-based machines must use instructions to load data on the stack and manipulate that data, and, thus, require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and, therefore, tend to be larger. This difference is primarily of importance to VM interpreters for which opcode dispatch tends to be expensive along with other factors similarly relevant to just-in-time compilation.

However, tests performed on ARM devices by Oracle (owner of the Java technology) in 2010 with standard non-graphical Java benchmarks on both Android 2.2 (the initial release to include a just-in-time compiler) and Java SE embedded (both based on Java SE 6) seemed to show that Android 2.2 was 2 to 3 times slower than Java SE embedded.[11][dated info]

Licensing and patents[edit]

Dalvik is published under the terms of the Apache License 2.0.[12] Google says that Dalvik is a clean-room implementation rather than a development on top of a standard Java runtime, which would mean it does not inherit copyright-based license restrictions from either the standard-edition or open-source-edition Java runtimes.[13] Oracle and some reviewers dispute this.[14]

On 12 August 2010, Oracle, which acquired Sun Microsystems in April 2009 and therefore owns the rights to Java, sued Google over claimed infringement of copyrights and patents. Oracle alleged that Google, in developing Android, knowingly, directly and repeatedly infringed Oracle's Java-related intellectual property.[15][16][17] In May 2012 the jury in this case found that Google did not infringe on Oracle's patents, and the trial judge ruled that the structure of the Java APIs used by Google was not copyrightable.[18][19] The parties agreed to zero dollars in statutory damages for 9 lines of copied code.[20][21]

Android's ART virtual machine[edit]

Android 4.4 introduced a new experimental runtime known as ART.[22] It uses an Ahead-of-Time (AOT) process in which the bytecode is pre-compiled into machine language at the time of installation. This new runtime performance is currently not significantly better than Dalvik's, and even sometimes worse, but results are heavily dependent on the benchmark (although it might be explained by the fact that work on optimizing the new runtime has not really begun yet).[23] There are also some disadvantages, such as longer application install time. Moreover, applications occupy 10–20% more storage space because of the pre-compiled bytecode.[24]

Dalvik Turbo[edit]

Dalvik Turbo virtual machine is an alternative implementation.

See also[edit]


  1. ^ Journal entry referencing the source of the name
  2. ^ "Google Calling: Inside Android, the gPhone SDK". onlamp.com. Retrieved 2008-02-05. 
  3. ^ Bornstein, Dan (2008-05-29). "Presentation of Dalvik VM Internals" (PDF). Google. p. 22. Retrieved 2010-08-16. 
  4. ^ "Nexus One Is Running Android 2.2 Froyo. How Fast Is It Compared To 2.1? Oh, Only About 450% Faster". 2010-05-13. Retrieved 2010-05-21. 
  5. ^ Rose, John (2008-05-31). "with Android and Dalvik at Google I/O". Retrieved 2008-06-08. 
  6. ^ Google (2009-04-13). "What is Android?". Retrieved 2009-04-19. 
  7. ^ "Google's Android SDK Bypasses Java ME in Favor of Java Lite and Apache Harmony". infoq.com. 2007-11-12. Retrieved 2009-05-31. "Instead of providing a full version of the Java SE or Java ME Google has diverged on two fronts. First, a limited subset of the core Java packages is provided. (...) By going this route Android is following in the footsteps of another Google project GWT which uses Java as its development language but does not support the full JDK." 
  8. ^ "Alternative to Point2D". Droid Tutorials. 2010-02-12. Retrieved 2010-02-17. "Given that AWT is not supported in Android API, the Point2D class, which is useful for writing 2D graphics, is missing either." 
  9. ^ "Package Index". Open Handset Alliance. Retrieved 2009-. 
  10. ^ Shi, Yunhe; Gregg, David; Beatty, Andrew; Ertl, M. Anton (2005-06-11). "Virtual Machine Showdown: Stack Versus Registers". Retrieved 2009-12-22. 
  11. ^ Vandette, Bob (2010-11-22). "Java SE Embedded Performance Versus Android 2.2". Oracle Corporation. Retrieved 2011-09-04. "The results show that although Androids new JIT is an improvement over its interpreter only implementation, Android is still lagging behind the performance of our Hotspot enabled Java SE Embedded. As you can see from the above results, Java SE Embedded can execute Java bytecodes from 2 to 3 times faster than Android 2.2." 
  12. ^ "Downloading the Source Tree - Android Open Source". Android.git.kernel.org. Retrieved 2012-06-07. 
  13. ^ Stefano Mazzocchi (2007-11-12). "Dalvik: how Google routed around Sun’s IP-based licensing restrictions on Java ME". Retrieved 2010-08-16. 
  14. ^ Ed Bott (2011-09-08). "The real history of Java and Android, as told by Google". ZDNet. Retrieved 2011-11-27. "The definition of a “clean room” implementation is that the engineers writing the code have no direct exposure to the original, copyrighted material, including code, specifications, and other documentation. That’s a problem for Google, as I noted in yesterday’s post, because there is substantial evidence that the engineers working on the project had direct access to the copyrighted material. " 
  15. ^ "Oracle Sues Google Over Java in Android Devices". digitaltrends.com. 2010-08-13. Retrieved 2011-08-08. 
  16. ^ James Niccolai (2010-08-12). "Oracle sues Google over Java use in Android". Computerworld. Retrieved 2010-08-13. 
  17. ^ Mark Hachman (2010-08-13). "Oracle Sues Google Over Android Java Use". PC Magazine. Ziff Davis. 
  18. ^ Josh Lowensohn (May 23, 2012). "Jury clears Google of infringing on Oracle's patents". ZDNet. Retrieved 2012-05-25. 
  19. ^ Joe Mullin (May 31, 2012). "Google wins crucial API ruling, Oracle’s case decimated". Ars Technica. Retrieved 2012-06-01. 
  20. ^ Niccolai, James (June 20, 2012). "Oracle agrees to 'zero' damages in Google lawsuit, eyes appeal". Retrieved 2012-06-23. 
  21. ^ Adam Outler (May 16, 2012). "Update on the Oracle Versus Google Trial". Retrieved 2013-01-18. "A major portion of the Oracle’s claims are based on 9 lines of code contained within Java.Util.Arrays.rangeCheck(). Here is the code in question:..." 
  22. ^ "Introducing ART". android.com. Retrieved 2013-11-02. 
  23. ^ "Meet ART, Part 2: Benchmarks - Performance Won't Blow You Away Today, But It Will Get Better". androidpolice.com. 2013-11-12. Retrieved 2014-01-02. "The numbers and the videos together paint a picture of where ART stands today. It will definitely make a difference, but its current incarnation just hasn't matured enough to deliver significant gains" 
  24. ^ "Google introduces ART (Android Runtime) in KitKat". androidaio.com. Retrieved 2013-11-08. 

External links[edit]