This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: Scm_sloppy_assq mostly fixed, still real slow
- To: hanwen at cs dot uu dot nl
- Subject: Re: Scm_sloppy_assq mostly fixed, still real slow
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 25 Jul 2000 16:42:35 +0200
- Cc: Jan Nieuwenhuizen <janneke at gnu dot org>, guile at sourceware dot cygnus dot com, djurfeldt at nada dot kth dot se
- Cc: djurfeldt at nada dot kth dot se
- References: <xy74s6wp33n.fsf@mdj.nada.kth.se><200006142031.WAA16169@appel.dyndns.org><14665.4651.97147.471377@dokkum.cs.uu.nl>
- Reply-To: djurfeldt at nada dot kth dot se
Han-Wen Nienhuys <hanwen@cs.uu.nl> writes:
[Sorry for commenting on this so lately. Maybe this question is out
of date by now.]
> To shed some further light on Lily's memory handling: Most smobs in
> lily smobify and protect themselves, i.e.
>
> Obj::Obj ()
> {
> self_scm_ = smobify_self();
> scm_protect_object (self_scm_);
> }
>
> later on, the smob is put into a big scheme list representing the
> score and the object is unprotected,
>
> list_ = gh_cons (obj->self_scm_, list_);
> scm_unprotect_object (obj->self_scm_);
>
> This used to be quite efficient because there was little
> time betweeen protect and unprotected (so unprotected would find the
> object quickly, in front of the list.)
>
> It is done in this way, because there might very well be some time
> between creation ("new Obj") and list-adding, in which a GC would kill
> an object that wasn't yet added to the score list.
I think you should avoid calling scm_protect_object.
There are many ways to achieve this. Two ways could be:
1. Smobify the object outside of the object, when putting the object
in the Scheme list.
or
2. Since you are able to put the object in a Scheme list later, you
are keeping the object in some kind of data structure S. In
addition to smobify_self (), you could have a mark_self () in every
object. If you protect the data structure S, the mark function for
S could call mark_self () in every object in S.
Best regards,
/mdj