[Vm-dev] Method header 64 vs 32 bits

Eliot Miranda eliot.miranda at gmail.com
Thu Dec 17 10:31:34 UTC 2020

Hi Vanessa,

A method header fits in a 31 bit SmallInteger on 32-bits and is exactly the same value on 64-bits.  So the values of a method header are in the range ((2 raisedTo: 30) negated to: (2 raisedTo: 30)). Therefore, at the Smalltalk level no change is required; one uses the same integer value.

But at the machine level
- to go from 32 to 64 bits one preserves the bottom 30 bits above the tag bit, shifting left two bits to make room for the three bit immediate tag, and moves the sign bit from bit 31 (0 relative) to bit 63, and sets the bottom three bits to 1.
- to go from 64 to 32 bits one shifts the bottom 30 bits above the tag right two bits, shifts the sign bit right 32 bits and sets the bottom tag bit to 1.

I chose not to take advantage of the bits 31 to 60 in 64 bits.  It would make converting back and forth a night mare. So in 64 bits exactly the same limitations on numLiterals, numTemps and numArgs apply. If and when 32 bit support becomes obsolete (please no...) we can revisit but right now wasting 30 bits, when we have a max literals limit of 32k, and a way of expanding beyond the Max arg/temp count of 16/32 using tuples and the indirect temp vector bytecodes, seems like the right choice to me.  Thoughts?

_,,,^..^,,,_ (phone)

> On Dec 16, 2020, at 1:02 PM, Vanessa Freudenberg <vanessa at codefrau.net> wrote:
> Hi Eliot / Clément / everyone,
> how do I properly convert a 64 bit method header word to 32 bits?
> E.g. if in 64 bits I have 0x8000000000000049 my guess it would be 0x80000049 in 32 bits, but which bits should I actually drop?
> Thanks!
> Vanessa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20201217/0810aef1/attachment.html>

More information about the Vm-dev mailing list