We had very similar idea in the past.
BTW it is possible to optimize function calls mach more.
Not only ZEND_DO_FCALL but also ZEND_INIT_FCALL_BY_NAME can be optimized,
and we can reuse the same cache entries for all op_arrays from the same PHP
file.
Sure, I went shallow with this first version just to have something to discuss, so that general intent was clear. There's certainly a lot that can be done to improve it both from a code-line coverage and in actual implementation (for one thing, I got a crash with it a couple days ago which I havn't bothered tracking down).
Making the cache per-file (rather than per-scope) would definately be a good direction to go (per-execution would unfortunately break opcode cache assumptions so we can't go that high), but I couldn't come up with a simple/easy way to "track" the current file. I suppose we could use the op_array's filename attribute to lookup a cache vector from a hashtable anytime scope changes...
I'll make a patch and send it to you in fey days.
Can't wait to see it! :)
-Sara