[Gc] Two-phase finalization?
2015-11-08 11:28:14 GMT
The Scheme interpreter Guile has been using the Boehm GC since version 2.0 and that's part of the reason the music typesetter LilyPond has not yet been ported to Guile 2. Guile offers user-defined types and in particular allows registering a deallocation procedure for them via -- C Function: void scm_set_smob_free (scm_t_bits tc, size_t (*free) (SCM obj)) This function sets the smob freeing procedure (sometimes referred to as a "finalizer") for the smob type specified by the tag TC. TC is the tag returned by ‘scm_make_smob_type’. The FREE procedure must deallocate all resources that are directly associated with the smob instance OBJ. It must assume that all ‘SCM’ values that it references have already been freed and are thus invalid. It must also not call any libguile function or macro except ‘scm_gc_free’, ‘SCM_SMOB_FLAGS’, ‘SCM_SMOB_DATA’, ‘SCM_SMOB_DATA_2’, and ‘SCM_SMOB_DATA_3’. Note in particular the second paragraph which clearly states that with respect to finalization order, there are no guarantees. Now LilyPond uses STL containers with pointers to other C++ structures with a Scheme presence a lot. It keeps these structures from being collected by using a mark procedure registered via -- C Function: void scm_set_smob_mark (scm_t_bits tc, SCM (*mark) (SCM(Continue reading)