text stringlengths 0 1.99k |
|---|
| v v | |
| classes.dex nativelib.so | |
| | | | |
+---------+----------------+---------+ |
| | |
+---------+----------------+---------+ |
| | | | |
| +----v-----+ +--v--+ | |
| | dexopt | | JNI | | |
| +----+-----+ +-----+ | |
| | | |
| +----v-----+ +----------+ | |
| | app.odex +-----> dalvikvm | | |
| +----------+ +----------+ | |
+------------------------------------+ |
``` |
It's 2014. The Nexus 6 has a processor with not just one but four 2.7GHz |
cores and 3 GB of RAM. Its 32GB of storage allows for much more code to be |
stored, and so the JIT compilation is replaced by a complete Ahead-Of-Time |
(AOT) compilation. ODEX files no longer contain Dalvik code. They contain |
binary code and become OAT (allegedly "of-ahead-time") files. This |
compilation adds another layer of optimizations, a fact that will come back |
in Section 3.4. We will call the binary ODEX files OAT instead of ODEX, but |
they still use the file ending .odex. They are technically ELF shared |
objects with some additional metadata, but they are meant to only run with |
the Android Runtime (ART). It replaces the dalvikvm and can handle oat |
files. |
On the developers' side, the pipeline of javac-to-plugins-to-dx also sees |
changes: Jack and Jill replace the whole stack, unifying compilation and |
optimizations. Android apps are fast(er). |
```txt |
+-------------+ +-------------+ |
| source.java | | library.jar | |
++------------+ ++------------+ |
| | |
| | +------------+ |
| | | source.cpp | |
| | ++-----------+ |
| | | |
+v-----------------v-+ +v-----------+ |
| jack | | NDK | |
| and | | | |
| jill | | | |
+---------+----+-----+ +--+---------+ |
| | |
| | above is accessible to developers |
----------+----------------+----------- |
| | below is running on devices |
| | |
+---------+----------------+---------+ |
| APK | | | |
| v v | |
| classes.dex nativelib.so | |
| | | | |
+---------+----------------+---------+ |
| | |
+---------+----------------+---------+ |
| ART | | | |
| +----v-----+ +--v--+ | |
| | dex2oat | | JNI | | |
| | | +-----+ | |
| | full | +----------+ | |
| | AOT----+-----> app.odex | | |
| | | +----------+ | |
| +----------+ | |
+------------------------------------+ |
``` |
It's 2017. The Xperia XZ1 has eight 2.3GHz cores and 4GB RAM. Lessons were |
learned. First, getting rid of the Java compiler is rolled back and instead |
ProGuard's functionality is included in the R8/D8 compiler suite that |
consumes Java bytecode. Kotlin is added as the preferred language. |
It also turned out that compiling all of an app's code during installation |
can take a while, even with all those cores available. And, of course, all |
apps have to be recompiled after system updates, which eats performance |
like Android codename snacks. JIT is re-introduced, and profile-based |
compilation is added. The compilation profiles track per app which methods |
should be compiled ahead-of time, for example, after a system update. This |
saves resources. |
```txt |
+-------------+ +-------------+ |
| source.java | | library.jar | |
++------------+ ++------------+ |
| | |
| +-----------+ | +------------+ |
| | source.kt | | | source.cpp | |
| ++----------+ | ++-----------+ |
| | | | |
+v--v-----------+ | | |
| javac/kotlinc | | | |
+---------+-----+ | | |
| | | |
+---------v--------v-+ +v-----------+ |
| R8/D8 | | NDK | |
| includes ProGuard | | | |
| shrinking and | | | |
| renaming | | | |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.