Hi Dmitry,
Thanks for your reply! You're correct. let me try to explain your points: If I have a main.php and worker.php And I defined work($worker) { $status = $worker->getStatus(); } inside main.php when main.php is compiled, we don't know what the class entry of $worker is. What we only know is invoking a method "getStatus" on $worker CV unless we know we have to compile worker.php before main.php and add a type hint on $worker. Is it correct? Since the original approach doesn't work, here comes another new idea: When executing method call on an object, if we found the method body are just 2 op codes (FETCH_OBJ_R and RETURN), we then denote the method is a "getter method" And the next time, when we execute the same method, we found the "getter method" flag, we simply execute FETCH_OBJ_R on that object and return the value to avoid extra op code execution time. Do you think if this could work? Best Regards and Thanks for your work on PHP VM Yo-An Lin On Fri, Mar 18, 2016 at 3:36 PM, Dmitry Stogov <dmi...@zend.com> wrote: > Hi Yo-An Lin, > > Unfortunately, this approach won't work. > At first, at compile time we don't know the body of called getter. > At second, the called method might be changed even at run-time, because of > polymorphism. > > Tricks like this might be implemented using JIT and polymorphic inline > caches. > > Thanks. Dmitry. > > ________________________________________ > From: Lin Yo-An <cornelius.h...@gmail.com> > Sent: Friday, March 18, 2016 05:23 > To: internals > Subject: [PHP-DEV] Object getter method optimization > > Hello Everyone, > > > I am recently trying to write an optimizer that could optimize the getter > method call into just one object fetch opcode. > > I'd like to know thoughts from you guys, here is the note: > https://c9s.hackpad.com/INLINE-OP-TVGo9WcshbZ > > -- > Best Regards, > > Yo-An Lin > https://github.com/c9s > -- Best Regards, Yo-An Lin