Dalvik

DalvikOriginal author(s)| Dan Bornstein

|

Operating system| Linux kernel
Platform| Android
Type| Virtual machine
License| Apache License 2.0
Website| source.android.com/devices/tech/dalvik/index.html
Dalvik ExecutableFilename extension| `.dex`

|

Dalvik is a discontinued[1] process virtual machine (VM) in Google's Android operating system that executes applications written for Android. (Dalvik bytecode format is still used as a distribution format, but no longer at runtime in newer Android versions.) Dalvik was an integral part of the Android software stack in the (now unsupported) Android versions 4.4 "KitKat" and earlier, which were commonly used on mobile devices such as mobile phones and tablet computers, and more in some devices such as smart TVs and wearables. Dalvik is open-source software, originally written by Dan Bornstein, who named it after the fishing village of Dalvík in Eyjafjörður, Iceland.[2][3]

Programs for Android are commonly written in Java and compiled to bytecode for the Java virtual machine, which is then translated to Dalvik bytecode and stored in .dex (Dalvik EXecutable) and .odex (Optimized Dalvik EXecutable) files; related terms odex and de-odex are associated with respective bytecode conversions. The compact Dalvik Executable format is designed for systems that are constrained in terms of memory and processor speed.

The successor of Dalvik is Android Runtime (ART), which uses the same bytecode and .dex files (but not .odex files), with the succession aiming at performance improvements transparent to the end users. The new runtime environment was included for the first time in Android 4.4 "KitKat" as a technology preview,[4][5] and replaced Dalvik entirely in later versions; Android 5.0 "Lollipop" is the first version in which ART is the only included runtime.[6]

## Contents

* 1 Architecture
* 2 Performance
* 3 Licensing and patents
* 4 See also
* 5 References
* 6 External links

## Architecture

A comparison of Dalvik and ART architectures

Unlike Java VMs, which are stack machines, the Dalvik VM uses a register-based architecture that requires fewer, typically more complex, virtual machine instructions. Dalvik programs are written in Java using the Android application programming interface (API), compiled to Java bytecode, and converted to Dalvik instructions as necessary.

A tool called dx is used to convert 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 Java archive (JAR) derived from the same .class files.[7]

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.

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

* The VM was slimmed down to use less space.
* The constant pool has been modified to use only 32-bit indices to simplify the interpreter.
* Standard Java bytecode executes 8-bit stack instructions. Local variables must be copied to or from the operand stack by separate instructions. Dalvik instead uses its own 16-bit instruction set that works directly on local variables. The local variable is commonly picked by a 4-bit "virtual register" field. This lowers Dalvik's instruction count and raises its interpreter speed.

According to Google, the design of Dalvik permits a device to run multiple instances of the VM efficiently.[9]

Android 2.2 "Froyo" brought trace-based just-in-time (JIT) compilation into Dalvik, optimizing the execution of applications by continually profiling applications each time they run and dynamically compiling frequently executed short segments of their bytecode into native machine code. While Dalvik interprets the rest of application's bytecode, native execution of those short bytecode segments, called "traces", provides significant performance improvements.[10][11][12]

## Performance

A Dalvik-powered phone

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

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 of importance to VM interpreters, for which opcode dispatch tends to be expensive, along with other factors similarly relevant to just-in-time compilation.

Tests performed on ARMv7 devices in 2010 by Oracle (owner of the Java technology) with standard non-graphical Java benchmarks showed the HotSpot VM of Java SE embedded to be 2–3 times faster than the JIT-based Dalvik VM of Android 2.2 (the initial Android release that included a JIT compiler).[14] In 2012, academic benchmarks confirmed the factor of 3 between HotSpot and Dalvik on the same Android board, also noting that Dalvik code was not smaller than Hotspot.[15]

Furthermore, (As of March 2014), benchmarks performed on an Android device still show up to a factor 100 between native applications and a Dalvik application on the same Android device.[16][original research?][improper synthesis?] Upon running benchmarks using the early interpreter of 2009, both Java Native Interface (JNI) and native code showed an order of magnitude speedup.[17]

## Licensing and patents

Dalvik is published under the terms of the Apache License 2.0.[18] Some say[citation needed] 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. Oracle and some reviewers dispute this.[19]

On August 12, 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.[20][21][22] 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.[23][24] The parties agreed to zero dollars in statutory damages for 9 lines of copied code.[25][26]

## See also

* Android Runtime
* Android software development
* Application virtualization
* Comparison of application virtual machines
* Comparison of Java and Android API
* JEB decompiler – a Dalvik (DEX and APK) decompiler
* Dalvik Turbo virtual machine – a proprietary alternative Dalvik implementation

## References

1. ↑ "Debugging ART Garbage Collection". https://source.android.com/devices/tech/dalvik/gc-debug.html. Retrieved 6 October 2015. "The Dalvik runtime is no longer maintained or available [in current versions of Android] and its byte-code format is now used by ART."
2. ↑ Journal entry referencing the source of the name
3. ↑ "Google Calling: Inside Android, the gPhone SDK". http://www.onlamp.com/pub/a/onlamp/2007/11/12/google-calling-inside-the-gphone-sdk.html. Retrieved 2008-02-05.
4. ↑ Sean Buckley (2013-11-06). "'ART' experiment in Android KitKat improves battery life and speeds up apps". Engadget. https://www.engadget.com/2013/11/06/new-android-runtime-could-improve-battery-life/. Retrieved 2014-07-05.
5. ↑ Daniel P. (2013-11-07). "Experimental Google ART runtime in Android KitKat can bring twice faster app executions". http://www.phonearena.com/news/Experimental-Google-ART-runtime-in-Android-KitKat-can-bring-twice-faster-app-executions_id49139. Retrieved 2014-07-05.
6. ↑ Brad Linder (October 15, 2014). "What's new in Android 5.0 Lollipop?". http://liliputing.com/2014/10/whats-new-android-5-0-lollipop.html. Retrieved October 15, 2014.
7. ↑ Bornstein, Dan (2008-05-29). "Presentation of Dalvik VM Internals" (PDF). Google. p. 22. http://sites.google.com/site/io/dalvik-vm-internals/2008-05-29-Presentation-Of-Dalvik-VM-Internals.pdf?attredirects=0. Retrieved 2010-08-16.
8. ↑ Rose, John (2008-05-31). "with Android and Dalvik at Google I/O". http://blogs.sun.com/jrose/entry/with_android_and_dalvik_at. Retrieved 2008-06-08.
9. ↑ Google (2009-04-13). "What is Android?". http://developer.android.com/guide/basics/what-is-android.html. Retrieved 2009-04-19.
10. ↑ "A JIT Compiler for Android's Dalvik VM" (PDF). Google. May 2010. pp. 5-14. http://www.android-app-developer.co.uk/android-app-development-docs/android-jit-compiler-androids-dalvik-vm.pdf. Retrieved March 18, 2015.
11. ↑ Phil Nickinson (May 26, 2010). "Google Android developer explains more about Dalvik and the JIT in Froyo". http://www.androidcentral.com/google-android-developer-explains-more-about-dalvik-and-jit-froyo. Retrieved July 8, 2014.
12. ↑ "Nexus One Is Running Android 2.2 Froyo. How Fast Is It Compared To 2.1? Oh, Only About 450% Faster". 2010-05-13. http://www.androidpolice.com/2010/05/11/exclusive-androidpolice-coms-nexus-one-is-running-android-2-2-froyo-how-fast-is-it-compared-to-2-1-oh-only-about-450-faster/. Retrieved 2010-05-21.
13. ↑ Shi, Yunhe; Gregg, David; Beatty, Andrew; Ertl, M. Anton (2005-06-11). "Virtual Machine Showdown: Stack Versus Registers". http://www.usenix.org/events/vee05/full_papers/p153-yunhe.pdf. Retrieved 2009-12-22.
14. ↑ Vandette, Bob (2010-11-22). "Java SE Embedded Performance Versus Android 2.2". Oracle Corporation. http://blogs.oracle.com/javaseembedded/entry/how_does_android_22s_performance_stack_up_against_java_se_embedded. 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."
15. ↑ "Evaluation of Android Dalvik virtual machine". Association for Computing Machinery. 2012. http://dl.acm.org/citation.cfm?id=2388956. Retrieved 2014-03-23. "In the JITC mode, however, Dakvik is slower than HotSpot by more than 2.9 times and its generated code size is not smaller than HotSpot's due to its worse code quality and trace-chaining code."
16. ↑ "Top AndEBench Scores". www.eembc.org. http://www.eembc.org/andebench/. Retrieved 2014-03-23.
17. ↑ "Developing and Benchmarking Native Linux Applications on Android". Lecture Notes of the Institute for Computer Sciences, Social Informatics and Telecommunications Engineering. Springer Publishing. 2009-04-29. https://link.springer.com/chapter/10.1007/978-3-642-01802-2_28. Retrieved 2014-03-23. "The results show that native C applications can be up to 30 times as fast as an identical algorithm running in Dalvik VM. Java applications can become a speed-up of up to 10 times if utilizing JNI."
18. ↑ "Downloading the Source Tree - Android Open Source". Android.git.kernel.org. Archived from the original on 2009-04-17. https://web.archive.org/web/20090417091524/http://android.git.kernel.org/?p=platform/dalvik.git. Retrieved 2012-06-07.
19. ↑ Ed Bott (September 8, 2011). "The real history of Java and Android, as told by Google". ZDNet. http://www.zdnet.com/blog/bott/the-real-history-of-java-and-android-as-told-by-google/3924. 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. "
20. ↑ "Oracle Sues Google Over Java in Android Devices". digitaltrends.com. 2010-08-13. http://www.digitaltrends.com/mobile/oracle-sues-google-over-java-in-android-devices/. Retrieved 2011-08-08.
21. ↑ James Niccolai (2010-08-12). "Oracle sues Google over Java use in Android". Computerworld. http://www.computerworld.com/s/article/9180678/Update_Oracle_sues_Google_over_Java_use_in_Android?taxonomyId=13. Retrieved 2010-08-13.
22. ↑ Mark Hachman (2010-08-13). "Oracle Sues Google Over Android Java Use". PC Magazine. Ziff Davis. https://www.pcmag.com/article2/0,2817,2367761,00.asp.
23. ↑ Josh Lowensohn (May 23, 2012). "Jury clears Google of infringing on Oracle's patents". ZDNet. http://www.zdnet.com/blog/btl/jury-clears-google-of-infringing-on-oracle-patents/77897. Retrieved 2012-05-25.
24. ↑ Joe Mullin (May 31, 2012). "Google wins crucial API ruling, Oracle’s case decimated". Ars Technica. https://arstechnica.com/tech-policy/2012/05/google-wins-crucial-api-ruling-oracles-case-decimated/. Retrieved 2012-06-01.
25. ↑ Niccolai, James (June 20, 2012). "Oracle agrees to 'zero' damages in Google lawsuit, eyes appeal". http://www.computerworld.com/s/article/9228298/Oracle_agrees_to_zero_damages_in_Google_lawsuit_eyes_appeal. Retrieved 2012-06-23.
26. ↑ Adam Outler (May 16, 2012). "Update on the Oracle Versus Google Trial". http://www.xda-developers.com/android/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:..."

## External links

* Dalvik bytecode – official Android documentation of the instruction set
* Dex Executable format – official Android documentation
* A JIT Compiler for Android's Dalvik VM on YouTube, Google I/O 2010, by Ben Cheng and Bill Buzbee
* Dalvik VM Internals, Google I/O 2008, by Dan Bornstein
* The $800 Million Dollar Question: What’s the Difference Between Trademark and Copyright?

* v
* t
* e

Android (operating system)

Software
development
Category|

| Development tools,
official|

* Software development kit (SDK)
* Android Debug Bridge (ADB)
* Fastboot
* Android application package (APK)
* Native Development Kit (NDK)
* Android Open Accessory Development Kit
* Bionic
* RenderScript
* Skia
* Dalvik
* Android Runtime (ART)
* Firebase
* Google Cloud Messaging (GCM)
* Firebase Cloud Messaging (FCM)
* AdMob
* Material Design
* Fonts
* Droid
* Roboto
* Noto
* Google Developers

|

Development tools,
other|

* OpenBinder
* Apache Harmony
* OpenJDK
* Gradle

Integrated development
environments (IDE)|

* Android Studio
* IntelliJ IDEA
* Eclipse
* Android Development Tools (ADT)
* App Inventor

Languages, databases|

* Java
* Kotlin
* XML
* C
* C++
* SQLite

Virtual reality|

* Cardboard
* Daydream

Events, communities|

* Google I/O
* Developer Challenge
* Developer Lab
* Android Open Source Project (AOSP)

Releases|

* 1.0
* 1.1
* Cupcake (1.5)
* Donut (1.6)
* Eclair (2.0–2.1)
* Froyo (2.2)
* Gingerbread (2.3)
* Honeycomb (3.x)
* Ice Cream Sandwich (4.0)
* Jelly Bean (4.1–4.3)
* KitKat (4.4)
* Lollipop (5.x)
* Marshmallow (6.0)
* Nougat (7.x)
* Oreo (8.x)
* Pie (9.0)
* 10

Derivatives|

* Android Automotive
* Android Things
* Android TV
* Wear OS

Smartphones,
tablets|

| Google Pixel|

* Pixel & Pixel XL
* Pixel 2 & Pixel 2 XL
* Pixel 3 & Pixel 3 XL
* 3a & 3a XL
* Pixel C
* Pixel 4 & Pixel 4 XL

|

Google Nexus|

* Nexus One
* Nexus S
* Galaxy Nexus
* Nexus 4
* Nexus 5
* Nexus 5X
* Nexus 6
* Nexus 6P
* Nexus 7
* 2012 version
* 2013 version
* Nexus 10
* Nexus 9
* Nexus Q
* Nexus Player

Google Play edition|

* HTC One (M7)
* HTC One (M8)
* LG G Pad 8.3
* Moto G
* Samsung Galaxy S4
* Sony Xperia Z Ultra

* Android Go
* Android One
* other smartphones

Customized
variants|

* Android-x86
* Remix OS
* AOKP
* Baidu Yi
* Barnes & Noble Nook
* ColorOS
* CopperheadOS
* Fire OS
* Flyme OS
* Funtouch OS
* LeWa OS
* LineageOS
* /e/
* CyanogenMod
* MIUI
* Nokia X software platform
* OmniROM
* OPhone
* OxygenOS
* Replicant
* Ubuntu for Android
* XobotOS
* Yun OS

Applications|

* Android Auto
* Assistant
* Google Now
* Earth
* Sky
* Gmail
* Google Chrome for Android
* Goggles
* Hangouts
* Maps
* Navigation
* Waze
* Pay
* Send
* Play
* Books
* Games
* Movies & TV
* Music
* Newsstand
* Talk
* Trips
* Voice

APIs|

* Google Maps
* Google Play Services
* Google Search

Alternative
user interfaces|

* Asus Zen UI
* Google Pixel UI
* Hive UI
* HTC Sense
* Huawei EMUI
* LG UX (Optimus UI)
* MIUI
* Samsung One UI
* Experience
* TouchWiz

Lists|

* Custom firmware
* Features
* Free and open-source applications
* Games
* Google apps
* Launchers

Related topics|

* Index of articles
* Androidland
* Chromecast
* Google
* Java vs. Android API
* Lawn statues
* Legal issues
* Oracle v. Google
* Smartphone patent wars
* Rooting
* XDA Developers

* v
* t
* e

Virtualization software

Comparison of platform virtualization software

Hardware
virtualization
(hypervisors)|

| Native|

* Adeos
* CP/CMS
* Hyper-V
* KVM
* Red Hat Enterprise Virtualization
* LDoms / Oracle VM Server for SPARC
* Logical Partition (LPAR)
* LynxSecure
* PikeOS
* Proxmox VE
* SIMMON
* VMware ESXi
* VMware vSphere
* vCloud
* VMware Infrastructure
* Xen
* Oracle VM Server for x86
* XenServer
* XtratuM
* z/VM

|

Hosted|

| Specialized|

* Basilisk II
* bhyve
* Bochs
* Cooperative Linux
* DOSBox
* DOSEMU
* PCem
* PikeOS
* SheepShaver
* SIMH
* Windows on Windows
* Virtual DOS machine
* Win4Lin

|

Independent|

* Microsoft Virtual Server
* Parallels Workstation
* Parallels Desktop for Mac
* Parallels Server for Mac
* PearPC
* QEMU
* VirtualBox
* Virtual Iron
* VMware Fusion
* VMware Player
* VMware Server
* VMware Workstation
* Windows Virtual PC

Tools|

* Ganeti
* oVirt
* System Center Virtual Machine Manager
* Virtual Machine Manager

OS-level
virtualization|

| Full stack|

* Container Linux
* Docker
* iCore Virtual Accounts
* Linux-VServer
* Turbo
* Virtuozzo

|

Backends|

* chroot
* cgroups
* FreeBSD jail
* Linux namespaces
* lmctfy
* LXC
* OpenVZ
* seccomp
* vkernel
* Solaris Containers
* Workload Partitions

Orchestration|

* Amazon ECS
* Kubernetes
* OpenShift

Desktop
virtualization|

* Citrix XenApp
* Citrix XenDesktop
* Remote Desktop Services
* VMware Horizon View
* Ulteo Open Virtual Desktop

Application
virtualization|

* Ceedo
* Citrix XenApp
* Dalvik
* InstallFree
* Microsoft App-V
* Remote Desktop Services
* Symantec Workspace Virtualization
* Turbo
* VMware ThinApp
* ZeroVM

Network
virtualization|

* Distributed Overlay Virtual Ethernet (DOVE)
* NVGRE
* Open vSwitch
* Virtual security switch
* Virtual Extensible LAN (VXLAN)

See also: List of emulators

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Dalvik&oldid=354787"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template