On Fri, 21 Sep 2007 01:48:32 GMT, Joshua Cranmer
<Pidgeot18@[EMAIL PROTECTED]
> wrote, quoted or indirectly quoted someone who
said :
>If I am understanding this correctly, then the two opcodes only differ
>in functionality when it comes to locating the function pointer to call
>in the vtable structure. That would mean that at logical level, the
>method resolution lookup is identical.
>
>(Hmmm... trying to put down in words the concept I envision in my head
>is much more difficult than I thought it would be.)
The implementation is quite different. For InvokeVirtual, you take
the method index, index into the vtbl for the current object's class,
and that points you to the method.
For InvokeInterface, you need a cache of class-offset pairs that have
been discovered in past to invoke this method. You have to do a
miniature HashMap lookup of the class to get the offset. If you don't
find the class, you must examine the class object structure for the
current object, looking for a match for that method, then add it to
the cache. There may be cleverer, faster ways of implementing it, but
it is much hairier operation than InvokeVirtual.
This is why abstract cl***** work faster than interfaces.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


|