ãã®è¨äºã¯PHP Advent Calendar 2014ã®7æ¥ç®ã§ãã
åã¯å æ¥ã®PHPã«ã³ãã¡ã¬ã³ã¹2014ã§PHP7ã«é¢ããLTããã¾ããï¼åç §ï¼ãPHPNGの動向ãï¼ããã ãæéãéããã¦ãããã¨ãããããã¾ãè¸ã¿è¾¼ãã å 容ã«ã¯è§¦ãã¾ããã§ããã
æ¬ç¨¿ã§ã¯LTã®å
容ããæ·±æãããzvalã¨ããå
é¨çãªæ§é ä½ãã©ãå¤ããã®ããæ§è½é¢ã®ã¡ãªããã«ãã©ã¼ã«ã¹ãã¦è§£èª¬ãã¦ã¿ã¾ãã
PHPãã¨ãã¾ãç¶æ³
ã¾ãæè¿ã®PHPã®è©±é¡ããããããã¦ããã¾ãããã
ããã¾ã§PHPã«ã¯å®ç¨ã¬ãã«ã®å¥å®è£ ãåå¨ããªãç¶æ ãç¶ãã¦ãã¾ããããHHVMã®ç»å ´ã§ç¶æ³ãå¤ãã£ã¦ãã¾ãããHHVMã¯Facebookãéçºãã¦ããPHPå®è¡ç°å¢ã§ãPHPããé«éã§äºææ§ãé«ãã®ãç¹å¾´ã§ããFacebookã§å®éã«å©ç¨ããã¦ããã ãã§ãªããä»ã®ä¼æ¥ã§ãåç¨ãµã¼ãã¹ã§å©ç¨ããäºä¾ãå¢ãã¦ãã¦ãã¾ãã
ãããªä¸ã2014å¹´ã®ã¯ããé ã«PHPã®æ§è½æ¹åããã¸ã§ã¯ãPHPNGãã¹ã¿ã¼ããã¾ãããããã¯PHPã³ããã¿ã¼ã§ããZend Technologies社å¡ã§ãããDmitry Stogovã«ãããã®ã§ãPHPå é¨ã®ãã¼ã¿æ§é ã®å¤æ´ããããã¨ã§PHPã®è¨èªä»æ§ãå¤ããã«æ§è½æ¹åãè¡ããã®ã§ãããã®ããã¸ã§ã¯ãã¯æ¥µãã¦é 調ã«é²ã¿ã2014å¹´8æã«ã¯PHP7ã®ãã¼ã¹ããã¸ã§ã¯ãã¨ãã¦æ¡ç¨ããã¾ããã
説æãåå¾ãã¦ãã¾ãã¾ãããPHPã®ãã¼ã¸ã§ãã³ã°ã«ã¤ãã¦ãæè¿åããããã¾ãããç¾æç¹ã§ã®PHPã®ææ°çã¯5.6.3ã§ãããæ¬¡ã®ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã¢ããã§7.0ã«ãªããã¨ã決ã¾ã£ã¦ãã¾ãï¼åç §ï¼ãPHP RFC: Name of Next Release of PHPãï¼ãPHP7ã¯2015å¹´11æã®ãªãªã¼ã¹ãç®æãã¦ããã2015å¹´6æã«ã¯ã³ã¼ãããªã¼ãºãã¦RC1ãåºãäºå®ã§ãï¼åç §ï¼ãPHP RFC: PHP 7.0 timelineãï¼ã
ã¡ãªã¿ã«ãPHP7ã§ã®æ§è½æ¹åã¯ããªãé²ãã§ãã¾ããä¸è¨ã°ã©ãã¯ZendCon 2014ã§ã®çºè¡¨ããã®å¼ç¨ã§ãããWordPressã§ãã³ããã¼ã¯ãã¹ãããã¨ãã«PHP5.6ã®ç´1.7åãHHVMã«å¹æµããæ§è½ã¨ãªã£ã¦ãã¾ãã
ï¼ãPHPNG a New Core for PHP7ãããï¼
PHP7ã§zvalãå¤ãã£ã
ããããæ¬é¡ã§ããæ¢ã«ç´¹ä»ãã¾ããããPHP7ã§ã¯å é¨çãªãã¼ã¿æ§é ã夿´ããã¦ããããããæ§è½æ¹åã«è²¢ç®ãã¦ãã¾ãã
ä¸ã§ããzvalæ§é ä½ã®å¤æ´ã¯ããªã大èãªå 容ã ã¨è¨ãã¾ããzvalã¯å ¨ã¦ã®PHP夿°ã管çããããã®ãã¼ã¿æ§é ã§ãããä»åã®å¤æ´ã¯PHPã½ã¼ã¹ã³ã¼ãå ¨ä½ã«å½±é¿ãããããªå¤§å¤æ´ã«ãªã£ã¦ãã¾ããããã«æ³¨ç®ãããã¨ãããããããã£ããã¨ã¯ããªãã®hackã ã¨æãã¾ãã
以ä¸ããã®zvalæ§é ä½ã®å¤æ´å
容ã«ã¤ãã¦å³ã交ãã¦èª¬æãã¦ããã¾ãã
æ´æ°åã®å ´å
以ä¸ã®èª¬æã¯å ¨ã¦64bitç°å¢ãåæã«ãã¦ãã¾ããæ¬¡ã®å³ã¯PHP5ã®æ´æ°åã®å¤æ°1åã«å¯¾å¿ããzvalãå³ç¤ºãããã®ã§ãã
ãã®å³ã®æ¨ªå¹ ã¯8bytesã表ãã¦ãã¾ããããã¾ã§PHP5ã§ã¯ãunusedãã¨ãªã£ã¦ãã8+2=10bytesãç¡é§é£ããã¦ãããã¨ããããã¾ãã
ãã¡ããPHP7ã§ã®åæ§ã®å³ã§ããPHP5ããPHP7ã§ã¯zvalã®ãµã¤ãºã24bytesãã16bytesã«æ¸ã£ã¦ãããã¨ããããã¾ãã
ã¾ããPHP7ã§ã¯åç §ã«ã¦ã³ã¿ï¼refcountï¼ãzvalããæ¶ãã¦ããã®ãç¹å¾´çã§ããPHP5ã§ã¯å ¨ã¦ã®åãã³ãã¼ãªã³ã©ã¤ãæ¹å¼ã§ç®¡çããã¦ããããzvalã§åç §ã«ã¦ã³ã¿ãæã£ã¦ãã¾ãã䏿¹ãPHP7ã§ã¯NULLã»çå½å¤ã»æ´æ°ã»æµ®åå°æ°ç¹æ°ã®4ã¤ã®åã§ã¯åºæ¬çã«ã¹ã«ã©ã¼å¤ãã³ãã¼ãããããã«ãªããåç §ã«ã¦ã³ã¿ãç¡ããªã£ã¦ããã®ã§ãã
ããã«ãPHP5ã®å³ã«æããã¦ããzvalã¸ã®ãã¤ã³ã¿ï¼ç½ãåè§ï¼ãPHP7ã®æ¹ã«ç¡ãç¹ã«ã注æãã¦ãã ãããPHP颿°ãå¼ã³åºãã¨ãã®å¼æ°ãªã©ãPHP5ã§ã¯å¤ãã®å¦çã§zvalã¸ã®ãã¤ã³ã¿ãå¼ãåãã¦ããã®ã§ãããPHP7ã§ã¯zvalãå¼ãåãããã«ãªã£ã¦ãã¾ããã¤ã¾ããPHP5ã§ã¯æ´æ°åã®å¤æ°1åãæ±ãã¨ãã«zvalã®å®ä½ã¨åããã¦32bytesæ¶è²»ããã®ã«å¯¾ããPHP7ã¯åãå
容ã16bytesã§è¡¨ç¾ã§ããã®ã§ããã¾ãããã¤ã³ã¿åç
§ã1忏ãã¨ããæå³ã§ãPHP7ã®æ¹ãæå©ãªã¯ãã§ãã
æåååã®å ´å
次ã«ãæåååã®ã¨ãã®zvalãè¦ã¦ã¿ã¾ãããã
PHP5ã®å ´åãzvalæ§é ä½ã§æååã¸ã®ãã¤ã³ã¿ã¨æååé·ã管çãã¦ãã¾ããæå忬ä½ã¯ãã¤ã³ã¿ã®åç §å ã«å¥é確ä¿ããã¦ãã¾ãã
PHP7ã§ã¯æååé·ã¨åç §ã«ã¦ã³ã¿ï¼refcountï¼ã¯zvalã§ãªãããã¤ã³ã¿ã®å ã®zend_stringæ§é ä½ã§ç®¡çããããã«å¤æ´ããã¦ãã¾ãã
zend_stringæ§é ä½ã®å é ã«åæ å ±ï¼typeã¨flagsï¼ãããã¾ãããããã¯æ§è½ã稼ãããã«zvalã¨åãæ å ±ãéè¤ãã¦æã¤ãããªå½¢ã«ãªã£ã¦ãã¾ããããã«ãhash_valueã¨ããè¨ç®ããããã·ã¥å¤ããã£ãã·ã¥ãã¦ããããã®é åãæ°ãã«è¿½å ããã¦ãã¾ãããããã®çµæã¨ãã¦æ¶è²»ã¡ã¢ãªéã®è¦³ç¹ã§ã¯PHP5ã«æ¯ã¹ã¦PHP7ã®æ¹ã4bytesæããããã¨ã«ãªãã¾ãã
䏿¹ã§ããã¤ã³ã¿åç §ã1忏ã£ã¦ããã®ã¯PHP7ã®æ¹ãæå©ãªç¹ã¨è¨ãã¾ãã
ã¾ããPHP5ã®æåååã§ã¯æååé·ã¨æå忬ä½ãã¡ã¢ãªä¸ã§é¢ãã¦ããããã®ä¸¡è
ãèªã¿æ¸ãããã¨ãã«ã¡ã¢ãªã¢ã¯ã»ã¹ããã£ãã·ã¥ã¢ã¯ã»ã¹ãå¿
ã2åå¿
è¦ã«ãªã£ã¦ãã¾ãã¾ãã䏿¹ãPHP7ã®å ´åã¯ä¸¡è
ãåºã¾ã£ãã¡ã¢ãªé åã«åå¨ãã¦ãã¾ããåæã«æ±ããã¼ã¿ã¯ã¡ã¢ãªä¸ã§ã®ç©ºéç屿æ§ãé«ãæ¹ããã£ãã·ã¥ãæå¹ã«ä½¿ããããã§ãããããããã観ç¹ã§ãPHP7ã®æ¹ãæå©ã§ãããã
æ´æ°åã®åç §ã®å ´å
次ã«ãåç
§ä»£å
¥ããã¨ãã®zvalãè¦ã¦ã¿ã¾ããããããã¯ããã¨ãã°æ¬¡ã®ãããªã³ã¼ããæ¸ããã¨ãã«ç¸å½ãã¾ãã
<?php $a = 1; $b = &$a;
PHP5ã¯ã次ã®ããã«is_refï¼åç
§ãã©ããï¼ã¨ãããã©ã°ãzvalä¸ã«ãããããé常ã®å¤æ°ã¨åç
§ã¨ã®éãã¯ãã®ãã©ã°ã ãã«ãªãã¾ãã
䏿¹ãPHP7ã§ã¯is_refã¯å»æ¢ãããåç §ã¯åã®ä¸ç¨®ã¨ãã¦æ±ãããããã«ãªãã¾ãããæ¬¡ã®ããã«ãtypeã®é¨åã®å¤ãIS_REFERENCEã«ãªãã¾ãã
PHP5ã¨PHP7ã¨ãè¦æ¯ã¹ãã¨ã夿°2ã¤åã«å¯¾å¿ããã¡ã¢ãªæ¶è²»éã¯40bytesãã56bytesã«å¢å ãã¦ãããã¨ããããã¾ãã
ããã ãã§ãªããé常ã®å¤æ°ã®ã¨ãã¨æ§é ãéããããã®ã§ãåç
§ä»£å
¥ããã¿ã¤ãã³ã°ã§ã¡ã¢ãªç¢ºä¿ã¨zvalã®ã³ãã¼ã®ã³ã¹ããããã£ã¦ãã¾ãã¾ãï¼ãæ´æ°åã®å¤æ°ï¼PHP7ï¼ãã¨ãæ´æ°åã®åç
§ï¼PHP7ï¼ããè¦æ¯ã¹ã¦ã¿ã¦ãã ããï¼ãããã¯PHP5ã®ã¨ãã«æ¯ã¹ã¦åç
§ä»£å
¥ã®ã³ã¹ããé«ããªã£ã¦ããã¨è¨ããã§ãããã
ã¾ã¨ã
ç¹å¾´çãªåã«ã¤ãã¦å³ã交ãã¦ç´¹ä»ãã¦ãã¾ããããPHP7ã§ã®zvalã®å¤æ´ç¹ã¯ããããæ¬¡ã®ããã«ã¾ã¨ãããã¾ãã
- åç
§ä»¥å¤ã®å
¨ã¦ã®PHPåã«ã¤ãã¦ããã¼ã¿ã®æã¡æ¹ã¨å¼ãåãæ¹ã®å·¥å¤«ã§ãã¤ã³ã¿åç
§ã1段æ¸ããã
- åç §ã ãã¯åé·ãªæ§é ã«ãªã£ã
- ã¹ã«ã©ã¼å¤ã«å¯¾å¿ãã夿°åã«ã¤ãã¦ã¯åç §ã«ã¦ã³ããå©ç¨ããã³ãã¼ãªã³ã©ã¤ãã廿¢ããå¤ã®ã³ãã¼ãè¡ãããã«ãªã£ã
- ä»ã®åã«ã¤ãã¦ã¯PHP5ã¨æåã¯åãã¾ã¾ããã¼ã¿æ§é ã®å¤æ´ã§ã¡ã¢ãªã¢ã¯ã»ã¹ã®å±ææ§ãé«ãã
ããããè«ã¨ãã¦ãã³ãã¼ãªã³ã©ã¤ãã¯å¤§ãããµã¤ãºã®ãã¼ã¿ã³ãã¼ãé¿ãããããªå ´åã«æå©ãªæ¦ç¥ã§ããããããã¾ã§ã®PHPã§æ´æ°ã®ãããªãµã¤ãºã®å°ãã夿°å¤ã¾ã§ã³ãã¼ãªã³ã©ã¤ãã®å¯¾è±¡ã«ãã¦ããã®ã失æã ã£ãã¨ãè¨ãã¾ããã¾ãããã¤ã³ã¿åç
§ãæ¸ãããããã¡ã¢ãªã¢ã¯ã»ã¹ã®å±ææ§ãé«ãããªã©ãçºæ³ã¨ãã¦çªé£ã ã¨ã¯æãã¾ããããã ããããããå½ããåãã®æ¹åãPHPã®ãããªå·¨å¤§ããã¸ã§ã¯ãã§ããåãã®ã¯åããã¨ã ã¨æãã¾ãã
ã¡ãªã¿ã«ãPHP7ã§ã¯zval以å¤ã«æååã¨é
åã«ã¤ãã¦ããã¼ã¿æ§é ã®è¦ç´ããè¡ããã¦ãã¾ããããããç´°ãããã¥ã¼ãã³ã°ã®ç©ã¿éããPHP7ã®éãã®è¦å ã¨è¨ããã§ãããã詳ããã¯åèè³æãã確èªãã ããã
åèè³æ
- PHPNG a New Core for PHP7 Dmitry Stogovã«ããZendCon 2014ã®çºè¡¨è³æ
- PHPNG (next generation) PHPNGã®æ¦è¦ã¨é²æç´¹ä»ãã¨ãã©ãææ°ã®ãã³ããã¼ã¯çµæãæ´æ°ãããã
- PHPNG Implementation Details
- Upgrading PHP extensions from PHP5 to NG






