Re: Jump tables and OOP in Oberon (Paul Hudson)
23 Jul 1996 23:28:22 -0400

          From comp.compilers

Related articles
Jump tables and OOP in Oberon (1996-07-13)
Re: Jump tables and OOP in Oberon (Tim Dwyer) (1996-07-18)
Re: Jump tables and OOP in Oberon (1996-07-22)
Re: Jump tables and OOP in Oberon (1996-07-23)
Re: Jump tables and OOP in Oberon (Darius Blasband) (1996-07-23)
| List of all articles for this month |

From: (Paul Hudson)
Newsgroups: comp.compilers
Date: 23 Jul 1996 23:28:22 -0400
Organization: The Harlequin Group.
References: 96-07-083 96-07-145
Keywords: code

Robert A Duff <> wrote:
>... Can someone clearly define how jump tables are used in
>pascal-type CASE statements?

>Ram Meenakshisundaram <> wrote:
>The compiler first checks that the case labels are "reasonably" close
>together. If so, generate an array, indexed by the case expression, of
>code addresses to jump to.
>If the case labels are not reasonably close together, it's better to
>generate a table of code addresses that can be binary-searched.
>And if there are just a couple of case labels, treating it like a series
>of if-then-else's makes sense.

You can develop this idea a bit. In a C compiler I wrote for the Acorn
ARM, I used to scan the labels looking for areas of reasonably-close
labels and implement a jump table for that bit, test-and-jump for a
few isolated cases, and binary switch on the rest (the test-and-jump
and tables get treated as one case when considering the binary

This works rather well given that case values are often runs of adjacent
values + a small number of 'exceptional' or error cases.


Paul Hudson, Chief Designer, Information Systems, Harlequin Ltd, Longstanton
House. Longstanton, Cambs. CB4 5BU, England +44 1954 785473 (fax 785444)
Personal: Learning:

Post a followup to this message

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