
On 11-Jun-2002, Daniel Diaz Daniel.Diaz@univ-paris1.fr wrote:
Fergus is right, GNU Prolog uses ebp to map a WAM register in a physical register (to increase efficiency). Since ebp serves as frame pointer, the code using WAM internals should be compiled with -fomit-frame-pointer. Other code CAN use ebp (since ebp is saved/restored in called functions). But a foreign code needs to be compiled withth -fomit-frame-pointer (and also -O2 or -O3).
Using `-fomit-frame-pointer' (with or without -O2/-O3) is not sufficient to guarantee that the generated code won't use the `ebp' register. The `-fomit-frame-pointer' option tells GCC to omit a frame pointer where possible, but it's not always possible. In particular, code using variable-length arrays or alloca() always needs a frame pointer. There may also be other circumstances in which a frame pointer is required.
While it's OK to avoid using such features in the code for GNU Prolog itself, 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.
I think it would be better for GNU Prolog to save/restore ebp itself, either in the code for handling exceptions, or when calling foreign code. (However, I'm not that familiar with the internals of GNU Prolog, so I don't know how feasible this would be.)