* GC of custom blocks Re: [Caml-list] User-defined equality on types?
@ 2001-04-19 22:31 David Gurr
0 siblings, 0 replies; only message in thread
From: David Gurr @ 2001-04-19 22:31 UTC (permalink / raw)
To: frisch; +Cc: caml-list, gurr
Alain Frisch:
> I support this suggestion. The standard equality/ordering/hashing
> functions are often adequate for most of the data structures, and it would
> be useful to use them and just place a hook on specific types to provide
> specialized implementation. It could almost be done with
> the "custom" block tag; the problem is that such blocks are not garbage
> collected. What about "custom Caml blocks" ?
The memory manager Cmm (not to be confused with the IL in ocamlopt)
gives a generic garbage collection interface that allows custom garbage
collectors and custom heaps in such a way that one can use multiple
collectors with multiple heaps including collection of cross heap
pointers. It is designed to do garbage collection of C++ so it is
complicated by C++ details. But the basic design is good. To use the
Cmm design with custom blocks would require
-- defining a heap interface type
struct heap_operations {
value (*alloc)(heap h, unsigned long size, mlsize_t mem, mlsize_t max);
value (*alloc_block)(heap h, tag_t tag, mlsize_t size, mlsize_t mem, mlsize_t max);
void (*register_root)(heap h, value r);
void (*unregister_root)(heap h, value r);
void (*scavenge)(heap h, value v); /* ie mark, copy, etc */
void (*collect)(heap h);
void (*collect_slice)(heap h); /* may need more parameters */
void (*compact)(heap h);
};
-- an addtional operation pointer:
struct custom_operations {
...
void (*traverse)(value v); /* walks v calling scavenge on its pointers */
};
-- using the existing minor and major heaps to implement heap interfaces
value alloc_shr_prime(heap h, tag_t tag, mlsize_t size, mlsize_t mem, mlsize_t max){
return alloc_shr(tag,size);
}
...
struct heap_operations major_heap = {
0, /* you can only alloc standard blocks in the major heap */
&alloc_shr_prime,
®ister_global_root_prime,
... };
See
ftp://ftp.di.unipi.it/pub/project/posso/cmm/
for Cmm papers and source. Kaffe (an open source Java implementation)
also has custom allocators and collectors but I have forgotten the details.
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-04-19 22:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-19 22:31 GC of custom blocks Re: [Caml-list] User-defined equality on types? David Gurr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox