Re: Type specialised opcode handlers
| From: | Dmitry Stogov | Date: | Thu, 17 Mar 2016 07:08:23 +0000 |
| Subject: | Re: Type specialised opcode handlers | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91729@lists.php.net to get a copy of this message | ||
I had to open another PR, because the old one was accidentaly merged and reverted.
https://github.com/php/php-src/pull/1825
I've also simplified specialization conditions a bit and started to use ZVAL_LONG() instead of
ZVAL_COPY_VALUE(), as Bob and Xinchen suggested.
Thanks. Dmitry.
________________________________________
From: Dmitry Stogov <dmitry@zend.com>
Sent: Wednesday, March 16, 2016 04:04
To: Nikita Popov; Xinchen Hui; Bob Weinand; bogdan.andone@intel.com
Cc: internals@lists.php.net
Subject: [PHP-DEV] Re: Type specialised opcode handlers
This is the final version: https://github.com/php/php-src/pull/1824
Thanks. Dmitry.
________________________________
From: Dmitry Stogov
Sent: Friday, March 11, 2016 17:31
To: Nikita Popov; Xinchen Hui; Bob Weinand
Subject: Type specialised opcode handlers
Hi,
I like to inform you that I'm working on implementation of type specialized opcode handlers.
DFA pass collects all necessary information, and opcode substitution become a really simple task.
I know, Nikita made similar work in his SSA-based PHP optimiser, but the type inference problem is,
actually, solved long time ago in php-jit project.
The PoC is here: https://gist.github.com/dstogov/74b2845116d5e53108dd
This PoC is to measure the impact of optimisation only (php should be compiled with
-DHAVE_DFA_PASS=1)
It increases PHP code size by 6KB, Mandelbrot becomes ~30% faster, bench.php ~5% faster, real-life
apps are not affected.
However, I don't like to introduce new opcodes like ZEND_ADD_INT.
I like to use the same ZEND_ADD opcode and make optimizer to update opline->handler accordingly
to inferred types.
I think, it's possible to "save" inferred type info in opline->extended_value, and
later relay on it in zend_vm_get_opcode_handler().
So all the magic is going to be done in zend_vm_gen.php.
Related ideas are welcome.
P.S. You might see my recent commits into zend_vm_gen.php that introduce extra specializations
useful for this.
Thanks. Dmitry.