Pro Android 2. 笔记

Dalvik 与 class files
These issues led Google to revisit the standard JVM implementation in many respects.
(The key figure in Google’s implementation of this JVM is Dan Bornstein, who wrote the
Dalvik VM—Dalvik is the name of a town in Iceland.) First, the Dalvik VM takes the
generated Java class files and combines them into one or more Dalvik Executable (.dex)
files. It reuses duplicate information from multiple class files, effectively reducing the
space requirement (uncompressed) by half from a traditional .jar file. For example, the
.dex file of the web browser app in Android is about 200K, whereas the equivalent
uncompressed .jar version is about 500K. The .dex file of the alarm clock app is about
50K, and roughly twice that size in its . jar version.
===========
Second, Google has fine-tuned the garbage collection in the Dalvik VM, but it has
chosen to omit a just-in-time (JIT) compiler, in early releases. The 2.0 codebase seem to
have the necessary sources for a JIT compiler but is not enabled in the final release
2.2 引入了JIT — 通过某种算法去收集和抽取那些最常用代码(或者是最符合算法需求的),把他们转化成native指令来提供执行效率。
 
==========
Finally, the Dalvik VM uses a different kind of assembly-code generation, in which it uses
registers as the primary units of data storage instead of the stack.
register一般指是CPU的一些存储器,不包括cache。stack是用于程序的函数保存临时变量的内存,如函数调用时保存某些寄存器的值和函数的临时变量(入栈),当函数结束时,将释放掉临时变量,恢复函数调用前的寄存器的值(出栈)。
========================================
This performance paranoia extends into the rest of the Android SDK. For example, the
Android SDK uses XML extensively to define UI layouts. However, all of this XML is
compiled to binary files before these binary files become resident on the devices
.class files   -> .dex    .xml   -> binary files
 
========================================
Most of the application framework accesses these core libraries through the Dalvik VM,
the gateway to the Android Platform. As we indicated in the previous sections, Dalvik is
optimized to run multiple instances of VMs. As Java applications access these core
libraries, each application gets its own VM instance.

reeoo.com - web design inspiration

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注