forwarded message from Henry Cejtin

Stephen Weeks sweeks@intertrust.com
Wed, 13 Sep 2000 12:01:00 -0700 (PDT)


Received: from maguro.epr.com ([198.3.162.27]) by exchange.epr.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21)
	id SZ72A21Q; Wed, 13 Sep 2000 11:57:02 -0700
Received: from magrathea.epr.com (firewall-user@magrathea.epr.com [198.3.160.1])
	by maguro.epr.com (8.9.3/8.9.3) with ESMTP id LAA07514
	for <sweeks@intertrust.com>; Wed, 13 Sep 2000 11:59:50 -0700 (PDT)
Received: (from uucp@localhost) by magrathea.epr.com (8.9.3/8.7.3) id LAA15417 for <sweeks@intertrust.com>; Wed, 13 Sep 2000 11:59:48 -0700 (PDT)
Received: from nodnsquery(199.249.165.245) by magrathea.epr.com via smap (V5.5)
	id xma015237; Wed, 13 Sep 00 11:59:22 -0700
Received: (from henry@localhost)
	by syzygy.clairv.com (8.9.3/8.9.3) id NAA30628
	for sweeks@intertrust.com; Wed, 13 Sep 2000 13:59:21 -0500
Message-Id: <200009131859.NAA30628@syzygy.clairv.com>
From: Henry Cejtin <henry@sourcelight.com>
To: sweeks@intertrust.com
Subject: Re: function dispatch
Date: Wed, 13 Sep 2000 13:59:21 -0500

The jump table that C++ uses has one extra indirection.  I.e.,
	x.f(???)
uses the fact that x (and object) contains a pointer to a function table (the
extra indirection is so all instances share the table).  Thus the code, assuming
the register R0 contains a pointer to x, is
	R1 = R0[constant]	R1 is base of function table array
	jump indirect R1[constant]

As to gcc using jump tables, note that for the 50 size thing jump tables were
a few percent slower.  For us and smallEiffel, it is more than offset by the
advantage of inlining the procedure bodies.  Also note that in the dispatch
case, you know all possible values, and you have to do something for each of
them.  In the general switch case, there can be lots of cases you don't mention
where nothing has to be done.  Thus you have to do a few more tests.