DMD 0.161 release

xs0 xs0 at xs0.com
Thu Jun 22 08:17:37 PDT 2006


Ben Hinkle wrote:
> ok, I see what you mean. thanks for explaining. Pretty cool! Since the 
> vtable lookup is linear in the total number of interfaces the class 
> implements (including the interfaces of super-interfaces) it could be more 
> noticeable in larger examples.

Well, the lookup need not be linear. Since the interfaces are known in 
advance for each class, it should be possible to achieve a fast O(1) 
lookup with something like a [minimal] perfect hash function, all you'd 
probably need is some sort of numeric identifier for each interface 
(could simply be a MD5 of its full name or something).

> In general I agree function call speed isn't a big deal for interfaces but 
> it isn't unusual to have an interface that abstracts out a field lookup (eg, 
> getLength). For those the body of the implementation would be very simple. 
> I'm curious if the double lookup technique has been tried in practice and 
> what the impressions were.

Well, as far as I can tell, Sun's JVM does something like this (at least 
the timing results seem to suggest so), and considering how often 
interfaces get used in Java, I'd say it's not actually a significant 
problem.

Though I've no idea if any compiled language does so, as I don't know 
that many :)

It should also be noted that having a single reference to each object 
would allow covariance in many more cases, so it'd be easier to actually 
have a class reference than it is now..


xs0



More information about the Digitalmars-d-announce mailing list