[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PPL-devel] Re: Raising Prolog exceptions from C code (2nd attempt)

From: Fergus Henderson
Subject: Re: [PPL-devel] Re: Raising Prolog exceptions from C code (2nd attempt)
Date: Wed, 12 Jun 2002 16:17:39 +1000
User-agent: Mutt/1.2.5i

On 11-Jun-2002, Daniel Diaz <address@hidden> 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.)

Fergus Henderson <address@hidden>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]