I few days ago I suggested inlining some PMC methods
would be good for performance. It turns out that this
question has been heavily studied by the OO community
for at least 10 years. A common solution is to
dynamically replace a method call with the body of the
method wrapped in an if statement.
Code like:
object->foo()
becomes
if (typeof object == Bar) {
... inlined body of Bar::foo
}
else {
object->foo()
}
There are lots of tweaks to the idea. SmallEifel
uses this concept to completely eliminate vtable
method lookups -- all of its methods are called using
inlined binary search trees. This is totally useless
for Parrot, but somebody might find it as interesting
as I did. ;)
Where this fits into Parrot's interpreter is that
languages could pre-generate ops corresponding to
dynamically generated inlined caches. All we need is a
way to replace the simple method call op with the
inlined one. Yep. You heard it -- dynamically modified
byte code.
- Ken