Related articles |
---|
Jump tables and OOP in Oberon rmeenaks@bfm.com (1996-07-13) |
Re: Jump tables and OOP in Oberon tim@xinotech.com (Tim Dwyer) (1996-07-18) |
Re: Jump tables and OOP in Oberon bobduff@world.std.com (1996-07-22) |
Re: Jump tables and OOP in Oberon paulh@harlequin.co.uk (1996-07-23) |
Re: Jump tables and OOP in Oberon darius@phidani.be (Darius Blasband) (1996-07-23) |
From: | paulh@harlequin.co.uk (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 <bobduff@world.std.com> wrote:
>... Can someone clearly define how jump tables are used in
>pascal-type CASE statements?
>Ram Meenakshisundaram <rmeenaks@bfm.com> 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
switch).
This works rather well given that case values are often runs of adjacent
values + a small number of 'exceptional' or error cases.
P.
--
Paul Hudson, Chief Designer, Information Systems, Harlequin Ltd, Longstanton
House. Longstanton, Cambs. CB4 5BU, England +44 1954 785473 (fax 785444)
Personal: phudson@pobox.com Learning: pth4@student.open.ac.uk
Work: paulh@harlequin.co.uk http://www.harlequin.com
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.