This is quite an interesting idea about dynamic recompiling and caching
of method lookups. And it smells like more MOPS and generally just a
faster Parrot VM. So I've hacked together an initial version for
testing, only MMD lookups currently.
PMC MOPS (examples/benchmarks/mops.pasm)
parrot -C CVS 13.6
parrot -j 13.4
parrot -C PIC 16.7
This is a 22% speedup for MOPS and very likely more for method lookups.
With JIT_CGP the JIT core could also use this optimization.
(Numbers with -O3 build, AMD 800)
Below is a (very) preliminary pod generated from src/pic.c.
Before spending more time on that, I'd like to hear some comments about
possible hidden drawbacks or whatever. I can provide a patch too.
Thanks,
leo
MMD add PerlInt PerlInt 0.698083
MMD add PerlInt INTVAL 0.601620
MMD sub PerlInt PerlInt 0.513797
MMD sub PerlInt INTVAL 0.457096
PIR add PerlInt PerlInt 7.789893
PIR sub PerlInt PerlInt 4.448320
These are 5 million add or sub instructions on AMD 800, --optimize
build. The add isn't cached, the sub opcode is cached. Last two lines
are with overloaded MMD functions.
The speedups are ~34% and 77% respectively. The latter number is
remarkable - due to the recompilation of the sub opcode, it get's
converted to a direct (invokecc-like) function call w/o entering a
second run-loop.
#! perl5_80
use overload '-' => \&my_sub; # here we come (14.5 seconds)
leo