[squeak-dev] Re: [Pharo-project] new Cog VMs available

Eliot Miranda eliot.miranda at gmail.com
Mon Feb 7 18:32:48 UTC 2011

Hi Francois,

On Mon, Feb 7, 2011 at 12:12 AM, Francois Stephany <
tulipe.moutarde at gmail.com> wrote:

> Hi Eliot,
> Probably a stupid question but what's the difference between
> SimpleStackBasedCogit and StackToRegisterMappingCogit ?

See the following thread:


Here's a summary:

The SimpleStackBasedCogit is a one-to-one translation of bytecodes to
machine code so tat every push or pop in the bytecode results in a
corresponding push or pop in the generted code.  This results in a machine
that passes all parameters on the stack and reifies all comparison results
as either true or false.

The StackToRegisterMappingCogit defers generating code until it reaches a
bytecode that consumes operands on the stack (i.e. a send, a temp or inst
var store, a return, a closure creation or an Array creation ( {...} )).
 This results in a machine that is able to pass parameters in registers for
small arity sends (currently 0 or 1 arg), and able to inline some integer
arithmetic and comparison, e.g. that involved in inlined to:do: loops, and
can do some constant folding (hint: write 2 + 3 + 4 + i, not i + 2 + 3 + 4).

There are two main benefits.  The StackToRegisterMappingCogit produces
machine code that is about 20% more compact than the SimpleStackBasedCogit
(hence meaning less frequent code zone reclamations and better cache
performance) and considerably faster for microbenchmarks, for example the
empty 1 to: 100000000 do: [:i|] (equivalent to i := 1. [i <= 100000000]
whileTrue: [i := i + 1]) is 4 times faster than the SimpleStackBasedCogit.

At a macro level StackToRegisterMappingCogit speeds up code such as
compiling a method by about 10%, with low-level arithmetic-intensive code
showing greater speedups.


>      new Cog VMs are available, SimpleStackBasedCogit @
>> http://www.mirandabanda.org/files/Cog/VM/VM.r2359/ and
>> StackToRegisterMappingCogit @
>> http://www.mirandabanda.org/files/Cog/VM/VM.r2361.  I think the new code
>> generator is ready for prime time now.  I fixed a number of bugs over
>> the past three weeks and we're now using the StackToRegisterMappingCogit
>> internally at Teleplace.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110207/6a5a5233/attachment.htm

More information about the Squeak-dev mailing list