Re: Method call improvements

From: Date: Tue, 12 May 2009 08:43:28 +0000
Subject: Re: Method call improvements
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-43896@lists.php.net to get a copy of this message
Paul Biggar wrote:
Hi Stas, Dmitry, On Tue, May 12, 2009 at 2:01 AM, Stanislav Malyshev <stas@zend.com> wrote:
IHMO it's not static enough. I.e., since PHP is not compiled, we can not create VD table for the class until runtime inheritance, which means that the code using this class can use method resolution more efficient than name->function, i.e. hashtable. These lookups can be cached (i.e. CV style) but I don't see how they can be altogether prevented.
On Tue, May 12, 2009 at 7:25 AM, Dmitry Stogov <dmitry@zend.com> wrote:
The real things is even worse as during compilation of a class it's parent class doesn't have to be known. So construction of VMTs becomes a bit problematic. BTW we could think in this way...
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?
The parent class may be defined in other file that is loaded at runtime using include() statement. It's very usual case. So the PHP first loads the include file and then declares child class at runtime.
Must it be known for the class' first instantiation?
Of course. :)
In the worst case, it _might_ be cheaper to build it at instantiation time, but I would have to look up how expensive that is in a more static language to be sure. Certainly, it is currently so expensive that almost anything else would be better (including the OP's patch).
I don't see how run-time VMT contraction may help, because calls to virtual method must know VMT offset at compile-time. Thanks. Dmitry.
Thanks, Paul


« previous php.internals (#43896) next »