
On 12-Jun-2002, Daniel Diaz Daniel.Diaz@univ-paris1.fr wrote:
Fergus Henderson wrote:
Using `-fomit-frame-pointer' (with or without -O2/-O3) is not sufficient to guarantee that the generated code won't use the `ebp' register. [...] I don't think it's a good idea to rely on third-party C libraries not using ebp when they are compiled with -fomit-frame-pointer. That would lead to code which might break when the third-party C library is upgraded to the next version.
Not really because if this third-party uses ebp it will then save it at the entry and restore it at the exit. So the problem comes from foreign code using a frame pointer (i.e. ebp) and calling a GNU-Prolog library function expecting ebp contains a valid WAM register.
I understand that. But IMHO the external interface that GNU-Prolog presents to C code should not rely on ebp containing a valid WAM register. Instead, GNU-Prolog should save ebp (to a global or thread-local variable) before calling foreign code, and the routines in the external interface presented to C code should restore ebp (from the global or thread-local variable) before trying to access it. Likewise for any other registers.
That's what we do in the Mercury implementation.