Re: What is byte-code ? (Ralph Corderoy)
9 May 2005 22:31:28 -0400

          From comp.compilers

Related articles
[17 earlier articles]
Re: What is byte-code ? (Nathan Moore) (2005-04-02)
Re: What is byte-code ? (John Slimick) (2005-04-11)
Re: What is byte-code ? (Chris Dollin) (2005-04-11)
Re: What is byte-code ? (2005-04-11)
Re: What is byte-code ? (Nathan Moore) (2005-04-16)
Re: What is byte-code ? (glen herrmannsfeldt) (2005-04-16)
Re: What is byte-code ? (2005-05-09)
Re: What is byte-code ? (glen herrmannsfeldt) (2005-05-13)
| List of all articles for this month |

From: (Ralph Corderoy)
Newsgroups: comp.compilers
Date: 9 May 2005 22:31:28 -0400
Organization: Compilers Central
References: 05-03-015 05-03-125 05-04-005 05-04-037
Keywords: VM, interpreter
Posted-Date: 09 May 2005 22:31:28 EDT

Hi Anton,

Anton Ertl <> wrote:
> Nathan Moore <> writes:
> > This will save you about 2 jumps per instructoin since the jump tables
> > that are usually spit out by compilers are:
> >
> > jump ip+(constant*case)
> > ...
> I have never seen that kind of code generated. Which compiler does it
> that way?

I've seen the Norcroft and gcc C compilers targetted at ARM generate
such code.

                ldrb r1, [r11, #0]
                cmp r1, #7
                addls pc, pc, r1, lsl #2 ;
                b case_8
                b case_0
                b case_1
                b case_2
                b case_3
                b case_4
                b case_5
                b case_6

                ldr r1, [r11, #&028]
                mov r0, r11

With a 32-bit word, pc is already two words ahead of the current
instruction due to pipe-lining. This is the idiomatic jump table in ARM
and assembly programmers use it too.

> Big, dense switch statements have been translated into a range check,
> an array access (for the target address), and an indirect jump to the
> target in the code I looked at (usually by gcc).

The assembler above only works when the relative jump destination can be
encoded along with the b instruction in the 32-bit word.


Ralph Corderoy.

Post a followup to this message

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