[Vm-dev] Method header 64 vs 32 bits
vanessa at codefrau.net
Fri Dec 18 02:30:20 UTC 2020
I think I did guess exactly what you described. My example was just wrong,
because SqueakJS does not use a tag bit for immediates, but the oop's type
(SmallIntegers are plain JS numbers).
What I do now to convert 64-to-32 is basically:
var header = bits >> 3;
var numLits = header & 0x7FFF;
method.pointers = decodePointers(bits, 1+numLits); // wrong header
method.pointers = (bits & 0x80000000) | header; // fixed header
... where bits is a 32-bit unsigned int array of the image, positioned
after the object header of the method (and assumed to be 64 bit little
On Thu, Dec 17, 2020 at 2:31 AM Eliot Miranda <eliot.miranda at gmail.com>
> 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.
> _,,,^..^,,,_ (phone)
> On Dec 16, 2020, at 1:02 PM, Vanessa Freudenberg <vanessa at codefrau.net>
> 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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev