SlideShare a Scribd company logo
1 of 42
Download to read offline
Dalvik is Dead, Long Live Dalvik! 
LCU14-September 2014 
Stuart Monteith 
Systems & Software
Outline 
▪What is Dalvik™? 
▪Porting Dalvik onto AArch64 
▪ART 
▪Working on AOSP1 
▪Q&A 
2 
1 - Android™ Open Source Project
What is Dalvik™? 
3 
?
Android™ & Dalvik™ 
4 
Applications 
Application Framework 
Libraries 
Kernel 
Android™ Runtime 
Core Libraries 
Dalvik VM 
Bionic 
SSL 
…
What is Dalvik™? 
▪ Dalvik is a virtual machine 
▪ A managed runtime 
▪ Interpreter 
▪ Executes Java™ class files translated into 
Dalvik “dex” bytecode 
▪ Exception handling 
▪ Object oriented 
▪ References rather than pointers 
▪ Garbage collection 
▪ Concurrency 
▪ Platform independence 
5 
Native 
Code 
Interpreter 
Heap 
OS 
Bytecode
Compiling for Dalvik 
*.java 
javac 
*.class 
Development Installation 
/data/dalvik-cache/ 
*.dex *.apk *.odex 
6 
dx 
dexopt
Devices 
7 
Phone `08 Phone `14 Tablet `10 Tablet `14 
Relative to Phone in 2008 
30 
22.5 
15 
7.5 
0 
CPU RAM Pixels
Dalvik Evolution 
▪ Just-In-Time (JIT) Compiler - Android™ 2.2 “Froyo”, May 2010 
▪ Concurrent Garbage collection - Android 2.3 “Gingerbread”, December 2010 
▪ SMP1 support - Android 3.0 “Honeycomb”, February 2011 
8 
1 - Symmetric MultiProcessing
Tracing JIT 
▪ Just-In-Time Compiler 
▪ Compiles code at runtime 
▪ Only code that is executed is compiled 
▪ Only “Hot code” is compiled 
▪ Interpreter executes bytecode instruction by instruction 
▪ Profiles code 
▪ Sends linear sequences of code to JIT 
▪ Native code branched to from interpreter 
▪ However… 
▪ Code produced is not ideal 
▪ Still, 5x faster than interpreter alone 
9
Traces 
10 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025
Traces 
11 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025 
0000: const-wide/16 v0, 0 
0002: const/4 v2, #int 0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d
Traces 
12 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
: : : : : :! 
0017: const-wide/high16 v7, #long! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b!
Traces 
0026: add-int/lit8 v2, 
v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025! 
0005: if-ge v6, v13, 001d 
13 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025
Traces 
14 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025 
07:! 
T0! 
1b:
Traces 
15 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025 
07:! 
T0! 
1b: 
26:! 
T1! 
05: 
1d: 
1d:
Traces 
16 
0000: const-wide/16 v0, #int 0 // #0! 
0002: const/4 v2, #int 0 // #0! 
0003: move v6, v2! 
0004: move-wide v2, v0! 
0005: if-ge v6, v13, 001d // +0018! 
0007: mul-double v4, v2, v2! 
0009: mul-double v7, v0, v0! 
000b: sub-double/2addr v4, v7! 
000c: add-double/2addr v4, v9! 
000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 
000f: mul-double/2addr v2, v7! 
0010: mul-double/2addr v0, v2! 
0011: add-double/2addr v0, v11! 
0012: mul-double v2, v4, v4! 
0014: mul-double v7, v0, v0! 
0016: add-double/2addr v2, v7! 
0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 
0019: cmpl-double v2, v2, v7! 
001b: if-lez v2, 0026 // +000b! 
001d: sget v0, LMandle;.threshold:I // field@0001! 
001f: int-to-double v0, v0! 
0020: int-to-double v2, v13! 
0021: div-double/2addr v0, v2! 
0022: int-to-double v2, v6! 
0023: mul-double/2addr v0, v2! 
0024: double-to-int v0, v0! 
0025: return v0! 
0026: add-int/lit8 v2, v6, #int 1 // #01! 
0028: move v6, v2! 
0029: move-wide v2, v4! 
002a: goto 0005 // -0025 
07:! 
T0! 
1b: 
26:! 
T1! 
05: 
1d:! 
T2! 
25: 
00:! 
T3! 
05:
Garbage Collection 
17 
Thread! 
Stack 
A 
B 
C 
D 
E 
F
Garbage Collection (Mark) 
18 
Thread! 
Stack 
A 
B 
C 
D 
E 
F
Garbage Collection (Sweep) 
19 
Thread! 
Stack 
A 
B 
C 
D 
E 
F 
X 
X
Porting Dalvik™ onto AArch64 
20
ARM’s AArch64 Porting effort 
▪ Model, kernel, bionic and shell below 
▪ LCU14-411 From zero to booting Nano-Android 
▪ Not just a recompile! 
▪ Dalvik™ VM implementation 
▪ Portable C interpreter, garbage collection, class loading, JNI 
▪ Compressed references 
▪ Java™ core libraries - platform/libcore: 
▪ java.* classes 
▪ int always 32-bit, long always 64-bit 
▪ Java: int pointer; ➤ long pointer;! 
▪ C: jint pointer; ➤ jlong pointer;! 
▪ pointer = (jlong)(void*) nativeStructure;! 
▪ Build system 
21
ARM’s AArch64 Porting effort (2) 
▪ Then: 
▪ AArch64 assembler interpreter 
▪ Slightly before with VIXL 
▪ VIXL - library for simulating, assembling and disassembling ARMv8 A64 
instructions. 
▪ Just-In-Time compiler 
▪ The rest of the Android™libraries 
▪ End result - Android with only 64-bit binaries 
▪ Initially 64-bit Dalvik™ running on host in November 2012 
▪ On ARM’s ARMv8 models on command line in February 2013 
▪ Then AOSP on models from July 2013 
22
Dalvik is Dead, Long Live ART! 
▪ After porting AOSP to AArch64 - ART came along in October 2013 
▪ Not all was lost: 
▪ Able to boot AOSP from July 2013 (4.2/4.3) through to 4.4 on Dalvik™ for 
AArch64 
▪ Demonstrated AOSP on Juno 2014 
23
ART - Android™ Runtime 
24
ART 
▪ Introduced October 2013 as experimental runtime in Android™ 4.4 “KitKat” 
▪ First release in Android “L” 
▪ Less lag, more performance 
▪ Productised through 2014 
▪ ART also introduces 64-bit support into Android 
▪ ARM contributed compiler backend components from Dalvik for AArch64 
▪ + JNI compiler, glue, fixes, performance features/tweaks 
25
Unchanged 
▪ Dalvik™ Virtual Machine 
▪ Java™ applications as before 
▪ Garbage collection, class loading, object references, all as before 
▪ It is not translating programs into C/C++ 
▪ Native code works as before (Java Native Interface - JNI) 
▪ Eclipse + ADT or Android Studio, NDK are essentially unchanged 
▪ Targeting the same platform - Android 
▪ Debugging 
▪ dalvikvm! 
▪ Zygote 
▪ app_process - Android’s command for starting VMs. 
26
Changed 
▪ Garbage collection + allocation 
▪ Parallel, less pauses 
▪ C++ Interpreter 
▪ Ahead-of-time compilation (AOT) 
▪ Support for 64-bit execution 
▪ Diagnostics 
▪ Stricter JNI 
▪ Stricter bytecode verification 
27
Initialization 
▪ No JITing during startup 
▪ Compilation time spent at installation 
▪ boot.art: 
▪ Part of the heap stored on flash 
▪ Built as part of firmware image 
▪ Pre-initialized VM heap 
▪ ~12 MB on AOSP 
▪ Zygote as before 
▪ Initialize 
▪ Wait for binder request to fork new apps 
28
Threads 
▪ Stacks now unified - each thread has one stack each 
▪ Original Dalvik™ implementation had separately allocated VM stack 
▪ ART has VM, interpreted, compiler and JNI frames all on same stack 
▪ Stack characteristics may be different 
▪ Stack overflow + null pointer exceptions detected through fault handlers 
▪ Trap and handle 
▪ Thread local allocation 
▪ Threads can allocate objects without getting global heap lock 
29
Garbage Collection 
▪ More pluggable 
▪ Provisions in runtime for different GC schemes 
▪ Parallel & Concurrent 
▪ More threads doing the work 
▪ Background collection 
▪ More throughput, less responsive 
▪ Mark & Sweep, semi-space, large objects, variations 
30
64-bit Support 
▪ Two Zygotes, one 32-bit , one 64-bit 
▪ 64-bit is the default 
▪ Files duplicated on flash - 32/64-bit. 
▪ Compressed references 
▪ 32-bit object references 
▪ Mapped within bottom 4 GB of memory 
▪ Heap size: 256 MB 
▪ Hard-float ABI 
▪ Parameters passed in floating-point registers 
▪ JNI 64-bit libraries 
▪ Apps with 32-bit JNI run by 32-bit Zygote 
31 
Zygote32 Zygote64 
fork() 
32 bit App 64 bit App 
32-bit App 64-bit App
Compiling for ART 
*.java 
javac 
*.class 
Development Installation 
/data/dalvik-cache/arm! 
*.dex *.apk *.odex 
32 
dx 
dex2oat 
or! 
/data/dalvik-cache/arm64
Compilation 
▪ Compiler driver 
▪ Portable compiler 
▪ Sea of nodes IR 
▪ Quick compiler 
▪ Optimising compiler 
▪ More platform independent code 
▪ ARM, MIPS & x86 with 64-bit variants 
▪ Performed at install time 
▪ Compiler compiles with multiple threads in parallel 
▪ Good code quality without onerous compile time 
33
Working on AOSP 
34
Working on AOSP 
▪ Google working in the open with ART in AOSP 
▪ ARM, MIPS, Intel & ARM partners contribute 
▪ 64-bit porting work has been a proving ground for this approach 
▪ Ideas are nice, but code is better 
▪ Understand who is doing what 
▪ Check, post to the Google groups (see android-platform, etc.) 
▪ Important to test on more than just ARM platforms - check MIPS & x86 
▪ Frequently unstable: reversions, build system restructuring 
▪ Android is big, and components have interdependencies 
35
Working on AOSP 
▪ AOSP’s gerrit has useful features 
▪ Use it to track new changes in projects through email 
▪ Volume can be high - can filter on git fields 
▪ esp. if you are working on a particular feature 
▪ Keep a working branch - pull it forward as quickly as possible though 
▪ Use and add to the unit tests 
▪ art # mma test-art 
36
Thank You 
The trademarks featured in this presentation are registered and/or unregistered trademarks of ARM Limited (or its 
subsidiaries) in the EU and/or elsewhere. All rights reserved. Any other marks featured may be trademarks of their 
respective owners 
37
Sessions 
▪ Today: 
▪ LCU14-104: Everything’s Done! Android™ for 64-bit ARMv8, What’s next? 
◦ Next in this room 
▪ LCU14-108: Panel: Faster, Better and more Open AOSP Support 
◦ 12:10, this room 
▪ Wednesday: 
▪ LCU14-309: Introducing Android NDK for 64bit ARMv8 SOCs 
◦ 12:10 Grand Peninsula A 
▪ Thursday: 
▪ LCU14-411: From zero to booting Nano-Android with 64bit support 
◦ 12:10 Grand Peninsula C 
▪ Friday 
▪ LCU14-502: Android User-Space Tests: Multimedia codec tests, Status and Open Discussions 
◦ 09:15 Grand Peninsula B 
38
References 
▪ Introducing ART: https://source.android.com/devices/tech/dalvik/art.html 
▪ ART compatibility: https://developer.android.com/guide/practices/verifying-apps-art.html 
▪ Google I/O 2014, The ART Runtime: https://www.youtube.com/watch?v=EBlTzQsUoOw 
▪ VIXL: https://github.com/armvixl/vixl 
▪ ARM Juno: http://www.arm.com/products/tools/development-boards/versatile-express/ 
juno-arm-development-platform.php 
▪ AOSP Gerrit: https://android-review.googlesource.com/ 
▪ Linaro's Android team: https://wiki.linaro.org/Platform/Android 
▪ Bug Reports: https://source.android.com/source/report-bugs.html 
▪ ARM Connected Community: http://community.arm.com/groups/android-community 
▪ ARMv8 Reference Manual: http://infocenter.arm.com/help/index.jsp?topic=/ 
com.arm.doc.ddi0487a.c/index.html 
39
Notices 
! 
▪ The Android™ robot is reproduced or modified from work created and shared by Google and 
used according to terms described in the Creative Commons 3.0 Attribution License. 
40
Backup slides 
41
Multi-lib: A 64bit 'primary' boot 
42 
6 CONFIDENTIAL

More Related Content

More from Linaro

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Linaro
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
Linaro
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
Linaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
Linaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
Linaro
 

More from Linaro (20)

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
 
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta VekariaArm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
 
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua MoraHuawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
 
Bud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qaBud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qa
 
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
 
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 

LCU14 100-dalvik is dead long live dalvik

  • 1. Dalvik is Dead, Long Live Dalvik! LCU14-September 2014 Stuart Monteith Systems & Software
  • 2. Outline ▪What is Dalvik™? ▪Porting Dalvik onto AArch64 ▪ART ▪Working on AOSP1 ▪Q&A 2 1 - Android™ Open Source Project
  • 4. Android™ & Dalvik™ 4 Applications Application Framework Libraries Kernel Android™ Runtime Core Libraries Dalvik VM Bionic SSL …
  • 5. What is Dalvik™? ▪ Dalvik is a virtual machine ▪ A managed runtime ▪ Interpreter ▪ Executes Java™ class files translated into Dalvik “dex” bytecode ▪ Exception handling ▪ Object oriented ▪ References rather than pointers ▪ Garbage collection ▪ Concurrency ▪ Platform independence 5 Native Code Interpreter Heap OS Bytecode
  • 6. Compiling for Dalvik *.java javac *.class Development Installation /data/dalvik-cache/ *.dex *.apk *.odex 6 dx dexopt
  • 7. Devices 7 Phone `08 Phone `14 Tablet `10 Tablet `14 Relative to Phone in 2008 30 22.5 15 7.5 0 CPU RAM Pixels
  • 8. Dalvik Evolution ▪ Just-In-Time (JIT) Compiler - Android™ 2.2 “Froyo”, May 2010 ▪ Concurrent Garbage collection - Android 2.3 “Gingerbread”, December 2010 ▪ SMP1 support - Android 3.0 “Honeycomb”, February 2011 8 1 - Symmetric MultiProcessing
  • 9. Tracing JIT ▪ Just-In-Time Compiler ▪ Compiles code at runtime ▪ Only code that is executed is compiled ▪ Only “Hot code” is compiled ▪ Interpreter executes bytecode instruction by instruction ▪ Profiles code ▪ Sends linear sequences of code to JIT ▪ Native code branched to from interpreter ▪ However… ▪ Code produced is not ideal ▪ Still, 5x faster than interpreter alone 9
  • 10. Traces 10 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025
  • 11. Traces 11 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025 0000: const-wide/16 v0, 0 0002: const/4 v2, #int 0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d
  • 12. Traces 12 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! : : : : : :! 0017: const-wide/high16 v7, #long! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b!
  • 13. Traces 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025! 0005: if-ge v6, v13, 001d 13 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025
  • 14. Traces 14 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025 07:! T0! 1b:
  • 15. Traces 15 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025 07:! T0! 1b: 26:! T1! 05: 1d: 1d:
  • 16. Traces 16 0000: const-wide/16 v0, #int 0 // #0! 0002: const/4 v2, #int 0 // #0! 0003: move v6, v2! 0004: move-wide v2, v0! 0005: if-ge v6, v13, 001d // +0018! 0007: mul-double v4, v2, v2! 0009: mul-double v7, v0, v0! 000b: sub-double/2addr v4, v7! 000c: add-double/2addr v4, v9! 000d: const-wide/high16 v7, #long 4611686018427387904 // #4000! 000f: mul-double/2addr v2, v7! 0010: mul-double/2addr v0, v2! 0011: add-double/2addr v0, v11! 0012: mul-double v2, v4, v4! 0014: mul-double v7, v0, v0! 0016: add-double/2addr v2, v7! 0017: const-wide/high16 v7, #long 4616189618054758400 // #4010! 0019: cmpl-double v2, v2, v7! 001b: if-lez v2, 0026 // +000b! 001d: sget v0, LMandle;.threshold:I // field@0001! 001f: int-to-double v0, v0! 0020: int-to-double v2, v13! 0021: div-double/2addr v0, v2! 0022: int-to-double v2, v6! 0023: mul-double/2addr v0, v2! 0024: double-to-int v0, v0! 0025: return v0! 0026: add-int/lit8 v2, v6, #int 1 // #01! 0028: move v6, v2! 0029: move-wide v2, v4! 002a: goto 0005 // -0025 07:! T0! 1b: 26:! T1! 05: 1d:! T2! 25: 00:! T3! 05:
  • 17. Garbage Collection 17 Thread! Stack A B C D E F
  • 18. Garbage Collection (Mark) 18 Thread! Stack A B C D E F
  • 19. Garbage Collection (Sweep) 19 Thread! Stack A B C D E F X X
  • 21. ARM’s AArch64 Porting effort ▪ Model, kernel, bionic and shell below ▪ LCU14-411 From zero to booting Nano-Android ▪ Not just a recompile! ▪ Dalvik™ VM implementation ▪ Portable C interpreter, garbage collection, class loading, JNI ▪ Compressed references ▪ Java™ core libraries - platform/libcore: ▪ java.* classes ▪ int always 32-bit, long always 64-bit ▪ Java: int pointer; ➤ long pointer;! ▪ C: jint pointer; ➤ jlong pointer;! ▪ pointer = (jlong)(void*) nativeStructure;! ▪ Build system 21
  • 22. ARM’s AArch64 Porting effort (2) ▪ Then: ▪ AArch64 assembler interpreter ▪ Slightly before with VIXL ▪ VIXL - library for simulating, assembling and disassembling ARMv8 A64 instructions. ▪ Just-In-Time compiler ▪ The rest of the Android™libraries ▪ End result - Android with only 64-bit binaries ▪ Initially 64-bit Dalvik™ running on host in November 2012 ▪ On ARM’s ARMv8 models on command line in February 2013 ▪ Then AOSP on models from July 2013 22
  • 23. Dalvik is Dead, Long Live ART! ▪ After porting AOSP to AArch64 - ART came along in October 2013 ▪ Not all was lost: ▪ Able to boot AOSP from July 2013 (4.2/4.3) through to 4.4 on Dalvik™ for AArch64 ▪ Demonstrated AOSP on Juno 2014 23
  • 24. ART - Android™ Runtime 24
  • 25. ART ▪ Introduced October 2013 as experimental runtime in Android™ 4.4 “KitKat” ▪ First release in Android “L” ▪ Less lag, more performance ▪ Productised through 2014 ▪ ART also introduces 64-bit support into Android ▪ ARM contributed compiler backend components from Dalvik for AArch64 ▪ + JNI compiler, glue, fixes, performance features/tweaks 25
  • 26. Unchanged ▪ Dalvik™ Virtual Machine ▪ Java™ applications as before ▪ Garbage collection, class loading, object references, all as before ▪ It is not translating programs into C/C++ ▪ Native code works as before (Java Native Interface - JNI) ▪ Eclipse + ADT or Android Studio, NDK are essentially unchanged ▪ Targeting the same platform - Android ▪ Debugging ▪ dalvikvm! ▪ Zygote ▪ app_process - Android’s command for starting VMs. 26
  • 27. Changed ▪ Garbage collection + allocation ▪ Parallel, less pauses ▪ C++ Interpreter ▪ Ahead-of-time compilation (AOT) ▪ Support for 64-bit execution ▪ Diagnostics ▪ Stricter JNI ▪ Stricter bytecode verification 27
  • 28. Initialization ▪ No JITing during startup ▪ Compilation time spent at installation ▪ boot.art: ▪ Part of the heap stored on flash ▪ Built as part of firmware image ▪ Pre-initialized VM heap ▪ ~12 MB on AOSP ▪ Zygote as before ▪ Initialize ▪ Wait for binder request to fork new apps 28
  • 29. Threads ▪ Stacks now unified - each thread has one stack each ▪ Original Dalvik™ implementation had separately allocated VM stack ▪ ART has VM, interpreted, compiler and JNI frames all on same stack ▪ Stack characteristics may be different ▪ Stack overflow + null pointer exceptions detected through fault handlers ▪ Trap and handle ▪ Thread local allocation ▪ Threads can allocate objects without getting global heap lock 29
  • 30. Garbage Collection ▪ More pluggable ▪ Provisions in runtime for different GC schemes ▪ Parallel & Concurrent ▪ More threads doing the work ▪ Background collection ▪ More throughput, less responsive ▪ Mark & Sweep, semi-space, large objects, variations 30
  • 31. 64-bit Support ▪ Two Zygotes, one 32-bit , one 64-bit ▪ 64-bit is the default ▪ Files duplicated on flash - 32/64-bit. ▪ Compressed references ▪ 32-bit object references ▪ Mapped within bottom 4 GB of memory ▪ Heap size: 256 MB ▪ Hard-float ABI ▪ Parameters passed in floating-point registers ▪ JNI 64-bit libraries ▪ Apps with 32-bit JNI run by 32-bit Zygote 31 Zygote32 Zygote64 fork() 32 bit App 64 bit App 32-bit App 64-bit App
  • 32. Compiling for ART *.java javac *.class Development Installation /data/dalvik-cache/arm! *.dex *.apk *.odex 32 dx dex2oat or! /data/dalvik-cache/arm64
  • 33. Compilation ▪ Compiler driver ▪ Portable compiler ▪ Sea of nodes IR ▪ Quick compiler ▪ Optimising compiler ▪ More platform independent code ▪ ARM, MIPS & x86 with 64-bit variants ▪ Performed at install time ▪ Compiler compiles with multiple threads in parallel ▪ Good code quality without onerous compile time 33
  • 35. Working on AOSP ▪ Google working in the open with ART in AOSP ▪ ARM, MIPS, Intel & ARM partners contribute ▪ 64-bit porting work has been a proving ground for this approach ▪ Ideas are nice, but code is better ▪ Understand who is doing what ▪ Check, post to the Google groups (see android-platform, etc.) ▪ Important to test on more than just ARM platforms - check MIPS & x86 ▪ Frequently unstable: reversions, build system restructuring ▪ Android is big, and components have interdependencies 35
  • 36. Working on AOSP ▪ AOSP’s gerrit has useful features ▪ Use it to track new changes in projects through email ▪ Volume can be high - can filter on git fields ▪ esp. if you are working on a particular feature ▪ Keep a working branch - pull it forward as quickly as possible though ▪ Use and add to the unit tests ▪ art # mma test-art 36
  • 37. Thank You The trademarks featured in this presentation are registered and/or unregistered trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved. Any other marks featured may be trademarks of their respective owners 37
  • 38. Sessions ▪ Today: ▪ LCU14-104: Everything’s Done! Android™ for 64-bit ARMv8, What’s next? ◦ Next in this room ▪ LCU14-108: Panel: Faster, Better and more Open AOSP Support ◦ 12:10, this room ▪ Wednesday: ▪ LCU14-309: Introducing Android NDK for 64bit ARMv8 SOCs ◦ 12:10 Grand Peninsula A ▪ Thursday: ▪ LCU14-411: From zero to booting Nano-Android with 64bit support ◦ 12:10 Grand Peninsula C ▪ Friday ▪ LCU14-502: Android User-Space Tests: Multimedia codec tests, Status and Open Discussions ◦ 09:15 Grand Peninsula B 38
  • 39. References ▪ Introducing ART: https://source.android.com/devices/tech/dalvik/art.html ▪ ART compatibility: https://developer.android.com/guide/practices/verifying-apps-art.html ▪ Google I/O 2014, The ART Runtime: https://www.youtube.com/watch?v=EBlTzQsUoOw ▪ VIXL: https://github.com/armvixl/vixl ▪ ARM Juno: http://www.arm.com/products/tools/development-boards/versatile-express/ juno-arm-development-platform.php ▪ AOSP Gerrit: https://android-review.googlesource.com/ ▪ Linaro's Android team: https://wiki.linaro.org/Platform/Android ▪ Bug Reports: https://source.android.com/source/report-bugs.html ▪ ARM Connected Community: http://community.arm.com/groups/android-community ▪ ARMv8 Reference Manual: http://infocenter.arm.com/help/index.jsp?topic=/ com.arm.doc.ddi0487a.c/index.html 39
  • 40. Notices ! ▪ The Android™ robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. 40
  • 42. Multi-lib: A 64bit 'primary' boot 42 6 CONFIDENTIAL