[Vm-dev] Alien initialization

Tobias Pape Das.Linux at gmx.de
Fri Feb 23 19:45:30 UTC 2018


can someone with commit rights on Alien please change the following method?

UnsafeAlien class>>ensureInSpecialObjectsArray
	"UnsafeAlien must be in the specialObjectsArray to enable the Newsqueak FFI.
	 Because of the bootstrap the specialObjectsArray may already have been
	 partially initialized with the callback selector and to be large enough (as part of
	 loading immutability), but it will be missing UnsafeAlien until UnsafeAlien is loaded.
	 So check if the specialObjectsArray is of the expected size before recreating
	 and slam UnsafeAlien in if the specialObjectsArray is already large enough."

	| index |
	self ~~ UnsafeAlien ifTrue: [^self].

	index := 55.
	(((Smalltalk includesKey: #VMObjectIndices)
	 and: [((Smalltalk at: #VMObjectIndices) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])
	or: [
		((Smalltalk includesKey: #ObjectMemory)
		 and: [((Smalltalk at: #ObjectMemory) classPool at: #ClassUnsafeAlien ifAbsent: []) == (index - 1)])])
			[self error: 'index probably wrong'].

	Smalltalk specialObjectsArray size < index ifTrue:
		[Smalltalk recreateSpecialObjectsArray].
	(Smalltalk specialObjectsArray size < index
	 or: [(Smalltalk specialObjectsArray at: index) ~~ nil
		and: [(Smalltalk specialObjectsArray at: index) ~~ self]]) ifTrue:
		[self error: 'SystemDictionary>>recreateSpecialObjectsArray appears incompatible'].

	(Smalltalk specialObjectsArray at: index) == nil ifTrue:
		[Smalltalk specialObjectsArray at: index put: self]

This is necessary as in the current spur architecture the #Class.... class variables are no longer in ObjectMemory but in a Shared Pool.

Hence, it breaks on loading.

Best regards

More information about the Vm-dev mailing list