On Sat, 19 Mar 2016 23:40:09 +0300, Andrea Faulds <a...@ajf.me> wrote:
Hi Lin,
Lin Yo-An wrote:
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?
For a while I'd also been wondering if we could implement some
implementation along these lines. Another approach could be possibly
replacing such methods with an C implementation (though I don't know if
non-internal classes can have internal methods).
I don't know how successful it will be, but I'm interested to hear how
much improvement it gives if you get it working.
Thanks!
I was playing with this idea sometime ago, it gives good performance boost
for code like `for ($i = 0; $i < 100000; $i++) $a->getFoo();` but in the
end of the day it's a very limited optimization.
If you abstract away from getters and say you want to optimize more and
more small functions like this one, you end up realizing that what you're
actually doing is what JIT compilation would do in a more generic way.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php