Thanks Nikita,

Does that mean a function which accepts an instance of an interface and
calls a method on it will have to do a full lookup of the method whenever
the concrete class isn't the same as when that function was first executed?
(or was last executed, depending on how the cache works)


On Wed, May 18, 2016 at 12:28 AM, Nikita Popov <nikita....@gmail.com> wrote:

> On Tue, May 17, 2016 at 3:03 PM, Jesse Schalken <m...@jesseschalken.com>
> wrote:
>
>> Hi Internals,
>>
>> I'd like to know whether references to
>> classes/functions/methods/properties/variables always go through a hash
>> table at runtime, or if the name is optimised into a pointer or fixed
>> offset. I recall seeing such an optimisation for local variables, but what
>> about the others?
>>
>> Thanks
>>
>
> A property access $foo->bar (where "bar" is a literal and not the result
> of an expression) uses a polymorphic runtime cache, which will store the
> class entry and property offset the first time the instruction is executed.
> Afterwards, if $foo is an instance of the same class, we will directly use
> this offset. Otherwise, a full lookup from the property name table with
> visibility checks and all those other bells an whistles has to be performed.
>
> The same holds for pretty much all other symbol references as well, so
> classes, functions, methods, etc.
>
> Nikita
>
>

Reply via email to