.odex
   HOME

TheInfoList



OR:

Dalvik is a discontinued
process virtual machine In computing, a virtual machine (VM) is the virtualization or emulation of a computer system. Virtual machines are based on computer architectures and provide the functionality of a physical computer. Their implementations may involve special ...
(VM) in the
Android operating system Android is an operating system based on a modified version of the Linux kernel and other open-source software, designed primarily for touchscreen-based mobile devices such as smartphones and tablets. Android has historically been developed by ...
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 phone A mobile phone or cell phone is a portable telephone that allows users to make and receive calls over a radio frequency link while moving within a designated telephone service area, unlike fixed-location phones ( landline phones). This rad ...
s and
tablet computer A tablet computer, commonly shortened to tablet, is a mobile device, typically with a mobile operating system and touchscreen display processing circuitry, and a rechargeable battery in a single, thin and flat package. Tablets, being computers ...
s, and more in some devices such as
smart TV A smart TV, also known as a connected TV (CTV or, rarely, CoTV), is a traditional television set with integrated Internet and interactive Web 2.0 features that allow users to stream music and videos, browse the internet, and view photos. Smart T ...
s and
wearables A wearable computer, also known as a body-borne computer, is a computing device worn on the body. The definition of 'wearable computer' may be narrow or broad, extending to smartphones or even ordinary wristwatches. Wearables may be for general ...
. Dalvik is
open-source software Open-source software (OSS) is Software, computer software that is released under a Open-source license, license in which the copyright holder grants users the rights to use, study, change, and Software distribution, distribute the software an ...
, originally written by Dan Bornstein, who named it after the fishing village of
Dalvík Dalvík () is the main village of the Icelandic municipality of Dalvíkurbyggð. Its population is approximately 1,400.
in
Eyjafjörður Eyjafjörður (, ''Island Fjord'') is one of the longest fjords in Iceland. It is located in the central north of the country. Situated by the fjord is the country's fourth most populous municipality, Akureyri. Physical geography The fjord is ...
,
Iceland Iceland is a Nordic countries, Nordic island country between the Atlantic Ocean, North Atlantic and Arctic Oceans, on the Mid-Atlantic Ridge between North America and Europe. It is culturally and politically linked with Europe and is the regi ...
. Programs for Android are commonly written in
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
and compiled to
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
for the
Java Virtual Machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally descr ...
, 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 Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembe ...
and processor speed. The successor of Dalvik is
Android Runtime Android Runtime (ART) is an application runtime environment used by the Android operating system. Replacing Dalvik, the process virtual machine originally used by Android, ART performs the translation of some of the application's bytecode i ...
(ART), which uses the same bytecode and .dex files (but not .odex files), with the succession aiming at performance improvements. The new runtime environment was included for the first time in Android 4.4 "KitKat" as a
technology preview The software release life cycle is the process of developing, testing, and distributing a software product (e.g., an operating system). It typically consists of several stages, such as pre-alpha, alpha, beta, and release candidate, before the fi ...
, and replaced Dalvik entirely in later versions; Android 5.0 "Lollipop" is the first version in which ART is the only included runtime.


History

Dalvik, named after a town in Iceland by its creator Dan Bornstein, was designed for embedded devices with very low RAM and CPU to run Java code, and eventually support
C++ C++ (, pronounced "C plus plus" and sometimes abbreviated as CPP or CXX) is a high-level, general-purpose programming language created by Danish computer scientist Bjarne Stroustrup. First released in 1985 as an extension of the C programmin ...
for "heavy-duty apps" and
JavaScript JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior. Web browsers have ...
for "light-weight widget-like apps" as first-class languages with Java catering to the rest.
Android Native Development Kit The Android Native Development Kit (NDK) provides a cross-compiling tool for compiling code written in C/ C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) for Android. The NDK uses the Clang compiler to compile C/C++. ...
which eventually paved way for C++ support has existed since Dalvik's first public release. According to Bornstein, Memory-mapping executables and libraries across multiple process and building a faster interpreter with register-based semantics drove much of the early design of the byte-aligned instruction set and the Virtual Machine. Experience working with
J2ME Java Platform, Micro Edition or Java ME is a computing platform for development and deployment of porting, portable code for embedded system, embedded and mobile devices (micro-controllers, sensors, gateways, mobile phones, personal digita ...
on
Sidekick A sidekick is a close companion or colleague who is, or is generally regarded as, subordinate to those whom they accompany. Origins The first recorded use of the term dates from 1896. It is believed to have originated in pickpocket slang of ...
at
Danger Danger is a lack of safety and may refer Places * Danger Cave, an archaeological site in Utah * Danger Island, Great Chagos Bank, Indian Ocean * Danger Island, alternate name of Pukapuka Atoll in the Cook Islands, Pacific Ocean * Danger Island ...
, Bornstein found it was too stripped down and fairly constrained for Android. While improvements such as
Isolates Isolates is a term used in developmental psychology and family studies to describe members of a study group, usually children through young adults, who do not actively participate in cliques or friendship groups. Isolates are one of four types of ...
as then planned by
Sun The Sun is the star at the centre of the Solar System. It is a massive, nearly perfect sphere of hot plasma, heated to incandescence by nuclear fusion reactions in its core, radiating the energy from its surface mainly as visible light a ...
made
process isolation Process isolation is a set of different hardware and software technologies designed to protect each process from other processes on the operating system. It does so by preventing process A from writing to process B. Process isolation can be implem ...
infeasible as it broke Android's intra-Device security model. For Dalvik VM, Bornstein particularly took inspiration from The Case for Register Machines authored by Brian Davis et al of
Trinity College Trinity College may refer to: Australia * Trinity Anglican College, an Anglican coeducational primary and secondary school in , New South Wales * Trinity Catholic College, Auburn, a coeducational school in the inner-western suburbs of Sydney, New ...
, Dublin. Dalvik was open sourced under
Apache License v2 The Apache License is a permissive free software license written by the Apache Software Foundation (ASF). It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software u ...
as rest of the
Android Open Source Project Android is an operating system based on a modified version of the Linux kernel and other open-source software, designed primarily for touchscreen-based mobile devices such as smartphones and tablets. Android has historically been developed by ...
in 2008.


Architecture

Unlike
Java Virtual Machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally descr ...
s, which are
stack machine In computer science, computer engineering and programming language implementations, a stack machine is a computer processor or a Virtual machine#Process virtual machines, process virtual machine in which the primary interaction is moving short- ...
s, 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 An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API), compiled to Java bytecode, and converted to Dalvik instructions as necessary. A tool called dx is used to convert Java
.class A Java class file is a file (with the filename extension) containing Java bytecode that can be executed on the Java Virtual Machine (JVM). A Java class file is usually produced by a Java compiler from Java programming language source files ( ...
files into the .dex format. Multiple classes are included in a single .dex file. Duplicate
strings String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
and other constants used in multiple class files are included only once in the .dex output to conserve space. Java
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
is also converted into an alternative
instruction set In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, s ...
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. The Dalvik executables may be modified again when installed onto a mobile device. In order to gain further optimizations,
byte order '' Jonathan_Swift.html" ;"title="Gulliver's Travels'' by Jonathan Swift">Gulliver's Travels'' by Jonathan Swift, the novel from which the term was coined In computing, endianness is the order in which bytes within a word (data type), word of d ...
may be swapped in certain data, simple
data structure In computer science, a data structure is a data organization and storage format that is usually chosen for Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the relationships amo ...
s and
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-orie ...
libraries A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
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: * The VM was slimmed down to use less space. * The
constant pool A Java class file is a file (with the filename extension) containing Java bytecode that can be executed on the Java Virtual Machine (JVM). A Java class file is usually produced by a Java compiler from Java programming language source files ( f ...
has been modified to use only
32-bit In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in a maximum of 32- bit units. Compared to smaller bit widths, 32-bit computers can perform la ...
indices to simplify the
interpreter Interpreting is translation from a spoken or signed language into another language, usually in real time to facilitate live communication. It is distinguished from the translation of a written text, which can be more deliberative and make use o ...
. * Standard
Java bytecode Java bytecode is the instruction set of the Java virtual machine (JVM), the language to which Java and other JVM-compatible source code is compiled. Each instruction is represented by a single byte, hence the name bytecode, making it a compact ...
executes
8-bit In computer architecture, 8-bit integers or other data units are those that are 8 bits wide (1 octet). Also, 8-bit central processing unit (CPU) and arithmetic logic unit (ALU) architectures are those that are based on registers or data bu ...
stack instructions. Local variables must be copied to or from the operand stack by separate instructions. Dalvik instead uses its own
16-bit 16-bit microcomputers are microcomputers that use 16-bit microprocessors. A 16-bit register can store 216 different values. The range of integer values that can be stored in 16 bits depends on the integer representation used. With the two ...
instruction set that works directly on local variables. The local variable is commonly picked by a
4-bit 4-bit computing is the use of computer architectures in which integer (computer science), integers and other data (computer science), data units are 4 bits wide. 4-bit central processing unit (CPU) and arithmetic logic unit (ALU) architectures a ...
"virtual register" field. This lowers Dalvik's instruction count and raises its interpreter speed. The design of Dalvik permits a device to run multiple instances of the VM efficiently. 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 In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
frequently executed short segments of their bytecode into native
machine code In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
. While Dalvik interprets the rest of application's bytecode, native execution of those short bytecode segments, called "traces", provides significant performance improvements. The potential trace heads are identified in the front-end of the compiler at the parsing stage and after the bytecode conversion. A translation cache is maintained during the runtime. Multiple traces can be chained to reduce synchronisation between the compiler and the interpreter. The trace is optimized by converting it into the Single Static Assignment form, enabling optimizations like dead store elimination, variable folding, and inlining getters and setters.


Performance

The relative merits of
stack machine In computer science, computer engineering and programming language implementations, a stack machine is a computer processor or a Virtual machine#Process virtual machines, process virtual machine in which the primary interaction is moving short- ...
s versus
register Register or registration may refer to: Arts, entertainment, and media Music * Register (music), the relative "height" or range of a note, melody, part, instrument, etc. * ''Register'', a 2017 album by Travis Miller * Registration (organ), ...
-based approaches are a subject of ongoing debate. 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 In computing, an opcode (abbreviated from operation code) is an enumerated value that specifies the operation to be performed. Opcodes are employed in hardware devices such as arithmetic logic units (ALUs), central processing units (CPUs), and ...
dispatch tends to be expensive, along with other factors similarly relevant to
just-in-time compilation In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations) is compilation (of computer code) during execution of a program (at run time) rather than before execution. This may consist of source code transl ...
. Tests performed on
ARMv7 ARM (stylised in lowercase as arm, formerly an acronym for Advanced RISC Machines and originally Acorn RISC Machine) is a family of reduced instruction set computer, RISC instruction set architectures (ISAs) for central processing unit, com ...
devices in 2010 by
Oracle An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
(owner of the Java technology) with standard non-graphical Java benchmarks showed the
HotSpot Hotspot, Hot Spot or Hot spot may refer to: Places * Hot Spot, Kentucky, a community in the United States Arts, entertainment, and media Fictional entities * Hot Spot (comics), a name for the DC Comics character Isaiah Crockett * Hot Spot (Tr ...
VM of Java SE embedded to be 2–3 times faster than the
JIT Jit (also known as jiti, jit-jive and the Harare beat) is a style of popular Zimbabwean dance music. It features a swift rhythm played on drums and accompanied by a guitar. Jit evolved out many diverse influences, including domestic chimurenga, ...
-based Dalvik VM of Android 2.2 (the initial Android release that included a JIT compiler). In 2012, academic benchmarks confirmed the factor of 3 between
HotSpot Hotspot, Hot Spot or Hot spot may refer to: Places * Hot Spot, Kentucky, a community in the United States Arts, entertainment, and media Fictional entities * Hot Spot (comics), a name for the DC Comics character Isaiah Crockett * Hot Spot (Tr ...
and Dalvik on the same Android board, also noting that Dalvik code was not smaller than Hotspot. Furthermore, , 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. Upon running benchmarks using the early interpreter of 2009, both
Java Native Interface The Java Native Interface (JNI) is a foreign function interface programming framework that enables Java code running in a Java virtual machine (JVM) to call and be called by native applications (programs specific to a hardware and operating s ...
(JNI) and native code showed an order of magnitude speedup.


Licensing and patents

Dalvik is published under the terms of the
Apache License The Apache License is a permissive free software license written by the Apache Software Foundation (ASF). It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software ...
2.0. Some say 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 An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
and some reviewers dispute this. On August 12, 2010,
Oracle An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
, which acquired
Sun Microsystems Sun Microsystems, Inc., often known as Sun for short, was an American technology company that existed from 1982 to 2010 which developed and sold computers, computer components, software, and information technology services. Sun contributed sig ...
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. 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. The parties agreed to zero dollars in
statutory damages Statutory damages are a damage award in civil law, in which the amount awarded is stipulated within the statute rather than being calculated based on the degree of harm to the plaintiff. Lawmakers will provide for statutory damages for acts in w ...
for 9 lines of copied code.


See also

*
Android Runtime Android Runtime (ART) is an application runtime environment used by the Android operating system. Replacing Dalvik, the process virtual machine originally used by Android, ART performs the translation of some of the application's bytecode i ...
*
Android software development Android software development is the process by which applications are created for devices running the Android mobile operating system. Google states that "Android apps can be written using Kotlin, Java, and C++ languages" using the Android ...
*
Application virtualization Application virtualization is a software technology that encapsulates computer programs from the underlying operating system on which they are executed. A fully virtualized application is not installed in the traditional sense, although it is sti ...
*
Comparison of application virtualization software Application virtualization software refers to both application virtual machines and software responsible for implementing them. Application virtual machines are typically used to allow application bytecode to run portably on many different comput ...
*
Comparison of Java and Android API This article compares the application programming interfaces (APIs) and virtual machines (VMs) of the programming language Java and operating system Android. While most Android applications are written in Java-like language, there are some diff ...
*
JEB decompiler JEB is a disassembler and decompiler software for Android applications and native machine code. It decompiles Dalvik bytecode to Java source code, and x86, ARM, MIPS, RISC-V machine code to C source code. The assembly and source outputs are ...
– a Dalvik (DEX and APK) decompiler *
Dalvik Turbo virtual machine Dalvik Turbo was created as a proprietary compatibility layer alternative to Google's implementation of the Dalvik virtual machine that runs on the Android operating system and other platforms. It was originally developed by French/Swiss firm M ...
– a proprietary alternative Dalvik implementation


References


External links


Dalvik bytecode
– official Android documentation of the
instruction set In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, s ...

Dex Executable format
– official Android documentation * , 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?
!--not sure where this title came from: "Oracle v Google Copyright Claims Decompiled"--> {{DEFAULTSORT:Dalvik (Software) Android (operating system) Discontinued Java virtual machines Register-based virtual machines Bytecodes