Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43919 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92975 invoked from network); 13 May 2009 08:40:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2009 08:40:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=paul.biggar@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=paul.biggar@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.46.31 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: paul.biggar@gmail.com X-Host-Fingerprint: 74.125.46.31 yw-out-2324.google.com Received: from [74.125.46.31] ([74.125.46.31:23540] helo=yw-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/6B-64369-5878A0A4 for ; Wed, 13 May 2009 04:40:38 -0400 Received: by yw-out-2324.google.com with SMTP id 3so258481ywj.83 for ; Wed, 13 May 2009 01:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=nwwDU2MFRqP27AOYwpzL0kPNhV5TuZLZOS2oUcRcxIk=; b=EWx1NRQVI84D/yjkxkPPHfX1HTo2bBo+vq4rxJV0NHZtY/196MAT9Xx44Fd6EuZ1N6 HcuUhY32/TS5/M5r+ia8grFpYC3Gye1N6QL5tgV8678hIwUuJwQaldRJ8d/CK+c4idvz UgEh5rufyFEng5uBYepAiajvcx5N021wQLpr0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=JfmJ+SzKV50GZILVQ7I2UTA7BiQUdl5+RsRUuF88HaHDMximaBHsTcfGYqVtZzwrj2 d6SifUAbDT1SNwwABX8onv7JGOKnAQszQ7r/1ImbS/vTZ9xTRJlwJ5uzizgM21EiIbOr KIG2Z0dVzN4ObSDkzLbJoDF69NZY5RVwRvzSE= MIME-Version: 1.0 Received: by 10.231.14.141 with SMTP id g13mr386892iba.55.1242204035171; Wed, 13 May 2009 01:40:35 -0700 (PDT) In-Reply-To: <4A09BECD.3000602@zend.com> References: <155749706.20090117211737@marcus-boerger.de> <497872B8.60807@zend.com> <4A08CA5F.7010200@zend.com> <4A09BECD.3000602@zend.com> Date: Wed, 13 May 2009 09:40:15 +0100 Message-ID: To: Stanislav Malyshev Cc: Guilherme Blanco , Dmitry Stogov , Marcus Boerger , Timm Friebe , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Method call improvements From: paul.biggar@gmail.com (Paul Biggar) Hi Stas, On Tue, May 12, 2009 at 7:24 PM, Stanislav Malyshev wrote: > Hi! > >> Apologies, I'm not familiar with run-time inheritence in PHP. My >> understanding was that when a classes source code is compiled, its >> parent classes must be known. When is this not the case? Must it be >> known for the class' first instantiation? > > No, the problems here are different. The process works as follows: > 1. Class X source is compiled. > 2. "X" is added to the class table > 3. Class Y (extends X) source is compiled. > 4. Since Y extends X, methods of X are added to methods of Y > 5. "Y" is added to the class table > > Now, adding bytecode caching. Bytecode caching replaces steps 1 and 3 with > "loaded from cache" - however since the identity of X can change between > requests, what is stored for step 3 can not bind to X as it is now - for > that there's step 4 which is executed at runtime, when the line where class > is defined is executed. That means static table describing class Y can exist > only after step 4, and it is not cacheable beyond the bounds of one request. Great explanation, thank you. As far as terminology goes, this is still static inheritance, as you cannot change a class' parent after it has been "set" in a request. Run-time inheritance is where it can change, for example in Javascript where an object's prototype can be changed. I think you could do lookup caches (ie the OP's patch) either way, but its probably cheaper with static inheritance. > However, if we now are compiling the code such as: > $a->foo(); > we meet with following challenges: > 1. We do not know what class $a is (suppose it's X, but in most cases we > won't know that) > 2. If we did, we do not know what class X is (definition, as opposed to just > name) at the compile time (it could be defined later) > 3. If we knew what class X definition is at compile time, the above would > preclude us from generating any code that binds to that definition since > such code would not be cacheable. > > These are three independent challenges, without overcoming each of them I do > not see how virtual table would be helpful. Yes. As I replied to Dmitry, I clearly wasn't thinking when I suggested this. FYI, I do type-inference on PHP, and the types here are difficult to calculate in the general case. Thanks, Paul -- Paul Biggar paul.biggar@gmail.com