Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53380 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22812 invoked from network); 20 Jun 2011 11:13:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 11:13:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=robert@xarg.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=robert@xarg.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain xarg.org from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: robert@xarg.org X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:45875] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/87-34681-D3B2FFD4 for ; Mon, 20 Jun 2011 07:13:01 -0400 Received: by vwl1 with SMTP id 1so1047919vwl.29 for ; Mon, 20 Jun 2011 04:12:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.118.146 with SMTP id v18mr1722725vcq.239.1308568378465; Mon, 20 Jun 2011 04:12:58 -0700 (PDT) Received: by 10.220.45.196 with HTTP; Mon, 20 Jun 2011 04:12:58 -0700 (PDT) X-Originating-IP: [92.225.216.141] In-Reply-To: References: Date: Mon, 20 Jun 2011 13:12:58 +0200 Message-ID: To: Derick Rethans Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=00221572697e5cdca204a622d1b6 Subject: Re: [PHP-DEV] Standard constants as part of the lexer From: robert@xarg.org (Robert Eisele) --00221572697e5cdca204a622d1b6 Content-Type: text/plain; charset=ISO-8859-1 2011/6/20 Derick Rethans > On Mon, 20 Jun 2011, Robert Eisele wrote: > > > The constants true, false and null are used very often. Unfortunately, > > every usage of either of these constants invokes a constant lookup. > > There is no problem with this, constant lookups are fast, but I > > nevertheless implemented these constants directly in the lexer to > > avoid these lookups. I'd be glad to see this change in 5.4 as the > > performance enhancement would be a steal. > > Would that not break the following code?: > > class bar > { > function true() > { > return true; > } > } > > $A = new bar; > $A->true(); > ?> > Yes, indeed. But as I wrote, we could add T_SIZEOF (symbol for count + strlen) and T_LVAL (used for constants) as exception for method and function names. A more general solution would be better, instead of hacking such things without deep considerations in an official tree. > > > I've also added a new OP code to hard-code count() and strlen() which > > improves the performance by ~800%. This is nice, but limits the usage > > of count() and strlen() as method name - if no further changes will be > > made at the parser. I would rather see a optimization for every > > function call in 5.4.x. I'll take a look at this soon, maybe I can > > provide a patch for this, too. > > Although it's a nice performance increase, I think that breaking > count() as a method name is not a good idea, as I would assume it's > used a lot. Even though count() and strlen() can be optimised that much, > how much does it buy a fully fledged application? > I think it depends on the experience of the developers. There are many - halfway ugly - "PHP optimization" tricks on the net. If these are used, the difference wouldn't that much. But constructs like for($i=0; $i > Then there is also the deliberation on whether it's good to go this > general direction, because I am sure we can make a case to convert every > function into an opcode perhaps. > This would make extension development much more complicated. > > cheers, > Derick > > grz Robert > -- > http://derickrethans.nl | http://xdebug.org > Like Xdebug? Consider a donation: http://xdebug.org/donate.php > twitter: @derickr and @xdebug > --00221572697e5cdca204a622d1b6--