Date: Fri, 29 Oct 1999 10:23:39 +0200
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Michael Hicks <email@example.com>, firstname.lastname@example.org, email@example.com
Subject: Re: collecting the collector?
In-Reply-To: <199910212007.QAA25159@codex.cis.upenn.edu>; from Michael Hicks on Thu, Oct 21, 1999 at 04:07:58PM -0400
> I have some code written in OCaml that I've exported to .a file (using the
> standard procedure outlined in the OCaml manual, including using
> -output-obj); this .a file will obviously include the OCaml runtime system,
> and thus its precise collector. I'm linking this .a file with a C program
> that has its own garbage collector, the Hans-Demers-Weiser conservative
I don't know of any OCaml user that actually tried this, but I see no
reason why it shouldn't work. The OCaml heap is composed of a number
of relatively large blocks (typically 256K), all allocated with malloc()
and chained together for easy reference. Other data structures for
the OCaml runtime are either in malloc()-ed blocks or in global variables.
A conservative collector a la Boehm-Weiser will just see a bunch of
malloc()-ed blocks, with many pointers from one inside another, and
sufficient chaining to ensure that they are always live as long as the
OCaml code is active. I can't see anything that could go wrong.
> I'm wondering if anyone has any stories from doing something of this sort
> before, or could at least speculate on how the two collectors will interact.
> I'm presuming that the OCaml collector will be "contained" within the area
> governed by the conservative collector, and so that potential mishaps will
> arise from the Caml collector doing something pointer unsafe,
I'm not sure what you mean by "pointer unsafe" here. If you're
thinking about those hacks that break conservative collectors, such as
storing the difference or the XOR between two pointers, OCaml doesn't
do any of these.
- Xavier Leroy
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:28 MET