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

commits at source.squeak.org commits at source.squeak.org
Fri Aug 28 12:55:28 UTC 2015


Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-EstebanLorenzano.1445.mcz

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

Name: VMMaker.oscog-EstebanLorenzano.1445
Author: EstebanLorenzano
Time: 28 August 2015, 2:53:43.289316 pm
UUID: 30a4eca9-7084-44ad-afec-ec964765b8a8
Ancestors: VMMaker.oscog-rmacnak.1444

adding ThreadedFFIPlugin>>#primitiveLoadSymbolFromModule (copy and adapt from IA32ABIPlugin)

=============== Diff against VMMaker.oscog-rmacnak.1444 ===============

Item was added:
+ ----- Method: ThreadedFFIPlugin>>primitiveLoadSymbolFromModule (in category 'primitives') -----
+ primitiveLoadSymbolFromModule
+ 	"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:'unsigned int *'>
+ 	
+ 	interpreterProxy methodArgumentCount = 2 ifFalse:
+ 		[^interpreterProxy primitiveFailFor: PrimErrBadNumArgs].	
+ 
+ 	module := interpreterProxy stackValue: 0.
+ 	symbol := interpreterProxy stackValue: 1.
+ 
+ 	moduleHandle := self ffiLoadCalloutModule: module.
+ 	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: 4.
+ 	ptr := interpreterProxy firstIndexableField: oop.
+ 	ptr at: 0 put: address.
+ 	
+ 	interpreterProxy methodReturnValue: oop!



More information about the Vm-dev mailing list