Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32326 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58891 invoked by uid 1010); 14 Sep 2007 17:01:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 58875 invoked from network); 14 Sep 2007 17:01:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Sep 2007 17:01:40 -0000 Authentication-Results: pb1.pair.com header.from=nlopess@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=nlopess@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.55.154.23 as permitted sender) X-PHP-List-Original-Sender: nlopess@php.net X-Host-Fingerprint: 212.55.154.23 relay3.ptmail.sapo.pt Linux 2.4/2.6 Received: from [212.55.154.23] ([212.55.154.23:53114] helo=sapo.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/22-44372-96EBAE64 for ; Fri, 14 Sep 2007 13:01:33 -0400 Received: (qmail 26448 invoked from network); 14 Sep 2007 17:01:18 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.208) by relay3 with SMTP; 14 Sep 2007 17:01:18 -0000 Received: (qmail 5573 invoked from network); 14 Sep 2007 17:01:18 -0000 X-AntiVirus: PTMail-AV 0.3-0.91.1 X-Virus-Status: Clean (0.18466 seconds) Received: from unknown (HELO pc07653) (nunoplopes@sapo.pt@[85.240.49.252]) (envelope-sender ) by mta13 (qmail-ldap-1.03) with SMTP for ; 14 Sep 2007 17:01:17 -0000 Message-ID: <001f01c7f6f0$dbcf5350$4001a8c0@pc07653> To: "PHPdev" Cc: , , Date: Fri, 14 Sep 2007 18:01:13 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 Subject: RFC: mark functions as const for possible optimizations From: nlopess@php.net ("Nuno Lopes") 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)