Eliot Miranda uploaded a new version of FFI-Kernel to project FFI: http://source.squeak.org/FFI/FFI-Kernel-eem.228.mcz
==================== Summary ====================
Name: FFI-Kernel-eem.228 Author: eem Time: 13 April 2023, 2:40:45.749373 pm UUID: 77163f53-9648-49ae-904a-d16fd63af2ab Ancestors: FFI-Kernel-eem.227
Make sure that compiledSpecs in ExternalLibraryFunctions in CompiledMethods are up-to-date after a platform change. The current FFI code invalidates these on platform change, but does nothing to update them.
Hence cache allInstances of ExternalLibraryFunction in a class var to avoid having to do an allInstancesDo: whenever the platform changes.
=============== Diff against FFI-Kernel-eem.227 ===============
Item was changed: ExternalFunction subclass: #ExternalLibraryFunction instanceVariableNames: 'name module errorCodeName' + classVariableNames: 'Instances' - classVariableNames: '' poolDictionaries: '' category: 'FFI-Kernel'!
!ExternalLibraryFunction commentStamp: '' prior: 0! An ExternalLibraryFunction specifies a fully qualified function from an external library.
Instance variables: name <String | Integer> name or ordinal of function module <String | nil> name of module (nil if bound in the VM). errorCodeName <String | nil> name of temp receiving error code, if any!
Item was added: + ----- Method: ExternalLibraryFunction class>>instances (in category 'private') ----- + instances + "Cache our instances for faster reinitialization." + ^Instances ifNil: [Instances := WeakSet withAll: self allInstances]!
Item was added: + ----- Method: ExternalLibraryFunction class>>new (in category 'instance creation') ----- + new + ^self instances add: super new!
Item was added: + ----- Method: ExternalLibraryFunction class>>platformChangedFrom:to: (in category 'instance initialization') ----- + platformChangedFrom: lastPlatform to: currentPlatform + "Byte size or byte alignment for atomic types might be different on the new platform." + + "Make sure that the cache of all instances is up-to-date before using it..." + Instances ifNil: [self new]. + + "Get all instances to update their compiledSpecs so that FFI calls work." + self updateArgTypeSpecs!
Item was added: + ----- Method: ExternalLibraryFunction class>>updateArgTypeSpecs (in category 'instance initialization') ----- + updateArgTypeSpecs + self instances do: [:elf| elf updateArgTypeSpecs]!
Item was added: + ----- Method: ExternalLibraryFunction>>updateArgTypeSpecs (in category 'instance initialization') ----- + updateArgTypeSpecs + argTypes ifNotNil: + [:typeArray| typeArray do: [:argType| argType updateFromReferentClass]]!
Item was added: + ----- Method: ExternalType>>updateFromReferentClass (in category 'instance initialization') ----- + updateFromReferentClass + "If I have a referentClass update my compiledSpec to reflect the new state of the system, e.g. after a platform change." + + referentClass ifNotNil: [:refClass| self newReferentClass: refClass]!
Item was changed: ----- Method: FFIPlatformDescription class>>startUp: (in category 'system startup') ----- startUp: resuming "Notify all FFI classes about platform changes."
resuming ifTrue: [ LastPlatform in: [:lastPlatform | self newCurrent in: [:currentPlatform | lastPlatform = currentPlatform ifTrue: [ self flag: #discuss. "mt: Maybe add #platformResuming?" ExternalAddress allBeNull ] ifFalse: [ LastPlatform := currentPlatform. "Update now. See #current." + { ExternalAddress. ExternalType. ExternalPool. ExternalLibrary. ExternalLibraryFunction } - { ExternalAddress. ExternalType. ExternalPool. ExternalLibrary } do: [:cls | cls platformChangedFrom: lastPlatform to: currentPlatform] ]]]. + self checkFFIOnStartUp ifTrue: [self checkFFI]]! - self checkFFIOnStartUp ifTrue: [self checkFFI]].!
squeak-dev@lists.squeakfoundation.org