Android 4.4ã«å ¥ã£ãARTã®ã½ã¼ã¹ãè¦ãææ³
Android 4.4 (Kitkat) ã®ã½ã¼ã¹ã³ã¼ããå
¬éããã¾ããã話ã«ããã¨Dalvikãç½®ãæããARTã¨ãããã®ãéçºè
åãã«ä½¿ããããã«ãªã£ã¦ããããã§ããé¢ç½ãããªã®ã§èª¿ã¹ã¦ã¿ã¾ããã以ä¸ã¯å
¨ã¦æ¨æ¸¬ã¨å人ã®ææ³ã§ãã
ART ã¨ã¯
å
¬å¼ãªæ
å ±ã¯ãã
https://source.android.com/devices/tech/dalvik/art.html
- Dalvikã¨ç½®ãããã¦ä½¿ããã©ã³ã¿ã¤ã
- ã¾ã éçºä¸ãéçºè ã®ãã£ã¼ãããã¯ãå¾ãããã«å ¬éãã
- Dalvikãããã©ã«ãã§ããã¨å¼·èª¿ã
Dalvikã®ã©ã³ã¿ã¤ã ã¯libdvm.soã§ãARTã§ã¯ãããlibart.soã«ç½®ãæããããããéçºè ã¡ãã¥ã¼ã§ã©ã¡ãã使ãã®ãåãæ¿ãããã¨ãã§ããããã ã
http://gigaom.com/2013/10/22/google-buys-frances-flexycore-for-better-performing-android/
Googleã¯ãã©ã³ã¹ã®FlexyCoreã¨ããä¼ç¤¾ãè²·åããããã§ããARTã¯ãã®ä¼ç¤¾ã®ææã¨ããåãããã¾ãããå®ãã§ã¯ããã¾ããã
2013.11.10ä¿®æ£
Android 4.4ã®ARTã¯å¤ããè²·ã£ã¦ãããã®ã§ã¯ãªãã¦ã2å¹´åããgoogleå
é¨ã§éçºãã¦ãããã®ãgitã®ãã°ãè¦ãã¨ããã確èªã§ãã¾ãã
Android 4.4ã®ã½ã¼ã¹ã³ã¼ããè¦ã
æ軽ãªã®ã¯ããã(ãããã¨ããã®ãã¤ãªããï¼
http://tools.oesf.biz/android-4.4.0_r1.0/
èªåã§ã½ã¼ã¹ã³ã¼ãããã¦ã³ãã¼ãããã«ã¯ã公式サイトの方法ãè¦ãªãããAndroid 4.4ãæå®ãã¦repo initãã¾ãã
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1
ãªããä½ãç¡ãç¶æ
ããrepo syncããã¨æéããããããããã¯ã¼ã¯ã®å¸¯åã使ã£ã¦è¿·æã«ãªãã®ã§ããã§ã«åã®ãã¼ã¸ã§ã³ãrepo syncãããã¨ã®ãã人ã¯ãã®ãªãã¸ããªãåå©ç¨ãã¾ãããã
KMC Staff Blog:Androidのrepo syncのTips
ARTã®ã½ã¼ã¹ã³ã¼ãããªãããªããã¤ã¶ããã
ARTã®ã½ã¼ã¹ã¯ããããã£ã¬ã¯ããªã®ç´ä¸ã®artã«ããã¾ãã
http://tools.oesf.biz/android-4.4.0_r1.0/xref/art/
å
¨ã¦c++ã§æ¸ããã¦ãã¾ããããã¡ã¤ã«åã®ãµãã£ãã¯ã¹ã¯*.ccã§ããDalvikã§ã¯c++ã®ãã¡ã¤ã«ã®ãµãã£ãã¯ã¹ã¯*.cppãªã®ã§ã両è
ã¯å
¨ãéããã¼ã ã§éçºãããã®ã§ã¯ãªãã§ããããã
ãã®ã³ã¡ã³ãã¯これããã¨ãã¨ã¯ç¬èªãã©ã¼ãããã ã£ããã©ããä»ã¯ELF dynamic objectã¨æ¸ãã¦ããã¾ãã
ここã«whileã«ã¼ãã®ä¸ã®å·¨å¤§ãªswitchæã¨ããç´ æ´ãªDEXã³ã¼ãã¤ã³ã¿ããªã¿ã®å®è£ ãããã¾ããDalvikã®ä¸ã®ã¤ã³ã¿ããªã¿ã¯ã¢ã»ã³ãã©ã§ã«ãªã«ãªã«ãã¥ã¼ãã³ã°ãããå®è¡é »åº¦ã®é«ãé¨åãè¦ã¤ãã¦JITã³ã³ãã¤ã«ãè¦æ±ããããã«ãªã£ã¦ãã¾ãããããã«ã¯ãã®ãããªæ°é ã¯ããã¾ãããå®è¡ä¸ã«ããã¯ã°ã©ã³ãã§ã³ã³ãã¤ã«ããã¨ãããã¨ã¯ãªãããã§ãã
oatãã¡ã¤ã«ã¯dexãã¡ã¤ã«ãç½®ãæãããã®ã§ã¯ãªãã¦ãdexãã¡ã¤ã«ã¨ä½µç¨ããããã§ãã
libart-compilerã®ã©ã¤ãã©ãªã¯ã©ãã§ä½¿ããã¦ãããã調ã¹ã¾ããããdex2oatã³ãã³ãã ããlibart-compilerããªã³ã¯ãã¦ãã¾ãããã¤ã¾ããdexãã¡ã¤ã«ãã³ã³ãã¤ã«ãã(=oatãã¡ã¤ã«ãçæãã)ã«ã¯dex2oatã³ãã³ããå®è¡ããå¿ è¦ãããã¾ãã
dex2oatコマンドのオプションãè¦ãã¨ã--bitcode=
Androidã§ã¯ã¾ã Java6ã使ç¨ãã¦ãã¾ãããããã¯ãã§ã«EOL(End of Life)ã§ããOracleã¨ã®ä¿äºãããã¾ãããJavaããã®ã¹ã¤ããããããã¾ããã(å人ã®ææ³ã§ãã)
runtime/class_linker.cc#GenerateOatFileã§dex2oatã³ãã³ããforkãã¦execãã¦ã¾ããããã¦ããã®é¢æ°ã®å¼ã³åºãå ãä¸ã«ãã©ã£ã¦ããã¨openDexFileNativeã¨ããé¢æ°ã«ãã©ãã¤ãã¾ããその検索結果ããããlibdvm.soã¨libart.soã®å ±éã®APIã«ãªã£ã¦ããã®ã§ãããã
runtime/class_linker.cc#FindOrCreateOatFileForDexLocationLockedã®ä¸ã§ããã®åã®éããoatãã¡ã¤ã«ãè¦ã¤ããã°ããã使ç¨ããç¡ããã°dexãã¡ã¤ã«ãã³ã³ãã¤ã«ãã¦oatãã¡ã¤ã«ãçæãã¦ãã¾ãã
emulatorããã«ããã¦ã¿ã¾ãããããã«ãããããã¡ã¤ã«ã®ä¸ã«*.oatãã¡ã¤ã«ã¯ããã¾ããã§ãããã§ãcleanããã¨ãã«*.oatãã¡ã¤ã«ãåé¤ããã³ã¼ãã¯ãã£ãã®ã§ãMakefileã®ã©ããããããã°ãã«ãæã«ãã¹ãå´ã§dex2oatã³ãã³ããå®è¡ãããã¨ã¯ã§ããã®ã§ã¯ãªããã¨æãã¾ãã
ã¢ããªã±ã¼ã·ã§ã³ãã¤ã³ã¹ãã¼ã«ãã¦ãæåã«èµ·åããã¨ãã«dex2oatã³ãã³ãã§ã³ã³ãã¤ã«ãè¡ãããã®ã§å°ãæéããããã¨ããæåã«ãªãã¨æãã¾ãã
DalvikVMã®JITã¨ã®æ¯è¼
Android 2.2 (Froyo)ããå
¥ã£ãDalvikVMã®JITã«ã¤ãã¦ä»¥åããã«æ¸ãã¾ããã
KMC Staff Blog:AndroidのFroyoのJITについて
http://togetter.com/li/16674
ã¤ã³ã¿ããªã¿ã§å®è¡ä¸ã«å®è¡é »åº¦ã®é«ãé¨åãæ¤åºãã¦ããã®é¨åã ããã³ã³ãã¤ã«ãã¦ç½®ãæãã¾ããã³ã³ãã¤ã«ã¯å°ç¨ã®ã¹ã¬ããã§ããã¯ã°ã©ã³ãã§è¡ãã¾ããå°ããåä½ã§ã³ã³ãã¤ã«ãããã¨ã§ãã³ã³ãã¤ã«æéãçãã使ç¨ã¡ã¢ãªã®å¢å ããããããã¦ãã¾ããã³ã³ãã¤ã«çµæã¯ä¿åãããã¢ããªã®èµ·åã®ãã³ã«JITãè¡ããã¾ãã
ç¾ç¶ã®ARTã§ã¯ã³ã³ãã¤ã«ã¯å®è¡ã®ç´åã«dexãã¡ã¤ã«åä½ã§è¡ããã¾ããã³ã³ãã¤ã«ã«ãããæéã使ç¨ã¡ã¢ãªã¯Dalvikã®JITããã大ããã¨æãã¾ããã³ã³ãã¤ã«ããçµæã¯oatãã¡ã¤ã«ã¨ãã¦ä¿åããã¾ããããã®ãã¡ã¤ã«ã®ãµã¤ãºã¯å
ã®dexãã¡ã¤ã«ã®æ°åã¯ããã¨æããã¾ãã
DalvikVMã®JITã®éçã¨LLVMã®ããã³ã·ã£ã«
DalvikVMã®JITã¯ããã§ãã¦ããã¨æãã®ã§ãããéçãããã¾ããããã¯å¼·åãªæé©åãè¡ããã¨ãé£ããã¨ãããã¨ã§ããæè¿ã®ã³ã³ãã¤ã«æè¡ã®ããããªè©±é¡ã¨ãã¦ã並åæ§ãèªåçã«æ¤åºãããããã¹ã¬ããã«åå²ããããã¯ã¿ã©ã¤ãºãã¦SIMDå½ä»¤ã使ç¨ããããã¾ããDalvikVMã®JITã§ã¯ããã¾ã§ã®æé©åã¯ã§ãã¾ãããæè¿ã®Androidã§ä½¿ç¨ããSoCã§ã¯NEONå½ä»¤ã¯æ¨æºè£
åã4ã³ã¢ã®SMPããããããããã¾ãããããããããã«æ´»ç¨ãããã¨ãã§ããªãã®ã§ããæè¼ããã¡ã¢ãªãã¹ãã¬ã¼ã¸ã®å®¹éã大ãããªã£ã¦å®æ©ä¸ã§æ¬æ ¼çãªæé©åã³ã³ãã¤ã©ãåããä½å°ãåºã¦ãã¾ããã
ãã®ãã¨ã«é¢ãã¦ã¯Googleãæ°ãã¤ãã¦ãã¦ãAndroid4.0ã§ã¯LLVM/Clangã®æè¡ã使ã£ãRenderScriptãå
¥ãã¾ããããåæµã®ã¾ã¾ã§ãããããã§ã主åã§ããDalvikVMãLLVMã®ã³ã³ãã¤ã«æè¡ããã«ã«æ´»ç¨ã§ããARTã¸ã®ç½®ãæããçã£ã¦ããã®ã ã¨æãã¾ãã
ç¾å¨ã®ARTã¯ã¾ã ã¾ã å®æå½¢ã§ã¯ããã¾ãããã¨ã«ããã¾ãã¤ãªãã¦ã¿ãã¨ããã¬ãã«ã§ãããLLVMã®æé©åãå¹æçã«ä½¿ããç¶æ ã§ã¯ããã¾ããããã®å ã®çºå±ã«æ³¨ç®ãããã¨æãã¾ãã
Android 4.0ã§ã®RenserScriptã«ã¤ãã¦ã¯ããã«æ¸ãã¾ããã
KMC Staff Blog:Android 4.0で利用されているLLVM
ãã¾ã©ãã®ã³ã³ãã¤ã©ã¯æ®éã®ã«ã¼ãããã¯ã¿ã©ã¤ãºãã¦SIMDå½ä»¤çæãããã¨ãã§ãã¾ããããã¯gccã®ä¾ã§ãããLLVMãåæ§ã®ãã¨ãå¯è½ã
KMC Staff Blog:ARMのNEONのSIMD命令をgccのオートベクタライズの最適化で使う方法
LLVMã§ã®é©ãã®æé©å
clang+llvmでさりげなくすごいコードが生成されていた話。 - 組み込みの人。
ãã¾ãï¼Dalvikã¨ARTãã³ãã³ãã©ã¤ã³ã§åãæ¿ããã«ã¯
root権éã§setprop persist.sys.dalvik.vm.lib libart.so ããã¦ãããªãã¼ããã¾ãã
$ adb root && sleep 3 $ adb shell setprop persist.sys.dalvik.vm.lib libart.so $ adb reboot
http://tools.oesf.biz/android-4.4.0_r1.0/xref/art/Android.mk#346
追è¨
ARTã®ä¸ã«ãã¬ãã¼ã¸ã³ã¬ã¯ã¿ãããã¾ãããDalvikVMã¨åæ§ã«ã³ã³ã«ã¬ã³ãGCã®ããã§ãã
ããã«æ¸ãããã¨ã¯ã½ã¼ã¹ãè¦ãææ³ã§ãããå®éã«åããã¦ã¿ãããã§ã¯ããã¾ãããå®éã«åããã¦Dalvikã¨ARTãæ¯è¼ãã人ããããæ å ±ããã ããã
ç¶ãã®è¨äºãæ¸ãã¾ããã
Android 4.4 のARTのブートログを見てみた - 組み込みの人。