Related articles |
---|
[3 earlier articles] |
Re: Switch statement code generation cr88192@hotmail.com (BGB / cr88192) (2009-11-04) |
Re: Switch statement code generation ian@airs.com (Ian Lance Taylor) (2009-11-03) |
Re: Switch statement code generation gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-11-04) |
Re: Switch statement code generation anton@mips.complang.tuwien.ac.at (2009-11-04) |
Re: Switch statement code generation Pidgeot18@verizon.invalid (Joshua Cranmer) (2009-11-04) |
Re: Switch statement code generation walter@bytecraft.com (Walter Banks) (2009-11-05) |
Re: Switch statement code generation bartc@freeuk.com (bartc) (2009-11-05) |
Re: Switch statement code generation nathan.mccauley@gmail.com (nathan.mccauley@gmail.com) (2009-11-07) |
Re: Switch statement code generation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-08) |
Re: Switch statement code generation bear@sonic.net (Ray) (2009-11-09) |
Re: Switch statement code generation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-11) |
Re: Switch statement code generation derek@knosof.co.uk (Derek M. Jones) (2009-11-11) |
Re: Switch statement code generation anton@mips.complang.tuwien.ac.at (2009-11-11) |
[4 later articles] |
From: | "bartc" <bartc@freeuk.com> |
Newsgroups: | comp.compilers |
Date: | Thu, 05 Nov 2009 22:11:44 GMT |
Organization: | Compilers Central |
References: | 09-11-002 09-11-003 09-11-009 |
Keywords: | code, interpreter |
Posted-Date: | 06 Nov 2009 11:23:57 EST |
"Joshua Cranmer" <Pidgeot18@verizon.invalid> wrote in message
news:09-11-009@comp.compilers...
> On 11/04/2009 12:27 AM, glen herrmannsfeldt wrote:
>> I believe that JVM also has a special instruction for this
>> operation, as the above likely don't work there.
>
> Actually two special bytecodes, lookupswitch and tableswitch. These are
> the linear scan and the jump table methods, respectively. The upcoming
> string switch appears to use a hash routine.
Hey, that's what I use.. invented independently of course.
'switch' for an indexed jump table, for case values in the range of 500 or
1000 (between minimum and maximum values).
'cswitch' for other case values, which just does a linear search.
Since these implement 'Switch' for an interpreted language, with the cswitch
bytecode implemented in tight assembler, opting for a linear search doesn't
have as much impact as it would do in a compiled language, especially if the
most common cases appear first.
However, with a big enough table size then I guess a proper lookup is called
for.
--
Bartc
Return to the
comp.compilers page.
Search the
comp.compilers archives again.