[Vm-dev] FFIExternalStructureReferenceHandle and pushing it to the stack
holger at freyther.de
Thu Apr 4 07:36:08 UTC 2019
In addition to my mail from yesterday to vm-dev I want to share the following example to illustrate the problem. I have taken StructA and StructNested from the FFIExternalStructureReferenceHandle class comment and put it into Unclassified.st that is attached to this mail. I am also making a call to LibC's getpid and try to push StructNested to the stack. The ffiCall is failing before getpid is called (Bad argument to external function).
The reproducer is:
StructA new theNest anyCall.
StructA has a ByteArray handle of the full struct. theNest returns an instance of StructNested with a FFIExternalStructureReferenceHandle. This makes sense as well. It can't be a copy of the ByteArray (or else updates would be invisible to the outer struct) and it can't be an ExternalAddress as StructA's handle might move in the Smalltalk heap.
I am not entirely sure how this is should work but what do you think of:
1st) Extending ExternalStructure class comment to list FFIExternalStructureReferenceHandle as possible handle type? I think we would only describe the reality.
2nd) ThreadedFFIPlugin>>#ffiPushStructureContentsOf: should be aware of FFIExternalStructureReferenceHandle and know how to reach the handle. Or should there be something in the image converting this to a ByteArray when being pushed as value in a ffiCall?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5938 bytes
Desc: not available
More information about the Vm-dev