Simon Cozens wrote:
> 
> I'm obviously missing something about vtables. It'll be obvious when someone
> corrects me, but...
> 
> Currently, SvPVX(foo) requires one lookup; with a vtable, it would necessitate
> two, (One to find the functino in "foo", and then the functino must find the
> data in "foo") given that C, beastly as it is, doesn't let us create anonymous
> function pointers. And given that the functinos are dynamic, this isn't
> something that can be optimized. Oops! In fact, it may require three lookups,
> because we're doing something like this:
> 
>     sv->vtable->svpvx;
> 
> Isn't this going to really, really hurt?

Doing three C pointer lookups is going to be less expensive than
invoking a subroutine, let alone the work done inside the subroutine. 
If we make sure the operations in the perl VM are of a sufficiently high
level (much as they are now, or not too much lower-level), I doubt we're
going to see this.

C++ does some complex lookups as well for virtual methods, but that
rarely is a problem (except for the size overhead of a vtable pointer on
tiny objects, or if you have too many methods each doing too little
work).

Hildo

Reply via email to