[Vm-dev] VM Maker: VMMaker.oscog-EstebanLorenzano.1725.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Mar 14 14:45:01 UTC 2016

Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker.oscog-EstebanLorenzano.1725
Author: EstebanLorenzano
Time: 14 March 2016, 3:43:34.128098 pm
UUID: 565d98b6-020e-48f3-b2fe-171e8b09ee52
Ancestors: VMMaker.oscog-nice.1724

make FFI load symbol fail after (when find function fails). 
In Pharo, we allow to load global functions (so we can control world windows through FFI). 

This change should not affect other distributions (it wil just fail a bit after).

=============== Diff against VMMaker.oscog-nice.1724 ===============

Item was changed:
  ----- Method: ThreadedFFIPlugin>>primitiveLoadSymbolFromModule (in category 'primitives') -----
  	"Attempt to find the address of a symbol in a loaded library.
  	loadSymbol: aSymbol fromModule: moduleName
  		<primitive: 'primitiveLoadSymbolFromModule' error: errorCode module: 'SqueakFFIPrims'>
  	<export: true>
  	| symbol module moduleHandle address oop ptr |
  	<var: #address type: #'void *'>
  	<var: #ptr type: #'void **'>
  	interpreterProxy methodArgumentCount = 2 ifFalse:
  		[^interpreterProxy primitiveFailFor: PrimErrBadNumArgs].	
  	module := interpreterProxy stackValue: 0.
  	symbol := interpreterProxy stackValue: 1.
+ 	module ~= interpreterProxy nilObject 
+ 		ifTrue: [ moduleHandle := self ffiLoadCalloutModule: module ]
+ 		ifFalse: [ moduleHandle := nil ].
- 	moduleHandle := self ffiLoadCalloutModule: module.
  	interpreterProxy failed ifTrue:
  		[^interpreterProxy primitiveFailFor: PrimErrNotFound].
  	address := interpreterProxy
  					ioLoadSymbol: (self cCoerce: (interpreterProxy firstIndexableField: symbol) to: #sqInt)
  					OfLength: (interpreterProxy byteSizeOf: symbol)
  					FromModule: moduleHandle.
  	(interpreterProxy failed
  	 or: [address = 0]) ifTrue:
  		[^interpreterProxy primitiveFailFor: PrimErrNotFound].
  	oop := interpreterProxy 
  			instantiateClass: interpreterProxy classExternalAddress 
  			indexableSize: (self sizeof: #'void *').
  	ptr := interpreterProxy firstIndexableField: oop.
  	ptr at: 0 put: address.
  	^interpreterProxy methodReturnValue: oop!

More information about the Vm-dev mailing list