
ãã®è³æã¯ã6æ2ã3æ¥ã«ãµã³ã¯ãããã«ãã«ã¯ã§éå¬ãããHolyJS 2017äŒè°ã§ã®èè ã®å ±åã«åºã¥ããŠäœæãããŸããã PDFã§ã®ãã¬ãŒã³ããŒã·ã§ã³ã¯ã ãã®ãªã³ã¯ã§èŠã€ããããšãã§ããŸãã
æ ç»ãThe Last Dragon Slayerãã¯æ°ã¶æåã«å ¬éãããŸããã ããã§ãäž»äººå ¬ããã©ãŽã³ã殺ããšãäžçã®éæ³ãæ¶ããŸãã JavaScriptã®äžçã«ã¯éæ³ã®å Žæããªãã®ã§ãä»æ¥ã¯æµã«ãªãããããã©ãŽã³ã殺ãããã åäœãããã¹ãŠãæ瀺çã«æ©èœããŸãã ã©ã®ããã«æ©èœããããç解ããããã«ãã©ã®ããã«æ©èœããããç解ããå¿ èŠããããŸãã
ç§ã¯ããªããšç§ã®æ ç±ãå ±æããããšæããŸãã ããæç¹ã§ãV8ã®å éšã§ã©ã®ããã«æ©èœããã®ãããããªãããšã«æ°ä»ããŸããã ç§ã¯æåŠãèªã¿å§ããäž»ã«è±èªã®ã¬ããŒããèŠãŠãèç©ãããç¥èãäœç³»åãããããããªãã«å±ããããšæããŸãã
ç§ãã¡ã®èšèªã¯è§£éãŸãã¯ã³ã³ãã€ã«ãããŠããŸããïŒ
誰ããéããç¥ã£ãŠããããšãé¡ã£ãŠããŸãããç¹°ãè¿ããŸãã ã³ã³ãã€ã«ãããèšèªïŒãããã®ãœãŒã¹ã³ãŒãã¯ãã³ã³ãã€ã©ã«ãã£ãŠãã·ã³ã³ãŒãã«å€æããããã¡ã€ã«ã«æžã蟌ãŸããŸãã å®è¡åã«ã³ã³ãã€ã«ã䜿çšããŸãã å©ç¹ã¯äœã§ããïŒ åã³ã³ãã€ã«ããå¿ èŠã¯ãããŸãããã³ã³ãã€ã«å¯Ÿè±¡ã®ã·ã¹ãã ã§å¯èœãªéãèªååãããŠããŸãã æ¬ ç¹ã¯äœã§ããïŒ ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãå€æŽãããŠããããœãŒã¹ããªãå Žåã¯ãããã°ã©ã ã倱ãããŸãã
解éãããèšèª-ã€ã³ã¿ãŒããªã¿ãŒããã°ã©ã ã«ãã£ãŠãœãŒã¹ã³ãŒããå®è¡ããããšãã å©ç¹ã¯ãã¯ãã¹ãã©ãããã©ãŒã ãç°¡åã«å®çŸã§ããããšã§ãã ãœãŒã¹ã³ãŒãããã®ãŸãŸæäŸããŸãããã®ã·ã¹ãã ã«ã€ã³ã¿ãŒããªã¿ãŒãããã°ãã³ãŒãã¯æ©èœããŸãã ãã¡ãããJavaScriptã¯è§£éãããŸãã
æŽå²ã«æµžã£ãŠãã ããã Chromeã¯2008幎ã«çºå£²ãããŸãã Googleã¯ãã®å¹Žã«æ°ããV8ãšã³ãžã³ãå°å ¥ããŸããã 2009幎ã«ãNode.jsã¯V8ãšioãæäŸããlibUVã©ã€ãã©ãªã§æ§æãããåããšã³ãžã³ã§å°å ¥ãããŸããã ãã¡ã€ã«ãžã®ã¢ã¯ã»ã¹ãããã€ãã®ãããã¯ãŒã¯ãªã©ã äžè¬ã«ãç§ãã¡ã«ãšã£ãŠéåžžã«éèŠãª2ã€ã®ããšã¯V8ãšã³ãžã³ã«åºã¥ããŠããŸãã ãããäœã§æ§æãããããèŠãŠã¿ãŸãããã

2008幎ããšã³ãžã³ã¯å éšãéåžžã«ã·ã³ãã«ã«ãªããŸããã ãŸããæ¯èŒçåçŽã§ã-ãã®ã¬ã€ã¢ãŠãã¯åçŽã§ããã ãœãŒã¹ã³ãŒãã¯ããŒãµãŒããããŒãµãŒããã³ã³ãã€ã©ãŒã«éãããåºåã§ã¯åæé©åãããã³ãŒããåŸãããŸããã æé©åãé©åã§ã¯ãªãã£ããããåæé©åãããŸããã ãããããããã®å¹Žã«ã¯ããªããã£ãã€ã¶ãå éšã§æé©åããããšãæåŸ ã§ããªãã£ããããããè¯ãJavaScriptãèšè¿°ããå¿ èŠããããŸããã
ãã®ã¹ããŒã ã®ããŒãµãŒã¯äœã§ããïŒ
ãœãŒã¹ã³ãŒããæœè±¡æ§æããªãŒãŸãã¯ASTã«å€æããã«ã¯ãããŒãµãŒãå¿ èŠã§ãã ASTã¯ããã¹ãŠã®é ç¹ãæŒç®åã§ããããã¹ãŠã®èããªãã©ã³ãã§ããããªãŒã§ãã

æ°åŒã®äŸãèŠãŠã¿ãŸãããã ãã®ãããªããªãŒãããããã¹ãŠã®é ç¹ã¯æŒç®åã§ãããåå²ã¯ãªãã©ã³ãã§ãã ããã«ã€ããŠè¯ãããšã¯ãåŸã§ãããããã·ã³ã³ãŒããçæããããšãéåžžã«ç°¡åã§ããããšã§ãã ã¢ã»ã³ãã©ãŒã§åãã人ã¯ãã»ãšãã©ã®å Žåãåœä»€ã¯äœãããããäœããããã§æ§æãããŠããããšãç¥ã£ãŠããŸãã

ãããŠãããã§ãçŸåšã®ãã€ã³ãã«æŒç®åããªãã©ã³ããã確èªã§ããŸãã æŒç®åã®å Žåããã®ãªãã©ã³ãã調ã¹ãŠã³ãã³ããçµã¿ç«ãŠãŸãã

ããšãã°ãé åããããã€ã³ããã¯ã¹1ã§é åããèŠçŽ ãèŠæ±ãããšãJavaScriptã§äœãèµ·ãããŸããïŒ æŒç®åããããŒã§ããããã£ãããŒããããæœè±¡æ§æããªãŒã衚瀺ãããŸãããªãã©ã³ãã¯ããã®ããããã£ãããŒããããªããžã§ã¯ããšããŒã§ãã
ãªãjavascriptã³ã³ãã€ã©ã§ïŒ
ç§ãèšã£ãããã«ãç§ãã¡ã®èšèªã¯è§£éãããŸããããã®ã¹ããŒã ã«ã¯ã³ã³ãã€ã©ããããŸãã ãªãã§ïŒ å®éã«ã¯ã2çš®é¡ã®ã³ã³ãã€ã©ããããŸãã å®è¡åã«ã³ã³ãã€ã«ããäºååŠçã³ã³ãã€ã©ãšãå®è¡æã«ã³ã³ãã€ã«ããJITã³ã³ãã€ã©ããããŸãã ãŸããJITã³ã³ãã€ã«ã«ãããåªããå éãåŸãããŸãã ããã¯äœã®ããã§ããïŒ æ¯èŒããŠã¿ãŸãããã

åãã³ãŒãããããŸãã 1ã€ã¯Pascalããã1ã€ã¯JavaScriptã§ãã ãã¹ã«ã«ã¯çŽ æŽãããèšèªã§ãã JavaScriptã䜿çšããã«ããã°ã©ãã³ã°ãåŠç¿ããå¿ èŠããããšæããŸãã ããã°ã©ãã³ã°ã®æ¹æ³ãåŠã³ãã人ãããå Žåã¯ãPascalãŸãã¯CãèŠããŠãã ããã
éãã¯äœã§ããïŒ Pascalã¯ã³ã³ãã€ã«ãšè§£éã®äž¡æ¹ãå¯èœã§ãJavaScriptã«ã¯è§£éãå¿ èŠã§ãã æãéèŠãªéãã¯éçåä»ãã§ãã

Pascalã§æžããšããå¿ èŠãªå€æ°ãæå®ããŠããããã®åãæžãããã§ãã ã³ã³ãã€ã©ãŒã¯ãæé©åãããé©åãªã³ãŒããç°¡åã«æ§ç¯ã§ããŸãã ã¡ã¢ãªå ã®å€æ°ã«ã©ã®ããã«ã¢ã¯ã»ã¹ããŸããïŒ äœæããããã·ããããããŸãã ããšãã°ãæŽæ°32ã®å Žåããã®ã¢ãã¬ã¹ã§32ãã¡ã¢ãªã«ã·ããããããŒã¿ãååŸããŸãã
JavaScriptã§ã¯ãããããåã¯åžžã«å®è¡æã«å€æŽãããŸããã³ã³ãã€ã©ãŒã¯ããã®ã³ãŒããæåã«å®è¡ããããšãã«ããã®ã³ãŒããæåã«å®è¡ããããšãã«ãåã«é¢ããæ å ±ãåéããŸãã ãããŠãåãæ©èœã2åç®ã«å®è¡ãããšããã©ã®ã¿ã€ãããã£ãããæ³å®ããŠãåååãåã£ãããŒã¿ã«åºã¥ããŠæé©åããã§ã«è¡ãããšãã§ããŸãã å€æ°ããã¹ãŠæ確ãªå Žåãå€æ°ã¯å€ã«ãã£ãŠæ±ºå®ãããŸããããªããžã§ã¯ãã«ã€ããŠã¯ã©ãã§ããããïŒ
çµå±ã®ãšãããJavaScriptãããããããã¿ã€ãã¢ãã«ãããããªããžã§ã¯ãã®ã¯ã©ã¹ã¯ãããŸããã å®éã«ã¯ãããŸããããããã¯èŠããŸããã ãããã¯ãããããé ãã¯ã©ã¹ã§ãã ãããã¯ã³ã³ãã€ã©ãŒã«ã®ã¿è¡šç€ºãããŸãã
é ãã¯ã©ã¹ã¯ã©ã®ããã«äœæãããŸããïŒ

ãã€ã³ãããããŸã-ããã¯ã³ã³ã¹ãã©ã¯ã¿ãŒã§ããããªããžã§ã¯ããäœæãããŸãã ãŸãããã€ã³ãèªäœã®ã¿ãå«ãé衚瀺ã®ã¯ã©ã¹ãäœæãããŸãã

次ã«ããã®ãªããžã§ã¯ãxã®ããããã£ãèšå®ããé衚瀺ã¯ã©ã¹ããã£ããšããäºå®ãããxãå«ã次ã®é衚瀺ã¯ã©ã¹ãäœæãããŸãã

次ã«ãyãèšå®ããããã«å¿ããŠãxãšyãå«ãå¥ã®é衚瀺ã¯ã©ã¹ãååŸããŸãã

ããã§ã3ã€ã®é ãããã¯ã©ã¹ãååŸããŸããã ãã®åŸãåãã³ã³ã¹ãã©ã¯ã¿ãŒã䜿çšããŠ2çªç®ã®ãªããžã§ã¯ããäœæãããšãåãããšãèµ·ãããŸãã ãã§ã«é衚瀺ã®ã¯ã©ã¹ããããããããäœæããå¿ èŠã¯ãããããŸããããããããã ãã§ãã ãã®ãããåŸã§ããã2ã€ã®ãªããžã§ã¯ãã®æ§é ãåäžã§ããããšãããããŸãã ãããŠãããªãã¯åœŒããšä»äºãããŠããããã«èŠããŸãã

ããããåŸã§p2ãªããžã§ã¯ãã«ããããã£ãè¿œå ãããšã©ããªããŸããïŒ æ°ããé衚瀺ã¯ã©ã¹ãäœæãããŸãã p1ãšp2ã¯ãã¯ãé¡äŒŒããŠããŸããã ãªããããéèŠãªã®ã§ããïŒ ã³ã³ãã€ã©ããã€ã³ãã«ãŒããå埩åŠçããp1ãšåããã®ããã¹ãŠæããšããã€ã¹ãããã€ã¹ãããã€ã¹ããp2ã«ã¶ã€ãããå¥ã®é ãããã¯ã©ã¹ããããããã³ã³ãã€ã©ã¯æé©å解é€ã«ãªããŸãã圌ã¯æåŸ ãããã®ãåãåããŸããã§ããã

ããã¯ããããã«ã¢ã¿ã€ãã³ã°ã§ãã ã¢ãã«ã¿ã€ãã³ã°ãšã¯äœã§ããïŒ è¡šçŸã¯ã¢ã¡ãªã«ã®ã¹ã©ã³ã°ããæ¥ãŸãããäœããã¢ãã«ã®ããã«æ©ããã«ãã«ããã¢ãã«ã®ããã§ããã°ãããã¯ã¢ãã«ã§ãã ããªãã¡ p1ãšp2ã®æ§é ãåäžã§ããå Žåããããã¯åãã¯ã©ã¹ã«å±ããŸãã ããããp2ãæ§é ã«è¿œå ããå¿ èŠããããŸãããããã®ã¢ãã«ã¯ããããç°ãªãæ¹æ³ã§ã«ãã«ãé³ãç«ãŠãŸãããããã¯ç°ãªãã¯ã©ã¹ã§ãã
ãããŠããªããžã§ã¯ããã©ã®ã¯ã©ã¹ã«å±ããŠããããã©ã®ãããªå€æ°ããã®ããŒã¿ãã©ãã§äœ¿çšããã©ã®ããã«ä¿åãããã«é¢ããããŒã¿ãååŸããŸããã ãã®ããã«ãã€ã³ã©ã€ã³ãã£ãã·ã¥ã·ã¹ãã ã䜿çšãããŸãã

ãã®éšåã®ã€ã³ã©ã€ã³ãã£ãã·ã¥ã®äœææ¹æ³ãèŠãŠã¿ãŸãããã æåã«ãã³ãŒããåæãããšããã®ãããªåŒã³åºãã§è£è¶³ãããŸãã ããã¯åãªãåæåã§ãã ã€ã³ã©ã€ã³ãã£ãã·ã¥ã®çš®é¡ã¯ãŸã ããããŸããã
ããã§ãããã§åæåãããšèšãããšãã§ããŸããthis.primesã®èªã¿èŸŒã¿ã¯æ¬¡ã®ãšããã§ãã

äž»ãªããŠã³ããŒãã¯æ¬¡ã®ãšããã§ãã

ãããŠãæäœBinaryOperation-ããã¯ãã€ããªã§ããããšãæå³ããã®ã§ã¯ãªããåé æŒç®ã§ã¯ãªããã€ããªã§ããããšãæå³ããŸãã å·Šå³ã®ããŒããããæäœã

å®è¡æã«äœãèµ·ãããŸããïŒ
ã³ãŒããå°çãããšããã¹ãŠã³ã³ãã€ã©å ã«æ¢ã«ããã³ãŒãã«çœ®ãæããããã³ã³ãã€ã©ã¯åæ å ±ãæã£ãŠããå Žåã«ãã®ç¹å®ã®ã±ãŒã¹ã§ããŸãæ©èœããæ¹æ³ãç¥ã£ãŠããŸãã ã€ãŸããããã§ã¯ããªããžã§ã¯ãããçŽ æ°ãååŸããæ¹æ³ãç¥ã£ãŠããã³ãŒããåŒã³åºã代ããã«äœ¿çšãããŸãã

ããã§ã¯ãSMIé åããèŠçŽ ãååŸããæ¹æ³ãç¥ã£ãŠããã³ãŒãã«çœ®ãæããããŸãã

2ã€ã®SMIã®é€ç®ã®å°äœãèšç®ããæ¹æ³ãç¥ã£ãŠããã³ãŒãã次ã«ç€ºããŸãã

ãã§ã«æé©åãããŠããŸãã ãã®ãããã³ã³ãã€ã©ãŒã¯ã»ãŒåäœãããã®ãããªéšåã§é£œåããŸããã

ãã¡ãããããã«ãããªãŒããŒããããçºçããŸãããããã©ãŒãã³ã¹ãåäžããŸãã
ç§ãã¡ã¯ã€ã³ã¿ãŒããããéçºããJavaScriptã®æ°ãå¢å ããããå€ãã®çç£æ§ãå¿ èŠã«ãªããGoogleã¯æ°ããã¯ã©ã³ã¯ã·ã£ããã³ã³ãã€ã©ãäœæããããšã§å¯Ÿå¿ããŸããã

å€ãã³ã³ãã€ã©ã¯FullCodegenãšããŠç¥ãããããã«ãªããŸãããããã¯ãå®å šãªã³ãŒãããŒã¹ã§åäœãããã¹ãŠã®JavaScriptãšãã®ã³ã³ãã€ã«æ¹æ³ãç¥ã£ãŠããããã§ãã ãããŠãæé©åãããŠããªãã³ãŒããçæããŸãã 圌ãäœåºŠãåŒã³åºãããé¢æ°ã«åºããããå Žåã圌ã¯ãããç±ããªã£ããšä¿¡ããŠãããCrankshaftã³ã³ãã€ã©ãŒããããæé©åã§ããããšãç¥ã£ãŠããŸãã ãããŠã圌ã¯åã«é¢ããç¥èãäžãããã®æ©èœã¯æ°ããã¯ã©ã³ã¯ã·ã£ããã³ã³ãã€ã©ã§æé©åã§ããããšã瀺ããŸããã 次ã«ãæ°ããã³ã³ãã€ã©ã¯æœè±¡æ§æããªãŒãååŸããŸãã å€ãASTã³ã³ãã€ã©ããã§ã¯ãªããæ»ã£ãŠASTãèŠæ±ããããšãéèŠã§ãã ãããŠãåãç¥ã£ãŠæé©åãè¡ããæåŸã«æé©åãããã³ãŒããååŸããŸãã
圌ãæé©åãè¡ããªãå Žåã圌ã¯éæé©åã«é¥ããŸãã ããã¯ãã€èµ·ãããŸããïŒ ããšãã°ãé ãã¯ã©ã¹ãµã€ã¯ã«ã§ã¹ãã³ããåŸãäºæãã¬äœããçºçããæé©åã解é€ããããªã©ãåã«èšã£ããšããã§ãã ãŸãã¯ãããšãã°ãå€ãã®äººã ã¯ãå·ŠåŽã«äœãããããšãã«ãã§ãã¯ãè¡ãããšã奜ã¿ãŸããããšãã°ãé·ããååŸããŸãã æååããããã©ããã確èªãããã®é·ããååŸããŸãã ãªããããæªãã®ã§ããïŒ è¡ããªãå Žåãå·ŠåŽã«ããŒã«å€ã衚瀺ãããåºåã¯ããŒã«å€ã«ãªãããã®åã«æ°å€ã衚瀺ãããããã§ãã ãã®å Žåãæé©åã解é€ãããŸãã ãŸãã¯ã圌ã¯ã³ãŒãã«äŒã£ããããããæé©åããããšã¯ã§ããŸããã

äŸãšããŠåãã³ãŒãã䜿çšããŸãã ããã§ã¯ãã€ã³ã©ã€ã³ãã£ãã·ã¥ã§ãã£ã±ãã®ã³ãŒãããããŸãããæ°ããã³ã³ãã€ã©ãŒã§ã¯ãã¹ãŠã€ã³ã©ã€ã³ã§ãã

圌ã¯ããããã¹ãŠã€ã³ã©ã€ã³ã«æ¿å ¥ããŸãã ããã«ããã®ã³ã³ãã€ã©ã¯ææ©çæé©åã³ã³ãã€ã©ã§ãã 圌ã¯äœãæšæž¬ããŠããŸããïŒ åœŒã¯åã®ç¥èãæšæž¬ããŠããŸãã 圌ã¯ããã®ã¿ã€ãã§10ååŒã³åºããå Žåããã®ã¿ã€ãã¯ç¶ç¶ãããšæ³å®ããŠããŸãã 圌ãæåŸ ããã¿ã€ããæ¥ããããªãã§ãã¯ãã©ãã«ã§ãããã圌ãæåŸ ããŠããªãã£ãã¿ã€ããæ¥ããšãã圌ã¯éæé©åã«é¥ããŸãã ãããã®æ¹åã«ããããã©ãŒãã³ã¹ã¯å€§å¹ ã«åäžããŸããããV8ãšã³ãžã³ã«é¢ä¿ããããŒã ã¯åŸã ã«ãã¹ãŠããŒãããå§ããå¿ èŠãããããšã«æ°ä»ããŸããã ãªãã§ïŒ æåã®ããŒãžã§ã³ãäœæãããšãã«ãœãããŠã§ã¢ãéçºããæ¹æ³ã¯ãããŸããã2çªç®ã®ããŒãžã§ã³ãæåããäœæããã®ã¯ãäœææ¹æ³ãç解ããŠããããã§ãã ãããŠã圌ãã¯æ°ããã³ã³ãã€ã©ãŒ-2014幎ã®ã¿ãŒããã¡ã³ãäœæããŸããã

ãœãŒã¹ã³ãŒãããããããã¯ããŒãµãŒã«ã次ã«FullCodegenã³ã³ãã€ã©ãŒã«åé¡ãããŸãã ããã§ãéãã¯ãããŸããã§ããã åºåã§ã¯ãæé©åãããŠããªãã³ãŒããååŸããŸãã ããããçš®é¡ã®æé©åãè¡ãããšãã§ããå ŽåãCrankshaftãšTurbofanã®2ã€ã®ã³ã³ãã€ã©ãŒã«é²ã¿ãŸãã FullCodegenã¯ãTurbofanã³ã³ãã€ã©ãŒãç¹å®ã®ãã®ãæé©åã§ãããã©ãããå€æããå¯èœãªå Žåã¯éä¿¡ããã§ããªãå Žåã¯å€ãã³ã³ãã€ã©ãŒã«éä¿¡ããŸãã ããã§ãES6ããæ°ãããã¶ã€ã³ãåŸã ã«è¿œå ãå§ããŸããã asm.jsãæé©åããããšããå§ããŸããã
ãªãæ°ããã³ã³ãã€ã©ãå¿ èŠãªã®ã§ããïŒ
- åºæ¬çãªããã©ãŒãã³ã¹ãæ¹åãã
- ããã©ãŒãã³ã¹ãäºæž¬å¯èœã«ããŸãã
- ãœãŒã¹ã³ãŒãã®è€éãã軜æž
ãåºæ¬çãªããã©ãŒãã³ã¹ãåäžãããããšã¯ã©ãããæå³ã§ããïŒ
å€ãã³ã³ãã€ã©ã¯ã匷åãªãã¹ã¯ãããããã£ãæ代ã«æžãããŸããã ãããŠããªã¯ã¿ã³ãåæãªã©ã®ãã¹ãã§ãã¹ããããããŒã¯æ§èœããã¹ããããŸããã æè¿ãGoogle I / Oã«ã³ãã¡ã¬ã³ã¹ããããV8ã®éçºã管çããŠãããããŒãžã£ãŒã¯ãã³ã³ãã€ã©ãå®éã«åäœãããã®ã«å¯Ÿå¿ããªããããåºæ¬çã«ãªã¯ã¿ã³ãæŸæ£ãããšè¿°ã¹ãŸããã ãããŠãããã¯ç§ãã¡ãéåžžã«è¯ãããŒã¯ããã©ãŒãã³ã¹ãæã£ãŠãããšããäºå®ã«ã€ãªãããŸããããåºæ¬çãªãã®ãããªãã¡ ã³ãŒãå ã®äºæã¯æé©åãããŠããããããŸãæ©èœããã³ãŒãããã®ãããªäºæã«åºããããšãããã©ãŒãã³ã¹ãå€§å¹ ã«äœäžããŸããã ãããŠããã®ãããªæäœã¯ãããããããŸããããã®ãã¡ã®ããã€ãã以äžã«ç€ºããŸãïŒforEachãmapãreduceã ãããã¯ããã§ãã¯ãè©°ãããã¬ãŒã³ãªJSã§æžãããŠããŸãã é »ç¹ã«äœ¿çšããããšããå§ãããŸãã
ãã€ã³ãã®é ãåäœ-å éšçã«å®è£ ãããŠãããå®å šã«æãããããšãå€æããŸããã å€ãã®ãã¬ãŒã ã¯ãŒã¯ãç¬èªã®ãã€ã³ãå®è£ ãäœæããŸããã å€ãã®å Žåã人ã ã¯ç§ã座ã£ãŠèã®äžã«ãã€ã³ããæžãããšèšã£ãŠãé©ãã»ã©éãåäœããŸãã try {} catchïŒeïŒ{}ïŒãããŠæåŸã«ïŒãå«ãé¢æ°ã¯éåžžã«é ãã§ãã

å€ãã®å Žåãããã©ãŒãã³ã¹ãäœäžããªãããã«ã䜿çšããªãæ¹ãè¯ãã¿ãã¬ããããããŸããã å®éãã³ã³ãã€ã©ãæ£åžžã«åäœããŠããªããããã³ãŒãã¯é ããªããŸãã ãŸããã¿ãŒããã¡ã³ã®åºçŸã«ããããã¹ãŠããã§ã«æé©åãããŠããããããããå¿ããããšãã§ããŸãã ãŸããéåžžã«éèŠã§ãïŒéåæé¢æ°ã®ããã©ãŒãã³ã¹ãæ¹åãããŸããã

ãããã£ãŠã誰ããæè¿ãªãªãŒã¹ãããæ°ããããŒãã®ãªãªãŒã¹ãåŸ ã£ãŠããŸã;ããã§ã¯éåæ/åŸ æ©ã®ããã©ãŒãã³ã¹ãéèŠã§ãã ç§ãã¡ã®èšèªã¯æåã¯éåæã§ãããã³ãŒã«ããã¯ã®ã¿ãããŸã䜿çšã§ããŸããã ãŸããpromiseã䜿çšããŠèšè¿°ããŠãã人ã¯ããµãŒãããŒãã£ã®å®è£ ããã€ãã£ãã®å®è£ ãããé«éã§ããããšãç¥ã£ãŠããŸãã
次ã®èª²é¡ã¯ãããã©ãŒãã³ã¹ãäºæž¬å¯èœã«ããããšã§ããã ãã®ãããªç¶æ³ããããŸããïŒjsPerfã§æ£åžžã«å®è¡ãããã³ãŒãã¯ãåäœäžã®ã³ãŒãã«è²Œãä»ãããããšãã«ãŸã£ããç°ãªãããã©ãŒãã³ã¹ã瀺ããŸããã ããããã³ãŒããåœåã®æåŸ ã©ããã«çç£çã«æ©èœããããšãä¿èšŒã§ããªãã£ãå ŽåããããŸãã

ããšãã°ãmymaxãåŒã³åºãéåžžã«åçŽãªã³ãŒãããããããããã§ãã¯ãããšïŒããŒtrace-optããã³trace-deoptã䜿çšããŠãã©ã®é¢æ°ãæé©åãããã©ã®é¢æ°ãæé©åãããªãã£ããã瀺ããŸãïŒã

ãããããŒãã§å®è¡ããããV8ããã©ãŠã¶ãŒãšã¯å¥ã«åäœããç¹å¥ãªç°å¢ã§ããD8ã§å®è¡ã§ããŸãã æé©åãç¡å¹ã«ãªã£ãŠããããšãããããŸãã æ€èšŒã®ããã«äœåºŠãå®è¡ãããããã§ãã åé¡ã¯äœã§ããïŒ åŒæ°ã®æ¬äŒŒé åã倧ããããããšãããããå éšã§ã¯ããã®é åã®ãµã€ãºã®ãã§ãã¯ãè¡ãããããšãããããŸããã ããã«ããã®ãã§ãã¯ã¯ãBenedikt MeurerïŒTurbofanã®ãªãŒãéçºè ïŒãèšã£ãããã«ãäœã®æå³ããããŸããã§ããããé·å¹Žã«ããã£ãŠã³ããŒããŒã¹ãã§åŠçãããŠããŸããã
ãããŠããªãé·ããå¶éãããŠããã®ã§ããïŒ çµå±ã®ãšãããã¹ã¿ãã¯ã®ãµã€ãºã¯ãã§ãã¯ããããäœããã§ãã¯ãããŸããã§ããã ããã¯ãæé€ããå¿ èŠãããäºæããªãåäœã§ãã

å¥ã®äŸãšããŠãããã§ã¯2ã€ã®ã³ãŒã«ããã¯ãåŒã³åºããã£ã¹ãããã£ãŒããããŸãã ãŸãã圌ãåŒã³åºããšã圌ãæé©åãããŠããªãããšãããããŸãã ããã§åé¡ã¯äœã§ããïŒ ãã®1ã€ã®é¢æ°ã¯å³å¯ã§ããã2çªç®ã®é¢æ°ã¯å³å¯ã§ã¯ãããŸããã ãŸããå€ãã³ã³ãã€ã©ã§ã¯ç°ãªãé ãã¯ã©ã¹ãååŸããŸãã ããªã㡠圌ã¯ããããç°ãªããšèããŠããŸãã ãŸãããã®å Žåã圌ã¯æé©åã解é€ããŸãã ãã®ã³ãŒããšä»¥åã®ã³ãŒãã®äž¡æ¹ã¯ãååãšããŠæ£ããèšè¿°ãããŠããŸãããæé©åãããŠããŸããã ããã¯äºæ³å€ã§ãã

ãŸããTwitterã§ãã®ãããªäŸããããããã€ãã®ã±ãŒã¹ã§ã¯chromeã®forã«ãŒããreduceãããé ãåäœããããšãå€æããŸããã reduceã®æ¹ãé ãããšã¯ããã£ãŠããŸããã åé¡ã¯ãäºæããã«forå ã§letã䜿çšãããŠããããšãå€æããŸããã ãã®æç¹ã§ææ°ããŒãžã§ã³ãã€ã³ã¹ããŒã«ããŸããããçµæã¯ãã§ã«è¯å¥œã§ã-ä¿®æ£æžã¿ã

次ã®ãã€ã³ãã¯ãè€éãã軜æžããããšã§ããã ããã«ã¯ããŒãžã§ã³V8 3.24.9ãããã4ã€ã®ã¢ãŒããã¯ãã£ããµããŒãããŠããŸããã

V8ã¯9ã€ã®ã¢ãŒããã¯ãã£ããµããŒãããããã«ãªããŸããïŒ

ãããŠãã³ãŒãã¯äœå¹Žãèç©ãããŠããŸããã JSãã¢ã»ã³ãã©ãŒãCã§éšåçã«æžãããŠãããããããŒã ã«æ¥ãéçºè ã¯ãã®ããã«æããŸããã

äžçã®å€åã«å¯Ÿå¿ã§ããããã«ãã³ãŒãã¯ç°¡åã«å€æŽã§ããå¿ èŠããããŸãã ãŸããã¿ãŒããã¡ã³ã®å°å ¥ã«ãããã¢ãŒããã¯ãã£åºæã®ã³ãŒãã®éãæžå°ããŸããã

2013幎ãã2017幎ã«ãããŠãã¢ãŒããã¯ãã£åºæã®ã³ãŒãããã29ïŒ å°ãªããªããŸããã ããã¯ãæ°ããã¿ãŒããã¡ã³ã³ãŒãçæã¢ãŒããã¯ãã£ã®ç»å Žã«ãããã®ã§ãã

圌ãã¯ãããããŒã¿é§ååãã€ãŸã å¶åŸ¡ãããŒã°ã©ãããããããã«äœãèµ·ãããã«ã€ããŠã®ããŒã¿ãšç¥èãå«ãŸããŠããŸãã ãããŠãããã¯äžè¬çãªã³ãã³ãã»ã¬ã¯ã¿ãŒã«åé¡ãããã¬ãžã¹ã¿ã®äºçŽãããã次ã«ç°ãªãã¢ãŒããã¯ãã£ã®ã³ãŒãçæããããŸãã ããªãã¡ éçºè ã¯ãç¹å®ã®ã¢ãŒããã¯ãã£åãã«ãã¹ãŠãã©ã®ããã«èšè¿°ãããŠããããç¥ãå¿ èŠã¯ãªããªããŸããããããäžè¬çãªã³ãŒããäœæã§ããŸãã ããããããã§ãã³ãŒãã¯ããæ¹åãããŸããããã€ã³ã¿ãŒããªã¿ãŒèšèªçšã®ã³ã³ãã€ã©ãŒãæžããŠããæ°å¹ŽåŸã«ã¯ãã€ã³ã¿ãŒããªã¿ãŒãå¿ èŠã§ããããšãããããŸããã
ãã®çç±ã¯äœã§ããïŒ ãã®çç±ã¯ãSteve Jobsã®æã«ããã£ãŠããŸãã

ãã¡ãããããã¯iPhoneèªäœã§ã¯ãªããiPhoneãçã¿åºããã¹ããŒããã©ã³ã§ãããã€ã³ã¿ãŒããããžã®äŸ¿å©ãªã¢ã¯ã»ã¹ãå¯èœã«ããŸããã ãããŠããã¯ãã¢ãã€ã«ããã€ã¹äžã®ãŠãŒã¶ãŒã®æ°ããã¹ã¯ãããäžã®æ°ãè¶ ãããšããäºå®ã«ã€ãªãããŸããã

ãããŠåœåãã³ã³ãã€ã©ã¯ã¢ãã€ã«ããã€ã¹çšã§ã¯ãªãã匷åãªãã¹ã¯ãããçšã«èšèšãããŠããŸããã

ããã¯ã1MB JavaScriptã®åæåæã¿ã€ã ã©ã€ã³ã§ãã ãããŠæè¿ãVKontakteãã¯ã©ã€ã¢ã³ãã¬ã³ããªã³ã°ã§ã¯ãªããµãŒããŒã¬ã³ããªã³ã°ãè¡ãçç±ã«ã€ããŠè³ªåããããŸããã JSåæã«è²»ããããæéã¯ãã¢ãã€ã«ããã€ã¹ã§ã¯2ã5åé·ããªãå¯èœæ§ãããããã§ãã ãããŠãæã ã¯ããããšã³ãã®ããã€ã¹ã«ã€ããŠè©±ããŠããããããŠäººã ã¯ãã°ãã°å®å šã«ç°ãªããã®ã§è¡ãã
ãã1ã€ã®åé¡ïŒå€ãã®äžåœã®ããã€ã¹ã«ã¯512 MBã®ã¡ã¢ãªããããV8ã¡ã¢ãªã®å²ãåœãŠæ¹æ³ãèŠããšãå¥ã®åé¡ããããŸãã

ã¡ã¢ãªã¯ããªããžã§ã¯ãïŒã³ãŒãã䜿çšãããã®ïŒãšã³ãŒããªããžã§ã¯ãïŒã³ã³ãã€ã©ã䜿çšãããã®ã§ã-ããšãã°ãã€ã³ã©ã€ã³ãã£ãã·ã¥ãããã«æ ŒçŽããïŒã«åãããŠããŸãã å éšäœ¿çšããµããŒãããããã«ãã¡ã¢ãªã®30ïŒ ãä»®æ³ãã·ã³ã«ãã£ãŠå æãããŠããããšãããããŸããã , .
- , 2016 Android Ignition.

, , Turbofan, , - . -.

-, JavaScript , .
- , â . - assembler, . , .
, .

, .
, . accumulator ( , , ) smi integer 100.

, a2 ( 150) (100). accumulator 50.

, r0. d.

. b, accumulator, a0 , , 105.

. , .
, , inline caches. â Data-driven IC, . â , â .

. - , , , - . , , , . inline caches, , , . , , , . .
.

Turbofan. , FullCodegen JS, Crankshaft â JS, Turbofan JS JS. , , , , , . .

, ( , ES6 , ). , , . ããªãã¡ , hidden class â , , . hidden class, , , .
V8 JIT-. JIT- â . JIT- , , , . , , - . , . a+b â . , number+number string+string, . JIT-.
, (, ). â . Turbofan , , .
â . , . , , , . . - , . - . .
. , . , ( , , ).
.
github.com/v8/v8/wiki/TurboFan
http://benediktmeurer.de/
http://mrale.ph/
http://darksi.de/
https://medium.com/@amel_true
JS , , , HolyJS :
- Better, faster, stronger â getting more from the web platform (Martin Splitt)
- The Post JavaScript Apocalypse (Douglas Crockford)
- Testing serverless applications (Slobodan Stojanovic)