Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Exupery Fast 32 bit Integer Plan
Last updated at 11:45 pm UTC on 15 March 2007
The fast 32 bit integer project has been proposed for Google's summer of code.

The goal isn't 100% C's speed, but it should be within striking distance with some programmer assistance. Removing the remaining overhead would involve building a proper optimiser to allow type checks to be combined or moved out of the loops and possibly full method inlining to get the entire loop into a single inlined method to allow it to be optimised.

The project plan:

Implement "^ true" and "^ false" primitives

This is just a warm up. The two primitives are trivial but it's a chance to do something useful and get some code into Exupery quickly.

The goal is to get a feel for working with Exupery, doing TDD on a compiler, and getting code committed into the mainstream development branch.

Choose a concrete benchmark to evaluate the performance with

Implement a 32 bit integer object and write primitives for at least addition and multiplication

The initial arithmatic primitives will have different selectors to the standard arithmatic operations. This is because arithmatic operations are automatically inlined for the SmallInteger case. The end goal is to use dynamic inlining to allow other types to be inlined instead of SmallIntegers.
The 32 bit integer class should use a compact class header. This isn't strictly nessisary but it'll make type checking in Exupery easier with inlined primitives. The use of a compact class header can be dropped when Exupery's type checks can handle long class headers.

Implement Exupery primitives for the previous primitives.

The key is to implement the primitives so they have 32 bit boxing and deboxing high level operations. That will allow the optimiser to be easily written later.

Add an optimisation to remove boxing the deboxing from ASTs.

Have a look at how the TreeOptimiser optimises away Boolean conversion in conditional expressions

Demonstrate some speed improvement

Possibly add side-effecting primitives such as += or straight assignment (setValue:)

This is enough to avoid all object creation with 32 bit integers with some help from the developer. There is still type checking overhead at the bottom of the AST. Type checking is much faster than object creation and GCing.

Possibly add primitives for 32 bit word at: and at:put:

Demonstrate a better speed improvement

Refactor inlining so that + - / can be used for addition etc

This might not be done during the summer project. It's not hard, but does involve a little insight into Exupery's internals so's not something best done first. If it's not done during the project then Bryce might develop it later.