Hi,

Following my last post on bytecode optimization (http://news.php.net/php.internals/32113), I would like to discuss a few more things. The patch in that e-mail allowed the engine itself to do transformations like, e.g.:
$a = 1*2*3*4*5+1-0;   -->  $a = 121;

However the patch is now a bit dead because Stas would like to have more advanced things that I didn't have time yet to look at (because the proposal introduces several difficult ambiguities in the grammar).

So, let's move on for now :P

My proposal is the following:
some functions when fed with constant arguments always return a constant value, too. e.g.:
strlen('abcd') === 4.

This means that an optimizer can and should do this transformation. (and others like: $a='abcd'; strlen($a); -> 4). I think Ilia created a list of such functions in his optimizer. But I would like to have that list in the core, so that everybody can benefit from it. Basically the only thing needed to do is to change PHP_FE() to PHP_CONST_FE() in the function entry tables.

The patch: http://web.ist.utl.pt/nuno.lopes/zend_const_function_entry.txt (includes a few function entries changed as an example)


Nuno

P.S.: the university semester has already started, so don't worry with the e-mail traffic I'm generating because it'll end pretty soon (until the next vacations :P)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to