[Vm-dev] VM Maker: VMMaker.oscog-EstebanLorenzano.1567.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Dec 8 16:06:34 UTC 2015
Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-EstebanLorenzano.1567.mcz
==================== Summary ====================
Name: VMMaker.oscog-EstebanLorenzano.1567
Author: EstebanLorenzano
Time: 8 December 2015, 5:05:02.518309 pm
UUID: 363ee8d1-d2fc-4176-8efc-75bbc9e8c482
Ancestors: VMMaker.oscog-eem.1566
check for primitiveFailed after trying to load module in #primitiveLoadSymbolFromModule (it can fail and in linux load a symbol from nowhere will lead to a crash)
temporal: reverted (again) the in-memory check for access objects through FFI. It was making structure access fail... I need futher investigation on the area :)
=============== Diff against VMMaker.oscog-eem.1566 ===============
Item was changed:
----- Method: ThreadedFFIPlugin>>ffiAddressOf:startingAt:size: (in category 'primitive support') -----
ffiAddressOf: rcvr startingAt: byteOffset size: byteSize
"return an int of the address of the byteSize slot (byte, short, int, whatever) at byteOffset in rcvr. Nominally intended for use with ExternalAddress objects, this code will work (for obscure historical reasons) with plain Byte or Word Arrays as well. "
| rcvrClass rcvrSize addr |
self flag: 'This needs more thought. It is 32-bit specific. What about 64-bit platforms?'.
(interpreterProxy isBytes: rcvr) ifFalse:[^interpreterProxy primitiveFail].
(byteOffset > 0) ifFalse:[^interpreterProxy primitiveFail].
rcvrClass := interpreterProxy fetchClassOf: rcvr.
rcvrSize := interpreterProxy byteSizeOf: rcvr.
rcvrClass = interpreterProxy classExternalAddress ifTrue:[
(rcvrSize = 4) ifFalse:[^interpreterProxy primitiveFail].
addr := interpreterProxy fetchPointer: 0 ofObject: rcvr.
"don't you dare to read from object memory (unless is pinned)!!"
+ (addr = 0" or: [(interpreterProxy isInMemory: addr) or: [(interpreterProxy isPinned: rcvr) not]]")
- (addr = 0 or: [(interpreterProxy isInMemory: addr) or: [(interpreterProxy isPinned: rcvr) not]])
ifTrue:[^interpreterProxy primitiveFail].
] ifFalse:[
(byteOffset+byteSize-1 <= rcvrSize)
ifFalse:[^interpreterProxy primitiveFail].
addr := self cCoerce: (interpreterProxy firstIndexableField: rcvr) to: 'int'.
].
addr := addr + byteOffset - 1.
^addr!
Item was changed:
----- 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.
+ 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: 4.
ptr := interpreterProxy firstIndexableField: oop.
ptr at: 0 put: address.
interpreterProxy methodReturnValue: oop!
More information about the Vm-dev
mailing list