çç£çãªã¢ããªã±ãŒã·ã§ã³
Androidãã©ãããã©ãŒã çšã®ã¢ããªã±ãŒã·ã§ã³ã¯ãã³ã³ãã¥ãŒãã£ã³ã°æ©èœãšã¡ã¢ãªãå¶éãããããããªãŒå¯¿åœãçãã¢ãã€ã«ããã€ã¹ã§èµ·åãããŸãã ãããã£ãŠãã¢ããªã±ãŒã·ã§ã³ã¯å¹æçã§ãªããã°ãªããŸããã ããããªãŒã®å¯¿åœã¯ãã¢ããªã±ãŒã·ã§ã³ãååã«é«éã§å®è¡ãããŠããå Žåã§ããã¢ããªã±ãŒã·ã§ã³ãæé©åããçç±ã®1ã€ã§ãã ããããªãŒã®å¯¿åœã¯ãŠãŒã¶ãŒã«ãšã£ãŠéåžžã«éèŠã§ãããAndroidãã©ãããã©ãŒã ã¯ãã¢ããªã±ãŒã·ã§ã³ãããããªãŒã®å¯¿åœãå€§å¹ ã«ççž®ããå Žåã«ãŠãŒã¶ãŒã«ç°¡åã«è¡šç€ºããŸãã
ããã§ã¯ãã€ã¯ãæé©åã«ã€ããŠèª¬æããŸãããã¢ããªã±ãŒã·ã§ã³ãæå·ããããšã¯ã»ãšãã©ãããŸããã é©åãªã¢ã«ãŽãªãºã ãšããŒã¿æ§é ãéžæããããšãåžžã«æåªå äºé ã§ããã¯ãã§ããããã®åŽé¢ã¯èæ ®ãããŸããã
ã€ã³ãã
çç£çãªã³ãŒããéçºããããã®2ã€ã®åºæ¬çãªã«ãŒã«ïŒ
- ããå¿ èŠã®ãªãä»äºãããªãã§ãã ãã
- å²ãåœãŠãããªãã¡ã¢ãªãå²ãåœãŠãªãã§ãã ãã
è³¢æãªæé©å
Androidã®ãã€ã¯ãæé©åã«ã€ããŠèª¬æããŸãããã®ããããããã¡ã€ã©ãŒã䜿çšããŠãæé©åããå¿ èŠãããç¹å®ã®ã³ãŒãã決å®ããå€æŽã®åœ±é¿ãè©äŸ¡ããæ¹æ³ãæ¢ã«ç¥ã£ãŠããããšãåæãšããŠããŸãã éçºã«å€ãã®æéãè²»ãããŠããã®ã§ãè³¢æã«ãããè²»ãããŠããããšãç¥ãããšãéèŠã§ãã
ãŸããæé©ãªã¢ã«ãŽãªãºã ãšããŒã¿æ§é ããã§ã«éžæããŠãããAPIã®æ±ºå®ãããã©ãŒãã³ã¹ã«äžãã圱é¿ãäºæž¬ããŠããããšãåæãšããŠããŸãã é©åãªããŒã¿æ§é ãšã¢ã«ãŽãªãºã ã䜿çšãããšããããã®ãã³ããããããã©ãŒãã³ã¹ãå€§å¹ ã«åäžããAPIãããã©ãŒãã³ã¹ã«äžãã圱é¿ãæ éã«æ€èšããããšã§ãå°æ¥ã®ããè¯ãå®è£ ãžã®ç§»è¡ã容æã«ãªããŸãïŒããã¯ãã¢ããªã±ãŒã·ã§ã³ã³ãŒãã§ã¯ãªãã©ã€ãã©ãªã³ãŒãã«ãšã£ãŠäž»ã«éèŠã§ãïŒã
Androidã¢ããªã±ãŒã·ã§ã³ã®ãã€ã¯ãæé©åäžã«çºçããæãåä»ãªåé¡ã®1ã€ã¯ãã¢ããªã±ãŒã·ã§ã³ãå€ãã®ç°ãªãããŒããŠã§ã¢ãã©ãããã©ãŒã ã§åäœããå¯èœæ§ãé«ãããšã§ãã ç°ãªãããã»ããµäžã®ç°ãªãããŒãžã§ã³ã®ä»®æ³ãã·ã³ã¯ãç°ãªãé床ã§åäœããŸãã äžè¬ã«ãããã¯åã«ãããã€ã¹Xã¯ããã€ã¹Yã®nåé«é/äœéããšèšã£ãŠãçµæãä»ã®ããã€ã¹ã«å€æ¿ã§ããå Žåã§ããããŸããã ç¹ã«ããšãã¥ã¬ãŒã¿ã§ã®ãã¹ãã§ã¯ãããã€ã¹ã®ããã©ãŒãã³ã¹ã«ã€ããŠã»ãšãã©äœãèšãããŠããŸããã ãŸããJITãæèŒããããã€ã¹ãšæèŒããªãããã€ã¹ã®éã«ã¯å€§ããªéãããããŸããJITãæèŒããããã€ã¹ã®ãæé©ãªãã³ãŒãã¯ãJITãæèŒããŠããªãããã€ã¹ã«ãšã£ãŠå¿ ãããæé©ãªãã®ã§ã¯ãããŸããã
äžéšã®ããã€ã¹ã§ã¢ããªã±ãŒã·ã§ã³ãã©ã®ããã«åäœããããç¥ãããå Žåã¯ããã¹ãããå¿ èŠããããŸãã
äžèŠãªãªããžã§ã¯ããäœæããªã
ãªããžã§ã¯ãã®äœæãç¡æã«ãªãããšã¯ãããŸããã åã¹ã¬ããã®äžæãªããžã§ã¯ãã®äžä»£ãšããŒã«ãæäœããã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ãã¡ã¢ãªã®å²ãåœãŠã容æã«ããŸãããã¡ã¢ãªãå²ãåœãŠãã®ã¯ãå²ãåœãŠãªããããåžžã«é«äŸ¡ã§ãã
ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã§ã«ãŒãå ã®ãªããžã§ã¯ããéžæãããšãå®æçãªã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã匷å¶ããããŠãŒã¶ãŒã«è¡šç€ºãããå°ããªãã¹ã¿ãã¿ãŒããäœæãããŸãã Gingerbreadã§å°å ¥ããããã©ã¬ã«ã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ããã«åœ¹ç«ã¡ãŸãããäžå¿ èŠãªäœæ¥ã¯åžžã«é¿ããå¿ èŠããããŸãã
ãããã£ãŠãäžèŠãªãªããžã§ã¯ãã®äœæã¯é¿ããŠãã ããã ããã«åœ¹ç«ã€ããã€ãã®äŸã瀺ããŸãã
- æååãè¿ãã¡ãœããããããçµæãåžžã«StringBufferã«è¿œå ãããããšãããã£ãŠããå Žåã¯ãäžæçãªäžæãªããžã§ã¯ããäœæããã®ã§ã¯ãªããã¡ãœãããçŽæ¥è¿œå ãå®è¡ããããã«å®è£ ãå€æŽããŸãã
- å ¥åããŒã¿ã»ããããæååãæœåºãããšããã³ããŒãäœæãã代ããã«ãåæããŒã¿ã®éšåæååãè¿ãããã«ããŠãã ããã æ°ããStringãªããžã§ã¯ããäœæãããŸããããã®æåã®é åãšåæããŒã¿ã¯å ±æãããŸãã ïŒåŠ¥åç¹ã¯ããã®ã¢ããã€ã¹ã«åŸãã°ãåæå ¥åã®ããäžéšãã䜿çšãããªãå Žåã§ããå šäœãä¿åãããããšã§ãïŒã
ãã£ãšæ¥é²çãªãã®ãèŠãŠã¿ãŸãããïŒå€æ¬¡å é åã1ã€ã®äžŠå1次å é åã«åå²ããŸãïŒ
- inté åã¯Integeré åãããã¯ããã«åªããŠããŸãã ãã ãããã®äºå®ã¯äžè¬åã§ããŸãã2ã€ã®äžŠåinté åã¯ããªããžã§ã¯ãã®é åïŒintãintïŒãããã¯ããã«å¹ççã§ãã ããªããã£ãã®ä»»æã®çµã¿åããã«ã€ããŠãåãããšãèšããŸãã
- ãã¢ïŒFooãBarïŒãå«ãã³ã³ãããå®è£ ããå¿ èŠãããå Žåã2ã€ã®äžŠåé åFoo []ããã³Bar []ã¯ããªããžã§ã¯ãã®åäžã®é åïŒFooãBarïŒãããã¯ããã«åªããŠããããšã«æ³šæããŠãã ããã ïŒäŸå€ã¯ãAPIãéçºããŠããå Žåã§ãããããã®å Žåãããã©ãŒãã³ã¹ãå°ãæãªãã ãã§è¯ãAPIã«åºå·ããããšããå§ãããŸãããã ããç¬èªã®ã³ãŒãã§å¯èœãªéãå¹ççã«ãªãããã«ããŠãã ãããïŒ
äžè¬çã«ãå¯èœã§ããã°çåœã®ãªããžã§ã¯ããäœæããªãã§ãã ããã äœæããããªããžã§ã¯ãã®æ°ãå°ãªããšãã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®é »åºŠãå°ãªããªãããŠãŒã¶ãŒãšã®å¯Ÿè©±ã«çŽæ¥åœ±é¿ããŸãã
ããã©ãŒãã³ã¹ç¥è©±
ãã®ããã¥ã¢ã«ã®å€ãããŒãžã§ã³ã«ã¯ãããŸããŸãªèª€ã£ãèšè¿°ãå«ãŸããŠããŸãã ãããã®ããã€ãã«å¯ŸåŠããŸãã
JITãæããªãããã€ã¹ã§ã¯ãç¹å®ã®ã¯ã©ã¹ã®ãªããžã§ã¯ãã®ã¡ãœãããåŒã³åºãæ¹ããã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠåŒã³åºãããããããã«é«éã§ãã ïŒãããã£ãŠãåããªããžã§ã¯ãã§ãã£ãŠããMapã®ä»£ããã«HashMapã¡ãœãããåŒã³åºãæ¹ãå®äŸ¡ã§ããïŒ2åé«éã§ã¯ãããŸããã å®æ°ã¯6ïŒ ã«è¿ãå€ã§ãã ããã«ãJITã䜿çšããå Žåããã®éãã¯ã»ãšãã©èªèã§ããŸããã
JITã®ãªãããã€ã¹ã§ã¯ãã¯ã©ã¹ãã£ãŒã«ããžã®ãã£ãã·ã¥ã¢ã¯ã»ã¹ã¯ããã£ãŒã«ããžã®çŽæ¥åŒã³åºããç¹°ãè¿ãããã20ïŒ é«éã§ãã JITã§ã¯ããã£ãŒã«ãã«ã¢ã¯ã»ã¹ããã³ã¹ãã¯ããŒã«ã«ã¢ãã¬ã¹ã«ã¢ã¯ã»ã¹ããã³ã¹ããšçãããããã³ãŒããèªã¿ããããããŸã§ãã®æé©åã¯å¿ èŠãããŸããã ïŒæçµãã£ãŒã«ããéçãã£ãŒã«ããããã³éçæçµãã£ãŒã«ãã«é¢ããŠåœãŠã¯ãŸããŸãïŒã
ä»®æ³ãããéçãåªå
ãªããžã§ã¯ãã®ãã£ãŒã«ãã«ã¢ã¯ã»ã¹ããå¿ èŠããªãå Žåãã¡ãœãããéçã«ããããšãã§ããŸãã åŒã³åºãã¯15ã20ïŒ é«éã«ãªããŸãã ããã¯ãã¡ãœããããªããžã§ã¯ãã®ç¶æ ãå€æŽããªãããšã眲åã«ãã£ãŠèšãããšãã§ãããããè¯ãã§ãã
å éšã¢ã¯ã»ãµãŒã¡ãœãããé¿ãã
C ++ãªã©ã®ãã€ãã£ãèšèªã§ã¯ãçŽæ¥ã¢ã¯ã»ã¹ïŒi = mCountïŒã®ä»£ããã«ã²ãã¿ãŒïŒi = getCountïŒïŒãªã©ïŒã䜿çšããããšããå§ãããŸãã ããã¯ãã³ã³ãã€ã©ãéåžžã€ã³ã©ã€ã³çœ®æãå®è¡ã§ãããããC ++ã®ãã°ãããç¿æ £ã§ãããã£ãŒã«ãã¢ã¯ã»ã¹ãå¶éãŸãã¯ãããã°ããå¿ èŠãããå Žåã¯ãå¿ èŠãªã³ãŒãããã€ã§ãè¿œå ã§ããŸãã
Androidã®å Žåãããã¯æªãèãã§ãã ä»®æ³ã¡ãœããã®åŒã³åºãã¯éåžžã«é«äŸ¡ã§ã-ãªããžã§ã¯ããã£ãŒã«ããæ€çŽ¢ãããããã¯ããã«é«äŸ¡ã§ãã ãã¡ãããäžè¬çãªOOPãã©ã¯ãã£ã¹ã®äœ¿çšãããã³ã€ã³ã¿ãŒãã§ã€ã¹ã§ã®ã²ãã¿ãŒãšã»ãã¿ãŒã®äœ¿çšã¯æ£åœåãããŸãããã¯ã©ã¹å ã§ã¯åžžã«ãã£ãŒã«ãã«çŽæ¥ã¢ã¯ã»ã¹ããå¿ èŠããããŸãã
JITããªãå Žåããã£ãŒã«ããžã®çŽæ¥ã¢ã¯ã»ã¹ã¯ãéåžžã®ã²ãã¿ãŒãåŒã³åºããããçŽ3åé«éã§ãã JITã§ã¯ãçŽæ¥ã¢ã¯ã»ã¹ãããŒã«ã«ã¢ãã¬ã¹ãžã®çŽæ¥ã¢ã¯ã»ã¹ãšåãé床ã§ããå ŽåãçŽæ¥ã¢ã¯ã»ã¹ã¯ã¢ã¯ã»ãµã¡ãœãããåŒã³åºããããçŽ7åéããªããŸãã ãã®å£°æã¯Froyoã«ãåœãŠã¯ãŸããŸãããå°æ¥ã®ãªãªãŒã¹ã§ã¯ãJITãgetterãã€ã³ã©ã€ã³åãããããç¶æ³ã¯æ¹åãããŸãã
å®æ°ã«éçãã¡ã€ãã«ã䜿çš
ã¯ã©ã¹ã®å é ã§æ¬¡ã®å®£èšãæ€èšããŠãã ããã
static int intVal = 42; static String strVal = "Hello, world!";
ã³ã³ãã€ã©ã¯ãã¯ã©ã¹ãæåã«äœ¿çšããããšãã«å®è¡ãããååã§ãã¯ã©ã¹åæåã¡ãœãããçæããŸãã ã¡ãœããã¯42ãintValã«å²ãåœãŠãstrValã®ã¯ã©ã¹ãã¡ã€ã«ã®äžå€è¡ã®ããŒãã«ãããªã³ã¯ãæœåºããŸãã ãããã®å€æ°ã«ã¢ã¯ã»ã¹ãããšãã¯ã©ã¹ã®å¯Ÿå¿ãããã£ãŒã«ããæ€çŽ¢ãããŸãã
æåŸã®1ã€ã®ããŒã¯ãŒãã§ãã®åäœãå€æŽããæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
static final int intVal = 42; static final String strVal = "Hello, world!";
å®æ°ã¯dexãã¡ã€ã«ã®éçãã£ãŒã«ãåæååã«æžã蟌ãŸããããããã®ã¡ãœããã¯äžèŠã«ãªããŸããã intValã«ã¢ã¯ã»ã¹ããã³ãŒãã¯æŽæ°å€42ãçŽæ¥äœ¿çšããstrValã«ã¢ã¯ã»ã¹ãããšããã£ãŒã«ããæ€çŽ¢ãã代ããã«æååå®æ°ãžã®å®äŸ¡ãªåŒã³åºããçºçããŸãã ïŒãã®æé©åã¯ããã¹ãŠã®ä»»æã®ãªã³ã¯ã¿ã€ãã§ã¯ãªããããªããã£ããšæååã«å¯ŸããŠã®ã¿æ©èœããããšã«æ³šæããŠãã ãããããã«ãããããããå¯èœãªéãéçãªfinalãšããŠã®å®æ°å®£èšã䜿çšããå¿ èŠããããŸããïŒ
æ¹è¯ãããForã«ãŒãæ§æã®äœ¿çš
for-eachã«ãŒãã¯ã
Iterable
ã€ã³ã¿ãŒãã§ã€ã¹ãšé åãå®è£ ããã³ã¬ã¯ã·ã§ã³ã«äœ¿çšã§ããŸãã hasNextïŒïŒããã³nextïŒïŒã¡ãœãããåŒã³åºãããã«ãã³ã¬ã¯ã·ã§ã³ã«ã€ãã¬ãŒã¿ãŒãå²ãåœãŠãããŸãã
ArrayList
ã«ãŠã³ã¿ãŒã䜿çšã
ArrayList
åŸæ¥ã®ã«ãŒãã¯ïŒJITã®æç¡ã«ãããããïŒçŽ3åé«éã§ãããä»ã®ã³ã¬ã¯ã·ã§ã³ã®å Žåããfor-eachãæ§æã¯ã€ãã¬ãŒã¿ãŒãæ瀺çã«äœ¿çšããã®ãšåçã§ãã
é åãèµ°æ»ããæ¹æ³ã¯ããã€ããããŸãã
static class Foo { int mSplat; } Foo[] mArray = ... public void zero() { int sum = 0; for (int i = 0; i < mArray.length; ++i) { sum += mArray[i].mSplat; } } public void one() { int sum = 0; Foo[] localArray = mArray; int len = localArray.length; for (int i = 0; i < len; ++i) { sum += localArray[i].mSplat; } } public void two() { int sum = 0; for (Foo a : mArray) { sum += a.mSplat; } }
zeroïŒïŒã¯æãé ãã¡ãœããã§ããJITã¯å埩ã®åã¹ãããã§é åã®é·ããååŸããããšãæé©åã§ããªãããã§ãã
oneïŒïŒã¯é«éã§ãã å¿ èŠãªæ å ±ãããŒã«ã«å€æ°ã«åã蟌ã¿ããã£ãŒã«ãæ€çŽ¢ãåé¿ããŸãã ããã§ã¯array.lengthã®ã¿ãããã©ãŒãã³ã¹ãæ¹åããŸãã
twoïŒïŒã¯ JITã®ãªãããã€ã¹ã§ã¯ããé«éã§ãJITã®ããããã€ã¹ã§ã¯1ïŒïŒãšåºå¥ã§ããŸããã Java 1.5ã§å°å ¥ãããæ¡åŒµæ§æã䜿çšããŸã
çµè«ïŒããã©ã«ãã§for-eachæ§æã䜿çšããŸãããããã©ãŒãã³ã¹ãéèŠãª
ArrayList
ãã¹ãæåã§ç¹°ãè¿ãããšã
ArrayList
ããŠãã ããã ïŒ æå¹ãªJavaã®æ®µèœ46ãåç §ããŠãã ãããïŒ
ãã©ã€ããŒãå éšã¯ã©ã¹ã«ã¯ããã©ã€ããŒãã§ã¯ãªãããã±ãŒãžãã©ã€ããŒãã¢ã¯ã»ã¹ã䜿çšããŸãã
次ã®ã¯ã©ã¹å®çŸ©ãæ€èšããŠãã ããã
public class Foo { private class Inner { void stuff() { Foo.this.doStuff(Foo.this.mValue); } } private int mValue; public void run() { Inner in = new Inner(); mValue = 27; in.stuff(); } private void doStuff(int value) { System.out.println(" " + value); } }
泚æãã¹ãæãéèŠãªããšã¯ããã©ã€ããŒãã¯ã©ã¹ãšå€éšã¯ã©ã¹ã®ãã©ã€ããŒããã£ãŒã«ããçŽæ¥åç §ãããã©ã€ããŒãå éšã¯ã©ã¹ïŒFoo $ InnerïŒã®å®çŸ©ã§ãã ã³ãŒãã¯æ£ãããäºæ³ã©ãããå€ã¯27ããšè¡šç€ºãããŸãã
ããã§ã®åé¡ã¯ãJavaãå éšã¯ã©ã¹ããå€éšã¯ã©ã¹ã®ãã©ã€ããŒãã¡ã³ããŒãžã®ã¢ã¯ã»ã¹ãèš±å¯ããŠããå Žåã§ããFooãšFoo $ Innerã¯ç°ãªãã¯ã©ã¹ã§ãããããä»®æ³ãã·ã³ã¯å éšã¯ã©ã¹ããFooã®ãã©ã€ããŒãã¡ã³ããŒãžã®çŽæ¥ã¢ã¯ã»ã¹ãåãå ¥ããããªããšèŠãªãããšã§ãã ãã®ã®ã£ãããåããããã«ãã³ã³ãã€ã©ãŒã¯ããã€ãã®äººå·¥çãªã¡ãœãããçæããŸãã
/*package*/ static int Foo.access$100(Foo foo) { return foo.mValue; } /*package*/ static void Foo.access$200(Foo foo, int value) { foo.doStuff(value); }
å éšã¯ã©ã¹ã¯ãmValueã«ã¢ã¯ã»ã¹ããå¿ èŠããããã³ã«ãããã®éçã¡ãœãããåŒã³åºãããå€éšã¯ã©ã¹ã®doStuffïŒïŒãåŒã³åºããŸãã ã€ãŸããäžèšã®ã³ãŒãã¯ãã¢ã¯ã»ãµãŒã¡ãœãããä»ããŠã¯ã©ã¹ã®ãã£ãŒã«ãã«ã¢ã¯ã»ã¹ããå Žåã«ãªããŸãã ãã£ãŒã«ãã«çŽæ¥ã¢ã¯ã»ã¹ããåã«ããã®ãããªã¡ãœããã®é床ãé ããšããåé¡ã«ã€ããŠã¯ãã§ã«èª¬æããŸããããã®ãããèšèªã®ç¹å®ã®ã€ãã£ãªã ã¯ãç®ã«èŠããªããããã©ãŒãã³ã¹ã®äœäžã«ã€ãªãããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãéèŠãªéšåã§åæ§ã®ã³ãŒãã䜿çšããå Žåãå éšã¯ã©ã¹ããã¢ã¯ã»ã¹ããããã£ãŒã«ãããã³ã¡ãœããã宣èšããããšã«ããããã®åäœãåé¿ã§ããŸãããã©ã€ããŒãã§ã¯ãªãããã±ãŒãžãã©ã€ããŒãã§ãã æ®å¿µãªãããããã¯ãã£ãŒã«ããããã±ãŒãžå ã®ä»ã®ã¯ã©ã¹ããã¢ã¯ã»ã¹ã§ããããšãæå³ããããããã®ææ³ã¯ãããªãã¯APIã§äœ¿çšã§ããŸããã
æµ®åå°æ°ç¹æ°ãè³¢ã䜿ã
èŠããã«ãæµ®åå°æ°ç¹ã®èšç®ã¯ãAndroidããã€ã¹ã®æŽæ°ã®çŽ2åé ããªããŸãã ããã¯ãG1ïŒJITããã³FPUãªãïŒããã³FPUããã³JITä»ãNexus Oneã«åœãŠã¯ãŸããŸãã ïŒãã¡ãããç®è¡æŒç®ã®é床ã«é¢ãã2ã€ã®ããã€ã¹ã®çµ¶å¯Ÿçãªå·®ã¯çŽ10åã§ãïŒã
é床ã®é¢ã§ã¯ãææ°ã®ããŒããŠã§ã¢ã§ã¯floatãšdoubleã®éã«éãã¯ãããŸããã ã¡ã¢ãªãããdoubleã¯2å倧ãããªããŸãã ãã¹ã¯ãããã³ã³ãã¥ãŒã¿ãŒã§ã¯ãã¡ã¢ãªãèæ ®ããã«ãfloatã§ã¯ãªãdoubleã䜿çšããå¿ èŠããããŸãã
ãŸããäžéšã®ãããã«ã¯æŽæ°ã®æŽæ°ä¹ç®ãæèŒãããŠããŸãããæŽæ°é€ç®ã¯çµã¿èŸŒãŸããŠããŸããã ãã®ãããªå ŽåãæŽæ°ã®é€ç®ãšã¢ãžã¥ãæŒç®ã¯ãœãããŠã§ã¢ã¬ãã«ã§å®è¡ãããŸãã ããã·ã¥ããŒãã«ãäœæããå ŽåããŸãã¯å€ãã®æ°åŠæŒç®ãå®è¡ããå Žåã¯ããã®ããšãèæ ®ããŠãã ããã
ã©ã€ãã©ãªãç解ããŠäœ¿çšãã
ç¬èªã®ã³ãŒããäœæãã代ããã«ã©ã€ãã©ãªã³ãŒãã䜿çšãããã¹ãŠã®éåžžã®çç±ã«å ããŠãã·ã¹ãã ãã©ã€ãã©ãªã³ãŒããã¢ã»ã³ãã©ãŒã€ã³ãµãŒãã«çœ®ãæããããšãã§ããããšã念é ã«çœ®ããŠãã ãããããã¯ãåçã®Javaçšã®JITã³ã³ãã€ã©ãŒã«ãã£ãŠçæãããæé«ã®ã³ãŒããããé«éã§ã å žåçãªäŸã¯ã
String.indexOf
ããã³Dalvikãå éšã³ãŒãã«çœ®ãæããä»ã®ã¡ãœããã§ãã ãã®ããã
System.arraycopy
ãæ¢åã®JITãåããNexus Oneã«æåã§å®è£ ãããã«ãŒããããçŽ9ïŒïŒïŒåé«éã§ãã ïŒ æå¹ãªJavaã®æ®µèœ47ãåç §ããŠãã ãããïŒ
ãã€ãã£ãã¡ãœãããè³¢ã䜿çšãã
ãã€ãã£ãã³ãŒãã¯å¿ ãããJavaãããå¹ççã§ã¯ãããŸããã çç±ã®1ã€ã¯ãJava->ãã€ãã£ãã³ãŒãã®ç§»è¡ã«æéãããããJITã¯ãããã®ç¯å²å ã§ã¯äœãã§ããªãããšã§ãã ãã€ãã£ããªãœãŒã¹ãå²ãåœãŠãå Žå
ïŒããŒãäžã®ã¡ã¢ãªããã¡ã€ã«èšè¿°åãªã©ïŒããããã®ãªãœãŒã¹ãã¿ã€ã ãªãŒã«åéããè€éããèããå¢å ããŸãã ãŸããJITã«äŸåãã代ããã«ãå®è¡ããäºå®ã®åã¢ãŒããã¯ãã£ã®ã³ãŒããã³ã³ãã€ã«ããå¿ èŠããããŸãã åãã¢ãŒããã¯ãã£ã®è€æ°ã®ããŒãžã§ã³ãã³ã³ãã€ã«ããããšãã§ããŸããG1ã®ARMããã»ããµçšã«ã³ã³ãã€ã«ããããã€ãã£ãã³ãŒãã¯åãããã»ããµãæ倧éã«æŽ»çšã§ããŸããããNexus Oneã§ã¯ãNexus Oneçšã«ã³ã³ãã€ã«ãããã³ãŒãã¯G1ã§å®è¡ãããŸããã
ãã€ãã£ãã³ãŒãã¯ãAndroidã«ç§»æ€ããããã€ãã£ãããŒã¹ããããJavaã¢ããªã±ãŒã·ã§ã³ã®åã ã®éšåãé«éåããªãå Žåã«æã圹ç«ã¡ãŸãã ïŒæå¹ãªJavaã段èœ54ãåç §ããŠãã ãããïŒ
æåŸã«
æåŸã«ãåžžã«æž¬å®ããŸãã æé©åãéå§ããåã«ãåé¡ãããããšã確èªããŠãã ããã æ¢åã®ããã©ãŒãã³ã¹ãæ£ç¢ºã«æž¬å®ã§ããããšã確èªããŠãã ãããããããªããšã代æ¿ãœãªã¥ãŒã·ã§ã³ããåŸãããå©ç¹ã枬å®ã§ããªããªããŸãã
ããã§äœæããããã¹ãŠã®ã¹ããŒãã¡ã³ãã¯ããã¹ãã«ãã£ãŠããã¯ã¢ãããããŸãã ãœãŒã¹ã³ãŒãã¯ãdalvikãããžã§ã¯ãã®code.google.comã«ãããŸãã
ãããã®ãã¹ãã¯ãCaliper埮é枬å®ãã¬ãŒã ã¯ãŒã¯ã䜿çšããŠèšè¿°ãããŠããŸãã ãã€ã¯ã枬å®ãæ£ããå®è¡ããã®ã¯é£ãããããCaliperã䜿çšãããšãããŒãã¯ãŒã¯ãè¡ãããšãã§ãã枬å®ããããšããŠãããã®ã枬å®ããŠããªãå Žåãç¹å®ã§ããŸãïŒããšãã°ãä»®æ³ãã·ã³ãã³ãŒããå®å šã«æé©åããããïŒã Caliperã䜿çšããŠç¬èªã®åŸ®é枬å®ãè¡ãããšã匷ããå§ãããŸãã
ãããã¡ã€ãªã³ã°ã«Traceviewã䜿çšããããšãã§ããŸãããJITããªãã«ãªããJITãåçã§ããå€ãã®ã©ã³ã¿ã€ã ã«ã€ãªããããšãç解ããããšãéèŠã§ãã Traceviewã«ãã£ãŠææ¡ãããå€æŽãè¡ã£ãåŸãTraceviewãªãã§å®è¡ãããå Žåãçµæã®ã³ãŒããå®éã«ããéãå®è¡ãããããšã確èªããããšãç¹ã«éèŠã§ãã