Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53406 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78924 invoked from network); 20 Jun 2011 14:25:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 14:25:54 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:56526] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/F1-34681-1785FFD4 for ; Mon, 20 Jun 2011 10:25:53 -0400 Received: by bwz18 with SMTP id 18so2791032bwz.29 for ; Mon, 20 Jun 2011 07:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=sW8Osa8KRgxW+aGNN4rdtYBHJ2FFJIdOA0EKX5h+H2Q=; b=SKDtXlx4jVlBVlUyx7of4HSWV4bKCh2253jtmeaQ7sNlJYF8i9mMJpvyY0TxxmzMQ8 YbaAdF/S1iaRT6FRFJZgcFGFrpGhx91Hvh8YaLREbhU7UA0rLBd9g2rurD9qBCgysquD 9X4RdhKNHsxJHt59qoC9EbSXJsF7dSqImwYAM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=nl81LM257rExW7r9cRcIkNbQj2KyUVWRAcTriQO65g/6kEqeQvzvcMMC3HbjiMqrZa OJAYyYkK2aIOVVUldDXISFhkW6fFxxFplIczwGVqXdtw2IASTSzOC6E2ZCLf647qjkNy +KyLk00F5TMSl6SkJfDmdmHTp/Fl7VnCp1l/Y= MIME-Version: 1.0 Received: by 10.204.42.11 with SMTP id q11mr1314759bke.131.1308579950060; Mon, 20 Jun 2011 07:25:50 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.204.10.66 with HTTP; Mon, 20 Jun 2011 07:25:49 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Jun 2011 16:25:49 +0200 X-Google-Sender-Auth: Z1F7Kz1y9sSBfaXCOj_ESlR13G0 Message-ID: To: Robert Eisele Cc: Derick Rethans , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Standard constants as part of the lexer From: colder@php.net (Etienne Kneuss) Hi, On Mon, Jun 20, 2011 at 13:12, Robert Eisele wrote: > 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 >> { >> =C2=A0 =C2=A0function true() >> =C2=A0 =C2=A0{ >> =C2=A0 =C2=A0 =C2=A0 =C2=A0return true; >> =C2=A0 =C2=A0} >> } >> >> $A =3D 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 funct= ion > names. A more general solution would be better, instead of hacking such > things without deep considerations in an official tree. Why have them as tokens at all? The optimisation comes from having specific opcodes, not specific tokens. We could keep the current tokens, and thus keeping 100% BC, but check for the content of T_STRING tokens at the parsing level, to dispatch to specific OPCodes in such cases. > > >> >> > 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, t= he > difference wouldn't that much. But constructs like for($i=3D0; $i $i++) could get optimized vigorous. > > >> >> 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 >> > --=20 Etienne Kneuss http://www.colder.ch