users-prolog
[Top][All Lists]
Advanced

[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 21:28:29 +1000
User-agent: Mutt/1.2.5i

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

-- 
Fergus Henderson <address@hidden>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.



reply via email to

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