This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
dirk@ida.ing.tu-bs.de writes: > > Thanks for your answer! > > I checked the guile source to figure out how scm_protect_object and > scm_unprotect_object work: > > - there is a global list 'scm_protects' > - whenever a new object is to be protected: > scm_protects = scm_cons(obj scm_protects); > > - when an object is to be unprotected: > scm_delq_x(obj, scm_protects) > > Besides the fact that this is a time consuming implementation, it has > a major problem: regardless of how often an object was protected, a > single call to unprotect will make it subject to gc. > Yes, I've found this to be a problem as well. That's what I was going to say in the part of my message that apprently got deleted. > A simple fix was, not to call scm_delq_x, but a function which only > deletes the first occurence of the object from scm_protects. > > However, this approach still seems to be quite ineffective: For every > level of protection a new pair is constructed. Wouldn't it make sense to > have a SCM subtype for protected objects, which consist of a pair with a > counter and the 'real' SCM object? > IMO a good solution would be to make the protected list a hash table from objects to reference counts, with scm_reference_object and scm_unreference_object which increment or decrement the counts and add or delete entries as appropriate. > Also, there should be access to this feature through the gh_ interface. > Currently, the gh_ interface knows nothing about GC because it's meant to be portable to other Scheme implementations. Of course, since many other Schemes require C code to mark even objects on the stack, ignoring GC issues entirely does not make things more portable. - Maciej