Re: Information on dispatch-techniques

Nick Kramer <nkramer@cs.cmu.edu>
5 Nov 1996 23:33:49 -0500

          From comp.compilers

Related articles
Information on dispatch-techniques astor@lucifer.guardian.no (Alexander Kjeldaas) (1996-10-30)
Re: Information on dispatch-techniques roques@pond.sub.org (Christian von Roques) (1996-11-03)
Re: Information on dispatch-techniques nkramer@cs.cmu.edu (Nick Kramer) (1996-11-05)
Re: Information on dispatch-techniques volanski@irisa.fr (1996-11-07)
Re: Information on dispatch-techniques astor@lucifer.guardian.no (Alexander Kjeldaas) (1996-11-26)
| List of all articles for this month |

From: Nick Kramer <nkramer@cs.cmu.edu>
Newsgroups: comp.compilers
Date: 5 Nov 1996 23:33:49 -0500
Organization: School of Computer Science, Carnegie Mellon
References: 96-10-150 96-11-032
Keywords: OOP, performance

Christian von Roques <roques@pond.sub.org> wrote:
> * Each function T.f corresponds to a number `f'. At the same offset
> in all objects of type `t' is a pointer to a dispatch-table `d_t'
> which holds the address a = d_t[f].


This is the standard technique for implementing virtual functions in
C++. This "class first" scheme has one big advantage over the
"functions first" scheme (a = d_f[t]) in that it is easy to implement
using a standard C linker. Bjarne Stroustrup's "The Design and
Evolution of C++" describes all this in detail, although it's
scattered throughout the book. (Look under "virtual" in the index)


Presumably this class first technique is also used for implementing
method dispatch in Java. How, then, are "interface" methods
implemented?


There are also languages with more complicated dispatch mechanisms.
In Dylan and CLOS (Common Lisp Object System), things are considerably
more complicated: You can dispatch off more than one parameter
(multi-methods), and you can specialize methods on types that are not
classes (such as union types and singleton types). In Dylan, a full
generic dispath means finding all applicable methods, sorting them,
and invoking the "most applicable" one. There's a lot of caching
going on, but even so a full generic dispatch is expensive enough that
compilers go to great lengths to avoid them.


(I've seen a lot more papers on caching schemes and on optimizing away
runtime dispatch than I have seen papers on actually implementing the
dispatch. Am I just looking in the wrong places?)
--


-Nick Kramer
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.