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.

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.
--
Stanislav Malyshev, Zend Software Architect
s...@zend.com   http://www.zend.com/
(408)253-8829   MSN: s...@zend.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to