[squeak-dev] FFI: FFI-Kernel-mt.202.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Aug 13 08:08:40 UTC 2021


Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.202.mcz

==================== Summary ====================

Name: FFI-Kernel-mt.202
Author: mt
Time: 13 August 2021, 10:08:38.629551 am
UUID: b7a408ea-4287-7248-bc5a-a18fff4dab53
Ancestors: FFI-Kernel-mt.201

Fixes a regression / ensures compatibility with Alien and 3DTransform around floatAt:(put:).

Note that Alien (being a subclass of ByteArray) breaks polymorphism in the sense that it changes all atomic read/write primitives from byteOffset-based to index-based. Yet, Alien is way older than what the recent SqueakFFI efforts are trying to achieve here: a more robust programming model.

The fundamental issue considering the programming model is as follows:

anArray at: 4 put: 1.234. "Easy. Dynamic. Clear semantics."
anArray floatAt: 4 put: 1.234. "Depends on whether you got Alien or ByteArray ... or Float32Array for that matter."

Note that this issue does not occur with the integer primitives ... even though it might make sense to add the #*ByteOffset:* variants as well in the future.

Note that 3DTransform actually adds the extension #floatAt:(put:) to FloatArray.

=============== Diff against FFI-Kernel-mt.201 ===============

Item was changed:
  ----- Method: ByteArray>>doubleAt: (in category '*FFI-Kernel-accessing - float') -----
  doubleAt: byteOffset	
  	"Primitive. Return a float value from the receiver.
  	- FAILS IF the receiver has not enough bytes for an IEEE 754 (64 bits) floating point number.
  	- NOTE that this primitive will access memory in the outer space if invoked from ExternalAddress.
  	- SEE Float class >> #fromIEEE64Bit: and Float >> #asIEEE64BitWord"
  	<primitive: #primitiveFFIDoubleAt module: #SqueakFFIPrims>
+ 	"<ffiAtomicRead: #double> -- See #doubleAtByteOffset:."
- 	<ffiAtomicRead: #double>
  	"Examples:
  		ExternalType double handle: #[ 0 0 0 255 0 0 0 0 ] at: 1.
  		ExternalType double handle: #[ 0 0 0 255 ] at: 1. --- Error.
  	"
  	^ self primitiveFailed!

Item was changed:
  ----- Method: ByteArray>>doubleAt:put: (in category '*FFI-Kernel-accessing - float') -----
  doubleAt: byteOffset put: value
  	"Primitive. Store the given value as IEEE 754 (64 bits) floating point number.
  	- FAILS IF the receiver has not enough bytes for that representation.
  	- NOTE that this primitive will access memory in the outer space if invoked from ExternalAddress.
  	- SEE Float class >> #fromIEEE64Bit: and Float >> #asIEEE64BitWord"
  	<primitive: #primitiveFFIDoubleAtPut module: #SqueakFFIPrims>
+ 	"<ffiAtomicWrite: #double> -- See doubleAtByteOffset:put:."
- 	<ffiAtomicWrite: #double>
  	"Examples:
  		ExternalType double allocate value: 123.4567890; explore
  		ExternalType double allocate value: 0.0001; explore
  	"
  	^ self primitiveFailed!

Item was added:
+ ----- Method: ByteArray>>doubleAtByteOffset: (in category '*FFI-Kernel-accessing - float') -----
+ doubleAtByteOffset: byteOffset	
+ 	"Duplicates #doubleAt: for compatibility reasons with Alien and 3DTransform. See comment in #doubleAt:."
+ 	<primitive: #primitiveFFIDoubleAt module: #SqueakFFIPrims>
+ 	<ffiAtomicRead: #double>
+ 	^ self primitiveFailed!

Item was added:
+ ----- Method: ByteArray>>doubleAtByteOffset:put: (in category '*FFI-Kernel-accessing - float') -----
+ doubleAtByteOffset: byteOffset put: value
+ 	"Duplicates #doubleAt:put: for compatibility reasons with Alien and 3DTransform. See comment in #doubleAt:put:."
+ 	<primitive: #primitiveFFIDoubleAtPut module: #SqueakFFIPrims>
+ 	<ffiAtomicWrite: #double>
+ 	^ self primitiveFailed!

Item was changed:
  ----- Method: ByteArray>>floatAt: (in category '*FFI-Kernel-accessing - float') -----
  floatAt: byteOffset
  	"Primitive. Return a float value from the receiver.
  	- FAILS IF the receiver has not enough bytes for an IEEE 754 (32 bits) floating point number.
  	- NOTE that this primitive will access memory in the outer space if invoked from ExternalAddress.
  	- SEE Float class >> #fromIEEE32Bit: and Float >> #asIEEE32BitWord"
  	<primitive: #primitiveFFIFloatAt module: #SqueakFFIPrims>
+ 	"<ffiAtomicRead: #float> -- See #floatAtByteOffset:."
- 	<ffiAtomicRead: #float>
  	"Examples:
  		ExternalType float handle: #[ 0 0 0 255 ] at: 1.
  		ExternalType float handle: #[ 0 0 255 ] at: 1. --- Error.
  	"
  	^ self primitiveFailed!

Item was changed:
  ----- Method: ByteArray>>floatAt:put: (in category '*FFI-Kernel-accessing - float') -----
  floatAt: byteOffset put: value
  	"Primitive. Store the given value as IEEE 754 (32 bits) floating point number.
  	- FAILS IF the receiver has not enough bytes for that representation.
  	- NOTE that this primitive will access memory in the outer space if invoked from ExternalAddress.
  	- SEE Float class >> #fromIEEE32Bit: and Float >> #asIEEE32BitWord"
  	<primitive: #primitiveFFIFloatAtPut module: #SqueakFFIPrims>
+ 	"<ffiAtomicWrite: #float> -- See floatAtByteOffset:put:."
- 	<ffiAtomicWrite: #float>
  	"Examples:
  		ExternalType float allocate value: 123.4567890; explore
  		ExternalType float allocate value: 0.0001; explore
  	"
  	^ self primitiveFailed!

Item was added:
+ ----- Method: ByteArray>>floatAtByteOffset: (in category '*FFI-Kernel-accessing - float') -----
+ floatAtByteOffset: byteOffset
+ 	"Duplicates #floatAt: for compatibility reasons with Alien and 3DTransform. See comment in #floatAt:."
+ 	<primitive: #primitiveFFIFloatAt module: #SqueakFFIPrims>
+ 	<ffiAtomicRead: #float>
+ 	^ self primitiveFailed!

Item was added:
+ ----- Method: ByteArray>>floatAtByteOffset:put: (in category '*FFI-Kernel-accessing - float') -----
+ floatAtByteOffset: byteOffset put: value
+ 	"Duplicates #floatAt:put: for compatibility reasons with Alien and 3DTransform. See comment in #floatAt:put:."
+ 	<primitive: #primitiveFFIFloatAtPut module: #SqueakFFIPrims>
+ 	<ffiAtomicWrite: #float>
+ 	^ self primitiveFailed!

Item was changed:
  ----- Method: ByteArrayReadWriter>>doubleAt: (in category 'read/write atomics') -----
  doubleAt: oByteOffset
  
+ 	self shouldNotImplement. "See doubleAtByteOffset:"!
- 	self checkAt: oByteOffset.
- 	^ byteArray doubleAt: oByteOffset + byteOffset!

Item was changed:
  ----- Method: ByteArrayReadWriter>>doubleAt:put: (in category 'read/write atomics') -----
  doubleAt: oByteOffset put: value
  
+ 	self shouldNotImplement. "See doubleAtByteOffset:put:"!
- 	self checkAt: oByteOffset.
- 	^ byteArray doubleAt: oByteOffset + byteOffset put: value!

Item was added:
+ ----- Method: ByteArrayReadWriter>>doubleAtByteOffset: (in category 'read/write atomics') -----
+ doubleAtByteOffset: oByteOffset
+ 
+ 	self checkAt: oByteOffset.
+ 	^ byteArray doubleAtByteOffset: oByteOffset + byteOffset!

Item was added:
+ ----- Method: ByteArrayReadWriter>>doubleAtByteOffset:put: (in category 'read/write atomics') -----
+ doubleAtByteOffset: oByteOffset put: value
+ 
+ 	self checkAt: oByteOffset.
+ 	^ byteArray doubleAtByteOffset: oByteOffset + byteOffset put: value!

Item was changed:
  ----- Method: ByteArrayReadWriter>>floatAt: (in category 'read/write atomics') -----
  floatAt: oByteOffset 
  
+ 	self shouldNotImplement. "See floatAtByteOffset:"!
- 	self checkAt: oByteOffset.
- 	^ byteArray floatAt: oByteOffset + byteOffset!

Item was changed:
  ----- Method: ByteArrayReadWriter>>floatAt:put: (in category 'read/write atomics') -----
  floatAt: oByteOffset put: value
  
+ 	self shouldNotImplement. "See floatAtByteOffset:put:"!
- 	self checkAt: oByteOffset.
- 	^ byteArray floatAt: oByteOffset + byteOffset put: value!

Item was added:
+ ----- Method: ByteArrayReadWriter>>floatAtByteOffset: (in category 'read/write atomics') -----
+ floatAtByteOffset: oByteOffset 
+ 
+ 	self checkAt: oByteOffset.
+ 	^ byteArray floatAtByteOffset: oByteOffset + byteOffset!

Item was added:
+ ----- Method: ByteArrayReadWriter>>floatAtByteOffset:put: (in category 'read/write atomics') -----
+ floatAtByteOffset: oByteOffset put: value
+ 
+ 	self checkAt: oByteOffset.
+ 	^ byteArray floatAtByteOffset: oByteOffset + byteOffset put: value!

Item was removed:
- ----- Method: Float32Array>>floatAt: (in category '*FFI-Kernel-accessing') -----
- floatAt: byteOffset
- 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:."
- 	
- 	^ self atByteOffset: byteOffset!

Item was removed:
- ----- Method: Float32Array>>floatAt:put: (in category '*FFI-Kernel-accessing') -----
- floatAt: byteOffset put: value
- 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:put:."
- 	
- 	^ self atByteOffset: byteOffset put: value!

Item was added:
+ ----- Method: Float32Array>>floatAtByteOffset: (in category '*FFI-Kernel-accessing') -----
+ floatAtByteOffset: byteOffset
+ 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:."
+ 	
+ 	^ self atByteOffset: byteOffset!

Item was added:
+ ----- Method: Float32Array>>floatAtByteOffset:put: (in category '*FFI-Kernel-accessing') -----
+ floatAtByteOffset: byteOffset put: value
+ 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:put:."
+ 	
+ 	^ self atByteOffset: byteOffset put: value!

Item was removed:
- ----- Method: Float64Array>>doubleAt: (in category '*FFI-Kernel-accessing') -----
- doubleAt: byteOffset
- 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:."
- 
- 	^ self atByteOffset: byteOffset!

Item was removed:
- ----- Method: Float64Array>>doubleAt:put: (in category '*FFI-Kernel-accessing') -----
- doubleAt: byteOffset put: value
- 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:put:."
- 	
- 	^ self atByteOffset: byteOffset put: value!

Item was added:
+ ----- Method: Float64Array>>doubleAtByteOffset: (in category '*FFI-Kernel-accessing') -----
+ doubleAtByteOffset: byteOffset
+ 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:."
+ 
+ 	^ self atByteOffset: byteOffset!

Item was added:
+ ----- Method: Float64Array>>doubleAtByteOffset:put: (in category '*FFI-Kernel-accessing') -----
+ doubleAtByteOffset: byteOffset put: value
+ 	"Backstop for compatibility with handle-based access. Raw-bits arrays are their own handle. See #getHandle and ExternalType >> #handle:at:put:."
+ 	
+ 	^ self atByteOffset: byteOffset put: value!



More information about the Squeak-dev mailing list