[virtmach] Re: Switch vs. Jump Tables?

reig@dcs.gla.ac.uk reig@dcs.gla.ac.uk
Tue, 14 Nov 2000 10:04:30 +0000 (GMT)

Murray, Peter C wrote:

> I've never look at the ASM code generated by an optimizing compiler for the
> switch statement, but I'd assume it would produce some form of efficient
> jump table anyway.  And you would't have the overhead of a pointer
> indirection and fn call for each virtual instruction.  Has anyone looked
> into this in more detail?

The lcc book has useful information on generating efficient code for
the switch statement.

  author =       "Chris W. Fraser and David R. Hanson",
  title =        "A Retargetable {C} Compiler: Design and
  publisher =    "Benjamin/Cummings Pub. Co.",
  address =      "Redwood City, CA, USA",
  pages =        "xv + 564",
  year =         "1995",
  ISBN =         "0-8053-1670-1",

Fermin Reig