[Vm-dev] VM Maker: VMMaker.oscog-nice.2109.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jan 24 22:09:24 UTC 2017


Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2109.mcz

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

Name: VMMaker.oscog-nice.2109
Author: nice
Time: 24 January 2017, 11:07:49.532985 pm
UUID: 75960d07-50a0-4d6c-a9b0-e4795bdb4eff
Ancestors: VMMaker.oscog-eem.2108

Fix FFI in 64bits. The moduleHandle (a pointer) was incorrectly truncated to an int (32bits).

This can eventually work (by luck), but for large libraries like lapack, addresses get higher and luck seems unlikely...

Note: only correct ThreadedFFIPlugin.
There are also plenty such 'int *' declaration in FFIPlugin, but they are left as is, considered obsolete.

=============== Diff against VMMaker.oscog-eem.2108 ===============

Item was changed:
  ----- Method: ThreadedFFIPlugin>>ffiLoadCalloutModule: (in category 'symbol loading') -----
  ffiLoadCalloutModule: module
  	"Load the given module and return its handle"
  	| moduleHandlePtr moduleHandle ffiModuleName moduleLength rcvr ptr |
+ 	<var: #ptr type:'sqInt *'>
- 	<var: #ptr type:'int *'>
  	(interpreterProxy isBytes: module) ifTrue:[
  		"plain module name"
  		ffiModuleName := module.
  		moduleLength := interpreterProxy byteSizeOf: ffiModuleName.
  		moduleHandle := (interpreterProxy
  							ioLoadModule: (interpreterProxy firstIndexableField: ffiModuleName) asInteger
  							OfLength: moduleLength) asInteger.
  		(interpreterProxy failed
  		 or: [moduleHandle = 0]) ifTrue:
  			[^self ffiFail: FFIErrorModuleNotFound]. "failed"
  		^moduleHandle].
  	"Check if the external method is defined in an external library"
  	rcvr := interpreterProxy stackValue: interpreterProxy methodArgumentCount.
  	(interpreterProxy is: rcvr KindOfClass: interpreterProxy classExternalLibrary) ifFalse:
  		[^self ffiFail: FFIErrorNoModule].
  	"external library"
  	moduleHandlePtr := interpreterProxy fetchPointer: 0 ofObject: rcvr.
  	moduleHandle := self ffiContentsOfHandle: moduleHandlePtr errCode: FFIErrorBadExternalLibrary.
  	interpreterProxy failed ifTrue:[^0].
  	moduleHandle = 0 ifTrue:["need to reload module"
  		ffiModuleName := interpreterProxy fetchPointer: 1 ofObject: rcvr.
  		(interpreterProxy isBytes: ffiModuleName) ifFalse:[^self ffiFail: FFIErrorBadExternalLibrary].
  		moduleLength := interpreterProxy byteSizeOf: ffiModuleName.
  		moduleHandle := (interpreterProxy
  								ioLoadModule: (interpreterProxy firstIndexableField: ffiModuleName) asInteger
  								OfLength: moduleLength) asInteger.
  		(interpreterProxy failed
  		 or: [moduleHandle = 0]) ifTrue:
  			[^self ffiFail: FFIErrorModuleNotFound]. "failed"
  		"and store back"
  		ptr := interpreterProxy firstIndexableField: moduleHandlePtr.
  		ptr at: 0 put: moduleHandle].
  	^moduleHandle!



More information about the Vm-dev mailing list