Hi all,
For a few months now I have been using IntegerArray and FloatArray with UFFI. They are pretty convenient since they reside in Internal memory space (unlike FFIExternalArray) yet you can pass them in a C function call with the "ByteArray" signature. Now I need the equivalent arrays for short, double words and IEEE 64bit double. Comment in Class>>variableWordSubclass:instanceVariableNames:classVariableNames:package: says Spur already supports them. From discussion with Guille it seems we just need new subclasses of BitsLayout (ByteLayout and WordLayout implemented so far). Question 1: What is the value of instanceSpecification for shorts and double-words? Question 2: Both IntegerArray and WordArray exist and refer to 32bit arrays, should there be a difference between the two? Question 3: How will it fare with 64bit Spur? Does word refer to 32bit or 64bit then? Is WordArray/variableWordSubclass growing to 64bit? FloatArray too? Cheers, Thibault |
Hi
On Tue, Jul 5, 2016 at 4:21 PM, Thibault Raffaillac <[hidden email]> wrote: Hi all, I copy the comment of Behavior>>instSpec instSpec "Answer the instance specification part of the format that defines what kind of object an instance of the receiver is. The formats are 0 = 0 sized objects (UndefinedObject True False et al) 1 = non-indexable objects with inst vars (Point et al) 2 = indexable objects with no inst vars (Array et al) 3 = indexable objects with inst vars (MethodContext AdditionalMethodState et al) 4 = weak indexable objects with inst vars (WeakArray et al) 5 = weak non-indexable objects with inst vars (ephemerons) (Ephemeron) 6 = unused 7 = immediates (SmallInteger, Character) 8 = unused 9 = 64-bit indexable 10-11 = 32-bit indexable (Bitmap) 12-15 = 16-bit indexable 16-23 = 8-bit indexable 24-31 = compiled methods (CompiledMethod)"
Yes. IntegerArray has two specific accessing primitives to store and read raw integers. WordArray uses the normal accessing primitives. Question 3: How will it fare with 64bit Spur? Does word refer to 32bit or 64bit then? Is WordArray/variableWordSubclass growing to 64bit? FloatArray too? It depends. ByteArray is a good name and ShortArray is good name, self-explanatory, there is no discussion here. Then it depends, at some place we use WordArray and DoubleWordArray, in other we use LongArray and SixtyFourBitsIndexableArray... I'd go for WordArray and DoubleWordArray, but I don't mind if one decides otherwise. For Float, we changed the representation to be "SmallFloat64" and "BoxedFloat64". We have no proper support for single precision float in Pharo. We could consider renaming FloatArray to DoubleArray, Float64Array, or something similar. I don't know.
|
In reply to this post by Thibault Raffaillac
> I copy the comment of Behavior>>instSpec
I had missed this one, thanks! > It depends. > > ByteArray is a good name and ShortArray is good name, self-explanatory, > there is no discussion here. > > Then it depends, at some place we use WordArray and DoubleWordArray, in > other we use LongArray and SixtyFourBitsIndexableArray... I'd go for > WordArray and DoubleWordArray, but I don't mind if one decides otherwise. > > For Float, we changed the representation to be "SmallFloat64" and > "BoxedFloat64". We have no proper support for single precision float in > Pharo. We could consider renaming FloatArray to DoubleArray, Float64Array, > or something similar. I don't know. I am still confused with WordArray in Pharo terminology: 32bit or native register size? For the naming I like the Java convention: byte(8), short(16), int(32), long(64). Ideally that would make: ByteArray(8), ShortArray(16), IntegerArray(32), LongArray(64), WordArray(native), DoubleWordArray(native*2) As for floats, one arithmetic on 64bit double is fine, but I think we need both 32bit & 64bit loads/stores, that is having FloatArray(32) and DoubleArray(64). That would make UFFI code consistent among 32bit & 64bit machines . Also in x86 all architectures do IEEE 64bit double arithmetic, so no need for a "native" register size. Thibault |
Free forum by Nabble | Edit this page |