Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling Scheme from C and Garbage Collection
Mikael Djurfeldt <mdj@nada.kth.se> writes:
> Greg Harvey <Greg.Harvey@thezone.net> writes:
>
> > I really dislike the current work around, since it is, after all, not
> > much less than explicit marking.
>
> But it is more efficient, at least given the current mark-stack system.
> Take it for what it is, an optimization internal to Guile.
>
> > I'm hoping that there's a way to avoid this without declaring every
> > SCM value volatile.
>
> I haven't followed this discussion. I just jumped into it when I
> happened to see Chris' message.
>
> I claim that this is really not a problem.
It isn't really, but at the time I was sufficiently annoyed with the
gc (stop crashing, damnit... better yet, stop putting free cells in
scm_symhash!).
> The conservative GC is safe, regardless of the intelligence of the
> compiler, as long as you follow one simple rule:
>
> * Always refer to Scheme objects with malloced memory through their
> SCM value.
>
> When you aren't working with Scheme objects with malloced memory,
> there are no rules at all: It is safe.
>
> An example of when the rule above apply is:
>
> *Don't* write
>
> SCM* p = SCM_VELTS (v);
> x = p[i];
>
> Instead, write
>
> x = SCM_VELTS (v)[i];
>
> Is this so problematic?
No, a bit annoying though, since it can crop up unexpectedly, and it
may be hard to diagnose if you don't know the details. A mention in
the documentation should be enough.
> /mdj
>
> P. S. The reason why big2str has a problem is that it refers directly
> to malloced memory through the pointer ds. It doesn't need to do
> this, but it is slightly more efficient.
Yep, I don't think I was really clear in explaining what was required
to invoke the problem.
--
Greg
Guile Home |
Main Index |
Thread Index