Even as the author of some parts of Adjustor.c and some parts of Hugs' FFI implementation I have to admit that it isn't clear to me at all if tail-calls
are used everywhere. %-)

Hugs uses tail-jumps or static return code on all supported platforms, GHC on all platforms except IA64.

And even if this is currently the case: Can we
really guarantee this for all eternity for every strange ABI people will come
up with? I'm not so sure about this, therefore I'd recommend against
"self-destruction", as handy as it admittedly is. I'd be happy to be
convinced of the opposite...

You'd be happy? OK, I'll try.

I think it will be possible for all ABIs. Tearing down the stack frame or whatever needs to be done on the way out can always be done by a piece of static code; even if some "dynamic" information (like, for example, the size of the stack frame) is needed, this information can be stored in the stack frame or in a register by the function that sets up the stack frame.

Or if you want to look at it differently:

1.) We can generate a thunk that will tail-call to a static piece of code and pass an additional constant argument to that static piece of code, with a custom calling convention.
2.) We can dynamically generate a call to the stub function.

If those two axioms are fulfilled for a platform, we can support self- destruction.

2 will definitely be supported (otherwise NO interpreters with FFI would work on that platform), and I can't imagine how a platform can NOT support 1....


Grüße,

Wolfgang

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to