guile-devel
[Top][All Lists]
Advanced

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

Re: scm_remember


From: Dirk Herrmann
Subject: Re: scm_remember
Date: Wed, 1 Nov 2000 11:45:30 +0100 (MET)

On 1 Nov 2000, Michael Livshin wrote:

> Dirk Herrmann <address@hidden> writes:
> 
> > Currently, scm_remember
> > expects a scm* as its parameter.  However, for the sake of keeping the
> > value alive it would suffice to pass the SCM value:
> > 
> >   chars = SCM_STRING_CHARS (str);
> >   some_syscall (chars);
> >   scm_remember (str);
> 
> I don't think so.  if `scm_remember' takes an SCM, then the compiler
> has all the rights to reuse the register (or the stack word) that held 
> `str'.
> 
> but if you pass a pointer to `str', then the compiler has (or at least
> it can be hoped that it has) to make sure that the pointer really
> points to a valid location that contains `str', and at least for the
> life expectancy of `str'.

I don't understand what you mean:  Sure, the compiler is allowed to reuse
the register or stack word of 'str', but only _after_ the call to
scm_remember.  The purpose of scm_remember is:  "Make sure the value
lives up to exactly this point.  I don't care what happens after this
point."  If you look at the example above, we only have to guarantee that
the str object lives until some_syscall has returned, because otherwise
the chars pointer might become invalid if str was collected in the
meantime.  We don't need to keep str after some_syscall, but we can't
say so other than by calling scm_remember immediately afterwards.  After 
the call to scm_remember str _can_ legally be collected.

Or am I missing something?

Best regards
Dirk Herrmann




reply via email to

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