Browse thread
GC of custom blocks Re: [Caml-list] User-defined equality on types?
- David Gurr
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Gurr <gurr@m...> |
| Subject: | GC of custom blocks Re: [Caml-list] User-defined equality on types? |
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