[Mono-dev] how does unmanaged callback marshalling work in full aot?

Rodrigo Kumpera kumpera at gmail.com
Sun Jul 31 23:35:30 EDT 2011


On Sat, Jul 30, 2011 at 6:51 PM, Brian Luczkiewicz <brian at sooloos.com>wrote:

> I just thought of a scheme to do non-static delegate marshalling without
> code generation, but it's a little bit goofy.
>
> Allocate a structure that contains two things:
>
> (1) the instance ptr that you want to capture
> (2) the function ptr for a compile-time-generated invoker that implements
> the desired unmanaged function signature.
>
> Then hand this structure off to unmanaged-land as if it were a function
> pointer.
>
> when you try to execute the function, the kernel will raise a fault. The
> runtime can notice that it's in this situation and invoke (2) with (1)
> either using another compile time generated function to forward the call, or
> (maybe on x86) by rewriting the stack to push the instance pointer + then
> jumping to the real function.
>
> There's obviously a cost associated with the fault. There's also a chance
> that the specific implementation of iOS's limitations would prohibit this
> (the kernel might murder the process before we get a chance to recover).
>
> Anyways, just a thought..
>

Yes, this would work, but performance would be so horrendous that it won't
be usable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110801/8a177ece/attachment.html 


More information about the Mono-devel-list mailing list