Dalvik is a Java virtual machine designed by Google to be used on Android platforms. Dalvik virtual Machine is one of the core components of Android mobile device platform developed by Google and other manufacturers. It can support the operation of a Java application that has been converted to. Dex (that is, Dalvik executable) format, which is a compression format designed for Dalvik and is suitable for systems with limited memory and processor speed. Dalvik is optimized to allow instances of multiple virtual machines to run concurrently in limited memory, and [1] each Dalvik application executes as a standalone Linux process. A standalone process can prevent all programs from shutting down when the virtual machine crashes. For a long time, Dalvik virtual machines have been blamed by users for slowing down the Android system at a slower pace than the source of iOS. June 25, 2014, Android L will be officially unveiled in the holding of the Google I/O Conference, Android L change a large margin, Google will directly delete Dalvik, instead of it is the long-rumored art. (
DXis a set of tools that convert Java. class to. dex format. A DEX file usually has more than one. Class. Because Dex sometimes has to be optimized, it increases the file size by 1-4 times, ending with Odex. )
Dalvik
and Standard
JavaVirtual machines
(JVM)
The first differenceThe Dalvik is based on a register, and the JVM is stack-based. Register-based VMS are less time-consuming when they are executed, for programs that become larger after compilation. (Also of register-based VMs allow faster execution times at the expense of programs which is larger after compilation.)
Dalvik
and the
Java
the difference between the operating environment1:dalvik mainly includes the completion of object lifecycle management, stack management, thread management, security and exception management, as well as garbage collection and other important functions. 2:dalvik is responsible for process isolation and thread management, and each Android application will have a standalone Dalvik virtual machine instance at the bottom, and its code can be executed under the virtual machine interpretation. 3: Unlike Java Virtual machine running Java bytecode, Dalvik virtual machine is running its proprietary file format Dex4:dex file format can reduce overall file size and improve the class lookup speed of I/O operations. The 5:odex is designed to further improve performance during operation and further optimize the Dex file. 6: All Android application threads correspond to a Linux thread, and virtual machines can therefore rely more on the operating system's thread scheduling and management mechanism 7: There is a special virtual machine process zygote, which is the incubator for virtual machine instances. It will be generated when the system starts, it will complete the initialization of the virtual machine, library loading, prefabricated class library and initialization operations. If the system needs a new instance of the virtual machine, it will quickly replicate itself and provide the system with the fastest data. For some read-only system libraries, all virtual machine instances share a memory area with zygote. 8:dalvik was written by Dan Bornstein, whose ancestors had lived in a small fishing village called Dalvík, which was located in Iceland.
ArchitectureUnlike other stack-structured Java virtual machines, Dalvik uses a register-based architecture. The DX tool converts some, but not all, Java. class files into. dex format. Multiple classes are included in a. dex file. To save space, repeated strings and other constants in each class file are stored only once in the. Dex output. The Java bytecode is converted into an alternate instruction set used by the Dalvik virtual machine. An uncompressed. dex file is usually smaller than the compressed. jar document from the same. class file. The Dalvik executable may be modified when it is installed on a mobile device. For further optimization, the virtual machine may adjust the end sequence of some data in the file, inline some functions and simple structure, and short out some unnecessary operations.
Starting with Android 2.2, Dalvik supports JIT (Just-in-time, instant-compile technology).
Optimized Dalvik has some different features than other standard virtual machines
• Takes up less space
• For simplified translation, the constant pool uses only 32-bit indexes
• Standard Java bytecode implements 8-bit stack instructions. Dalvik uses a 16-bit instruction set to directly act on local variables. Local variables typically come from a 4-bit "virtual register" area. This reduces the Dalvik instruction count and improves the translation speed.
When Android starts, the Dalvik VM monitors All Programs (APK) and creates a dependency tree, optimizes the code for each program and stores it in the Dalvik cache. Dalvik The cache file is generated the first time it is loaded to provide the next quick load, so the first time is slow.
The Dalvik interpreter uses a pre-calculated goto address, and each instruction accesses the memory on a 64-byte boundary. This saves a command after the time to look up the table. For enhanced functionality, the Dalvik also provides a fast translator (fast interpreter).
PerformanceStack-based machines and register-based machines who have the advantage has always been a vexed topic. In general, stack-based machines must use instructions to load and manipulate data from the stack, so they require more instructions to achieve the same performance than register-based machines. But the instructions on the register-based machine must be encoded, so their instructions tend to be larger. This difference is mainly caused by the operation code scheduling of VM pairs, which are often more expensive than other factors, such as compiling in time. However, in 2010, standard non-graphical performance tests on embedded devices at Oracle Corporation (owner of Java Technology) showed that Android 2.2 (the original version includes an instant compiler) is 2-3 times slower than the Java SE Embedded device (both based on Java SE 6).
ArchitectureThe Dalvik virtual machine does not support either Java SE or Java me libraries (e.g. Java classes, neither AWT nor swing support). Instead, it uses its own built-in class library (a subset of Apache Harmony Java).
Licensing and PatentsDalvik is based on the Apache License 2.0 release. Google says Dalvik is an implementation of a clean room, not an improvement in the standard Java operating environment, meaning it does not inherit the copyright license restrictions of the standard version or open source Java Runtime environment. Oracle and some experts are still in the discussion about this. Oracle, which acquired Sun Microsystems in April 2009, was patented by Java and sued Google on August 12, 2010 for infringing its copyrights and patents. Oracle claims that Google has directly and repeatedly violated the intellectual property rights of Java in the development of Android. In 20,125 months, the jury found that Google did not infringe on Oracle's patents, and the judge found that the Java APIs used by Google were not copyrighted. The parties agree to a $0 legal compensation of 9 lines of copy code (9 lines of copied code).
Non-Android platformsIn 2011, Myriad Group Software announced a new Dalvik virtual machine platform port "Alien Dalvik" other than Android.
Android Development Learn--dalvik