[Vm-dev] float word order
David T. Lewis
lewis at mail.msen.com
Mon Apr 20 01:35:05 UTC 2009
On Sun, Apr 19, 2009 at 11:08:14AM -0700, John M McIntosh wrote:
> On 19-Apr-09, at 8:37 AM, David T. Lewis wrote:
> >>The values in a FloatArray are 32-bit floats, packed into 64-bit slots
> >in the object memory. There are no endian issues to worry about. On both
> >32-bit and 64-bit object memories, the values are arranged in the order
> >of an (int *) access. In other words, they are arrays of 32-bit values
> >that just happen to be stuffed onto slots that the object memory thinks
> >are 64-bit words.
> Well that's not quite true, you have to be careful here because might
> people move data in and out of
> the FloatArray, but let's see..
> MatrixTransform2x3>>at: index put: value
> <primitive: 'primitiveAtPut' module: 'FloatArrayPlugin'>
> value isFloat
> ifTrue:[self basicAt: index put: value asIEEE32BitWord]
> ifFalse:[self at: index put: value asFloat].
> CGPoint>>x: aValue
> self unsignedLongAt: 1 put: aValue asFloat asIEEE32BitWord
> bigEndian: SmalltalkImage current isBigEndian.
As near as I can tell all accesses to FloatArray and IntegerArray are
on 32 bit boundaries for both 32-bit and 64-bit images, and are not
impacted by host endianness.
I should mention that I have not tried FloatArrayPlugin on 64-bit
images; I should probably have a look at that one of these days.
> Ok, well the reverseBytesInImage logic I'll assume without looking is
> swapping the bytes in the FloatArray at load time so that accessors
> use SmalltalkImage current isBigEndian to move data in/out in the
> proper form.
Yes, the bytes in a FloatArray would be swapped at load time if moving
from one endianness to another, but no I don't think that #isBigEndian
is required for accessing the ints or floats on 32 bit boundaries.
Also, a 64-bit image containing FloatArray or IntegerArray instances
should be correctly byte swapped when moved from one endianness to
another, although I have never actually tried it so I can't say for
Bottom line: This stuff pretty much just works, no special cases to
More information about the Vm-dev