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

commits at source.squeak.org commits at source.squeak.org
Tue Aug 17 10:08:21 UTC 2021

Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:

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

Name: FFI-Kernel-mt.207
Author: mt
Time: 17 August 2021, 12:08:20.929505 pm
UUID: 693d99be-bab4-8d4c-801c-96a534e6f7d0
Ancestors: FFI-Kernel-mt.206

Adds version number of FFI plugin to the platform description. Needs primitivePluginVersion but defaults to 1 since this is a new concept. I will add this to the plugin shortly.

Note that the plugin version can be used to coordinate the communication the relies on shared data structures such as atomic-type codes and classes in the special-objects array. Then, older FFI plugins can keep on working with newer FFI images. This makes it easier to develop plugin and image-code concurrently but not in parallel. :-) Note that we do not have an "Update this VM" button in the image but we can easily update image code. Additional warnings can then help users to be notified when more recent VMs/plugins might be available.

Note that this does not help with older image code running on newer plugins. So, update your image first, then update the VM/plugins.

Note that I used the name #pluginVersion from the SqueakSSL plugin, which already provides that information.

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

Item was changed:
  Object subclass: #FFIPlatformDescription
+ 	instanceVariableNames: 'name osVersion subtype wordSize endianness pluginVersion'
- 	instanceVariableNames: 'name osVersion subtype wordSize endianness'
  	classVariableNames: 'CheckFFIOnStartUp LastPlatform'
  	poolDictionaries: ''
  	category: 'FFI-Kernel-Support'!
  !FFIPlatformDescription commentStamp: 'mt 6/2/2020 15:18' prior: 0!
  This class stores the information about the current (host) platform. It supports testing instances for platform compatibility and specificity. The entire FFI machinery should go through here, when making platform-specific decisions such as when figuring out the #wordSize for pointers to external memory (i.e., ExternalAddress class >> #new) or when looking up compatible definitions for external pools (i.e., ExternalPool class >> #compatibleResolvedDefinitions).
  This class is registered for system startup. It then checks whether the current platform is different from the last one. In that case, a selection of FFI classes gets notified such as ExternalObject and ExternalType.
  Platform descriptions may be unspecific, that is, some of their values may be undefined. For example, (FFIPlatformDescription name: 'unix') creates a valid description but is not specific about #osVersion or #wordSize. When comparing such descriptions, precedence of the platform values are:
  	platform name > osVersion > subtype > wordSize
  So, if one description has a #name and the other does not, the first one is more specific. If both have #name but only the second one has #osVersion, the second one is more specific. If one has only #wordSize and another one has only #subtype, the second one is more specific because #subtype has a higher precedence than #wordSize.
  Platform descriptions implement a notion of compatibility, which is coupled to its notion of specificity as mentioned before. Using the same rules of precedence, compatibility is checked by comparing the description's values. If not specificed, compatibility is assumed. If specified, values must match via #= to be regarded compatible.
  Here is an interesting edge case of two compatible platform descriptions:
  	| p1 p2 |
  	p1 := FFIPlatformDescription name: 'Win32' osVersion: '' subtype: 'IX86' wordSize: nil.
  	p2 := FFIPlatformDescription name: '' osVersion: 'linux-gnu' subtype: '' wordSize: 8.
  	p1 isCompatibleWith: p2.
  Consequently, the developer has to be careful with unspecific platform descriptions, which are used, for example, in the definitions of external pools.
  - all references to FFIPlatformDescription
  - all senders of #wordSize
  - class comments of ExternalAddress, ExternalType, ExternalPool, ExternalObject

Item was added:
+ ----- Method: FFIPlatformDescription class>>currentPluginVersion (in category 'system startup') -----
+ currentPluginVersion
+ 	"Answers the version of the currently loaded FFI plugin. Can be used to coordinate the communication that relies on shared data structures such as type codes (e.g., v1 means float = 12 and double = 13) and classes (e.g., v1 means ExternalType has compiledSpec at instVar[1] and ExternalObject has handle at instVar[1]."
+ 	<primitive: #primitivePluginVersion module: #SqueakFFIPrims>
+ 	^ 1!

Item was added:
+ ----- Method: FFIPlatformDescription class>>name:osVersion:subtype:wordSize:pluginVersion: (in category 'instance creation') -----
+ name: aName osVersion: anOSVersionString subtype: aSubtypeString wordSize: aWordSize pluginVersion: aVersionNumber
+ 	^ self new
+ 		name: aName;
+ 		osVersion: anOSVersionString;
+ 		subtype: aSubtypeString;
+ 		wordSize: aWordSize;
+ 		pluginVersion: aVersionNumber!

Item was changed:
  ----- Method: FFIPlatformDescription class>>newCurrent (in category 'instance creation') -----
  	^ self
  		name: self currentName
  		osVersion: self currentOSVersion
  		subtype: self currentSubtype
+ 		wordSize: self currentWordSize
+ 		pluginVersion: self currentPluginVersion!
- 		wordSize: self currentWordSize!

Item was changed:
  ----- Method: FFIPlatformDescription>>= (in category 'comparing') -----
  = anObject
  	self == anObject
  		ifTrue: [^ true].
  	self species == anObject species
  		ifFalse: [^ false].
  	^ self name = anObject name
  		and: [self osVersion = anObject osVersion
+ 		and: [self subtype = anObject subtype
+ 		and: [self wordSize = anObject wordSize
+ 		and: [self pluginVersion = anObject pluginVersion]]]]!
- 			and: [self subtype = anObject subtype
- 				and: [self wordSize = anObject wordSize]]].!

Item was added:
+ ----- Method: FFIPlatformDescription>>pluginVersion (in category 'accessing') -----
+ pluginVersion
+ 	^ pluginVersion ifNil: [pluginVersion := 1]!

Item was added:
+ ----- Method: FFIPlatformDescription>>pluginVersion: (in category 'accessing') -----
+ pluginVersion: anInteger
+ 	pluginVersion := anInteger!

More information about the Squeak-dev mailing list