
C -> adjustor -> stub -> Haskell -> stub -> adjustor -> C
It could be the case that the adjustor tail-jumps to the stub, but this is not guaranteed to be the case for all platforms.
Hmmm, I thought it was. Well, the FFI addendum is rather vague on this point; this seems to be all it says about freeHaskellFunPtr. freeHaskellFunPtr :: FunPtr a -> IO () Release the storage associated with the given \code{FunPtr}, which must have been obtained from a wrapper stub. This should be called whenever the return value from a foreign import wrapper function is no longer required; otherwise, the storage it uses will leak. Do I need the FunPtr value in order to return to C land? I didn't think so. The addendum doesn't say so. (It doesn't clearly say otherwise, though). All of the implementations in Adjustor.c *except* for the IA-64 one go to some lengths to ensure that a tail-calll is used: C -> adjustor -> stub -> Haskell -> stub -> (maybe some static code) -> C I think this confusion should be fixed... Cheers, Wolfgang