Numbers. (but completely different)

Alan Grimes alangrimes at starpower.net
Fri Apr 9 05:43:28 UTC 2004


I was going through the posting I just made and squinting really hard at 
what the VM was _REALLY_ doing I came across something that starteled me 
out of my chair...

I had assumed that the basic integer format was a basic two's complement 
number only shifted to the left one bit...
To my shock and disbeleif I found that it's stored in a magnitude+sign 
format, EGADS!!!

I presume there is a 50 page paper that explains why this format is 
indispensible to the operation of Squeak.. If no such paper exists then 
it is time to change.

Consider that even Athlons have a 10-12 stage pipeline and a pentium 4's 
have between a 22 and 32 stages (no typo)... Doing a branch to convert 
the above format into the hardware 2's complement for every operation is 
just plain nuts... You can probably get away with it on a G4 which has a 
relatively short pipe but let me propose that for Squeak 4.0 we go to 
2's compliment all the way and use this code instead:

To convert from object:

^obj >> 1 + obj bitAnd: maxInt.

Rationale: if we are already in 2's compliment all we have to do is to 
retain the present value of the sign bit.

and back (under the assumption that the value is in range)

^obj << 1 + 1.

Admittedly, we'll sometimes have to do range checks and promote as 
necessary but that doesn't really worry me.



More information about the Squeak-dev mailing list