Dalvik and art

Source: Internet
Author: User
This entry is missing Information bar, Add relevant content to make the entry more complete. You can also quickly upgrade it. Edit it now! Dalvik is a Java virtual machine designed by Google for the Android platform. Dalvik virtual machine is one of the core components of the Android mobile device platform developed by Google and other vendors. It supports conversion. dex (Dalvik executable) format Java application running ,. dex format is a compression format designed for Dalvik, suitable for systems with limited memory and processor speed. Dalvik is optimized to allow instances of multiple virtual machines to run simultaneously in limited memory, and [1] Each Dalvik application is executed as an independent Linux Process. Independent processes can prevent all programs from being shut down when the Virtual Machine crashes. For a long time, the Dalvik virtual machine has been accused by users of slowing down the Android system. In June 25, 2014, android l will be officially unveiled at the Google I/O conference. Android l will be greatly changed, and Google will directly Delete Dalvik, replacing it with the rumored art. Directory

1. Development and Prospects

? Prospect

2 Architecture

3. Performance

4 class libraries

5 others

1. development and Prospects the birth of Dalvik has also led to concern that the first large-scale split of the Java platform may have taken place-some people have linked davlik with Microsoft's JVM and Sun's lawsuit against Microsoft, wait to see if similar things will happen on Google. others point out that Google did not claim that Dalvik is a Java implementation, but Microsoft did. Sun also expressed concern about the possible camp split and proposed to work with Google to ensure the compatibility between Dalvik and JVM. Google explained that, dalvik is an attempt to solve the current split on the Java me platform. It also aims to provide a platform with fewer restrictions and licenses. Some people may even doubt whether this is a large-scale contest between the Sun and Google camps on the future of Java. Ian skerret believes that the birth of Dalvik is a response to Sun's attempt to control and protect the source of Java me revenue, as well as a delayed response to the establishment of the openjdk Governing Council. This also caused Dalibor topic to doubt whether Google would like to repeat Sun's path: of course, a very interesting question is, why no one has the courage to ask Google about openjdk in turn? Although Android is known as open-source, it is still a proprietary product. Android has provided compatibility assurance and is signed and kept in secret meeting rooms. Android does not have any governance model, and there is no evidence that a governance model will appear in the future. Android has no specification, and its license prohibits any development of alternative implementations, because this is not the right to use Google's license in the SDK license. Android is completely under the control of Google. Once a competitive application financially damages Google's interests, Google reserves the right to erase these applications. At the beginning of the design, Android has been restricted and can only be opened within the conditions permitted by Google's financial interests. The proprietary Java is just a new bottle of wine. This is like we are witnessing the rebirth of JCP, people lined up to lend the "street reputation" of the open-source community to another closed manufacturer monopoly group on the basis of a single and proprietary implementation. But this time the big data name was changed to Google, not sun. (However, when everyone calls open source, it seems that they all forget that developing this series of software requires a huge investment. Therefore, the benefits come first, which is actually understandable .) stefano mazzocchi released an analysis report that explores Java me and Dalvik licenses. He concluded that Dalvik is well positioned in the market, it is enough to bring an impact to the mobile phone market. Although Google has always been careful to avoid several key points of litigation, mazzocchi believes sun will still draft an intellectual property lawsuit (IBM may also ). He also pointed out that Google can change Android very quickly due to operations outside of JCP, sun's more dynamic veto power on any JCP can also be avoided-they can also add interfaces for components such as USB and Bluetooth, which are unavailable in the Basic Java me implementation. Finally, by authorizing the Dalvik source code under the Apache license, the mobile phone operator is more likely to use Dalvik, because the operator can use and modify it without the license fee. In addition, Java is no longer the only language that people choose to develop on Dalvik-Someone has run Scala on Dalvik and hecl has been successfully transplanted. Another attempt was made to run groovy, but so far it has not been very successful. Miguel de Icaza, the founder of the Mono Project, also expressed interest in integrating mono into Dalvik after the Dalvik Source Code was published, and some people have speculated on how to implement integration in multiple ways, includes the common intermediate language (Common intermediate language) to the Dalvik re-compiler similar to the Java-to-Dalvik re-compiler provided with the android SDK. ( DXIs a set of tools that can convert java. class to. Dex format. A Dex file usually has multiple. classes. Because Dex sometimes has to be optimized, it will increase the file size by 1 to 4 times and end with odex .) Dalvik And standards JavaVirtual Machine (JVM) Primary differencesDalvik is based on registers, while JVM is based on stacks. Register-based virtual machines consume less time for programs that increase after compilation. (Also of register-based VMS allow faster execution times at the expense of programs which are larger after compilation .) Dalvik And Java Differences between runtime Environments1: Dalvik is mainly used to complete 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. Each Android Application corresponds to an independent Dalvik Virtual Machine instance at the underlying layer, and its code can be executed under the interpretation of the virtual machine. 3: Unlike Java bytecode running on java virtual machines, the Dalvik virtual machine runs its proprietary file format dex4: Dex file format to reduce the overall file size, improves the speed of Class search for I/O operations. 5: odex is used to further improve the performance of the DEX file during running. 6: All Android Application threads correspond to a Linux thread. Therefore, virtual machines can depend more on the thread scheduling and management mechanism of the operating system. 7. There is a special Virtual Machine Process zygote, it is the incubator for Virtual Machine instances. It is generated when the system is started. It completes VM initialization, Library Loading, pre-made class libraries, and initialization operations. If the system needs a new Virtual Machine instance, it will quickly replicate itself and provide the fastest data to the system. For some read-only system libraries, All VM instances share a memory area with zygote. 8: Dalvik was written by Dan bornstein and its name came from the small fishing village where his ancestor once lived in dalvík. The village is located in eyjafj & ouml; R & ETH; Iceland; for a long time, the Dalvik virtual machine has been accused by users of slowing down Android systems. In June 25, 2014, android l will be officially unveiled at the Google I/O conference. Android l will be greatly changed, and Google will directly Delete Dalvik, replacing it with the rumored art. Because of the emergence of art, Dalvik is destined to become a historical application in the Android system. 2 Architecture
Unlike Java virtual machines with other stack structures, 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 to the alternative instruction set used by the Dalvik virtual machine. An uncompressed. Dex file is usually smaller than the compressed. jar file from the same. Class file. When installed on a mobile device, the Dalvik executable file may be modified. For further optimization, the virtual machine may adjust the end sequence of some data in the file, inline some functions and simple struct, and short-circuit some unnecessary operations.
Since Android 2.2, Dalvik supports JIT (just-in-time, instant compilation technology ).
The optimized Dalvik has some different features than other standard virtual machines.
· Less space occupied
· To simplify 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 are usually from the 4-bit "virtual register" area. This reduces the Dalvik instruction count and increases the translation speed.
When Android is started, the Dalvik VM monitors all programs (APK), creates dependency trees, optimizes code for each program, and stores the code in the Dalvik cache. After the first load, Dalvik will generate a cache file to provide the next fast load, so the first load will be slow.
The Dalvik interpreter uses a pre-calculated goto address, and each instruction accesses the memory on a 64-byte boundary. In this way, you can save the time for querying the table after a command. To enhance the functionality, Dalvik also provides a fast interpreter ). 3. Performance
Stack-based machines and register-based machines who have more advantages have always been a hot topic. Generally, stack-based machines must use commands to load and operate data from the stack. Therefore, more commands are required for register-based machines to achieve the same performance. However, commands on register-based machines must be encoded. Therefore, their commands are usually larger. This difference is mainly caused by the scheduling of operation codes on VM machines. They are often more expensive than other factors, such as timely compilation. However, in 2010, a standard non-graphical performance test on an Oracle (Java technology owner) embedded device showed that Android 2.2 (the original version includes an instant compiler) 2-3 times slower than Java SE embedded devices (both based on Java SE 6. 4 class libraries
The Dalvik Virtual Machine neither supports Java SE nor Java me class libraries (such as Java class, AWT and swing are not supported ). Instead, it uses a self-built class library (a subset of Apache harmony Java ). 5 others License and patentDalvik is released based on Apache license 2.0. Google said Dalvik is an implementation of a clean room, rather than an improvement in the standard Java Runtime Environment, this means that it does not inherit the copyright license restrictions of the standard version or open-source Java Runtime Environment. Oracle and some experts are still discussing this. Oracle, which acquired Sun (Sun Microsystems) in April 2009, obtained a Java patent and sued Google for infringement of its copyright and patent in August 12, 2010. Oracle declares that Google directly and repeatedly infringes on Java's intellectual property rights during Android development. In June 2012, the jury held that Google did not infringe the Oracle patent and the judge held that the Java APIs used by Google had no copyright. Both parties agree to copy 9 lines of copied code for zero USD statutory compensation ). Non-android platformsOn June 23, 2011, myriad group software company announced a new Dalvik Virtual Machine Platform port "alien Dalvik" except android ". Android Runtime
The mechanism of art is different from that of Dalvik. In Dalvik, every time an application runs, bytecode needs to be converted to a machine code through the real-time compiler, which slows down the running efficiency of the application. In the art environment, during the first installation of an application, the bytecode is pre-compiled into a machine code to make it a real local application. This process is called pre-compilation (AOT, ahead-of-time ). In this case, application startup and execution will become faster. Directory

1. Principles

2. Latest message

1. Principles
[1] Compared With iOS, the android user experience has a relatively bad start. For a long time, the interface has been an ugly duckling, and choppy is also a pain point. However, with the full promotion of Google and the response from hardware manufacturers, Android is still growing through various obstacles. In this process, Google is also undergoing significant changes. It gradually changes from a company that only focuses on data to a company that focuses on design and user experience. Since Android 4.0, Android has its own design language and Application Design Guide. At the same time, Google is also working to solve the choppy problem. The "butter program" of Android 4.1 makes the system and applications run smoothly, while the "Project svelte" of Android 4.2 improves memory management, this allows the system to run smoothly on devices with low hardware configurations. However, none of these issues solve the core issue, that is, the application runtime environment. Dalvik VM is not the most efficient. Since Android 4.4, Google developers have introduced the new Android Runtime Environment Art (Android runtime. In the introduction to the official Android page, it is also called a new Virtual Machine) to replace the old Dalvik VM. It is now an experiment option, and the default operating environment of the system is Dalvik. What changes does art bring to Android? The androidpolice website analyzed the issue. Based on some benchmark tests, the new runtime environment can reduce the execution time of most applications by half. This means that applications with high CPU consumption and long running time can be completed more quickly, while general applications can also be smoother, such as smoother animation effects and more instant touch feedback. On a multi-core processor device, you only need to activate a small number of cores or make better use of arm's big. Little architecture. In addition, it will significantly improve the battery endurance and system performance. Pre-compilation also brings some disadvantages. On the one hand, machine code occupies a larger storage space. After the bytecode changes to the machine code, it may increase by 10%-20%. However, in the application package, executable code is often only a part. For example, the latest Google + APK is 28.3 MB, but the code is only 6.9 MB. On the other hand, the installation time of the application will become longer. The extended time depends on the application itself. Some complex applications such as Facebook and Google + will keep you waiting for a longer time. In general, the advantages of art are far beyond its disadvantages. After all, battery life and smooth operation of applications are even more important among the factors that affect user experience. We still don't know when art can replace Dalvik, but the androidpolice website says Google has been secretly developed for two years. Android is just getting rid of choppy hopes. 2. Latest news: November 1, Google released the android 4.4 system. The biggest change in this version is the change in the running mode of applications, that is, the original Dalvik Runtime is abandoned and replaced with the art runtime. Art (Android runtime) is a kind of runtime that enables faster development and higher execution efficiency and saves power. It is the underlying runtime environment for Android systems to survive. In the past, the underlying Android code was run by the Dalvik Java virtual machine. This mechanism is not very efficient and is called a "cancer" of low android running efficiency, but it is precisely because of it, this allows applications to run on different hardware and architectures. Unlike Dalvik, art processes application execution in a more efficient way, consumes less power, and consumes less memory.

Dalvik and art

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.