[Vm-dev] RoarVM: The Manycore SqueakVM

Ian Piumarta piumarta at speakeasy.net
Sat Nov 6 21:45:39 UTC 2010

On Nov 7, 2010, at 06:02 , Stefan Marr wrote:

> Are you assuming that GCC is not using jumptables?
> Well, if I read the assembly code correctly, it does. See below.

GCC does produce jump tables for switch() whenever it makes sense to.  The conditions & solution we need are more complex.


1. an integer driving a switch that is guaranteed to be in a known range (in this case 8-bit unsigned);
2. every case ends with a break to the end of the switch statement;
2. the switch is inside an infinite loop that generates the next integer for the switch,

then the compiler could decide to:

1. remove the range check;
2. turn off common subexpression elimination (a useless extra jump in many bytecodes);
3. combine the head of the loop (fetch) with the switch's indirect jump through the table;
4. distribute the combined fetch+jump over the entire switch as the final step in each branch (another useless jump in every bytecode).

That's an awful lot to ask of an optimiser for a general-purpose programming language.

On Nov 6, 2010, at 2:05 PM, Igor Stasenko <siguctua at gmail.com> wrote:

> In an ideal world it would all be implemented in Smalltalk (or something similar) and dynamically translated directly into machine code.

Agreed.  Critical optimisations should be part of the program specification, not the compiler implementation.

> Michael Haupt has a few nice slides visualizing what threaded code is about :)

A sort explanation is here, too:  http://citeseerx.ist.psu.edu/viewdoc/download?doi=


More information about the Vm-dev mailing list