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