From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA02764 for caml-redistribution; Fri, 29 Oct 1999 19:06:57 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA15139 for ; Fri, 29 Oct 1999 10:23:56 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id KAA08548; Fri, 29 Oct 1999 10:23:40 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA23379; Fri, 29 Oct 1999 10:23:39 +0200 (MET DST) Message-ID: <19991029102339.16763@pauillac.inria.fr> Date: Fri, 29 Oct 1999 10:23:39 +0200 From: Xavier Leroy To: Michael Hicks , gclist@iecc.com, caml-list@inria.fr Subject: Re: collecting the collector? References: <199910212007.QAA25159@codex.cis.upenn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <199910212007.QAA25159@codex.cis.upenn.edu>; from Michael Hicks on Thu, Oct 21, 1999 at 04:07:58PM -0400 Sender: weis > 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 > collector. 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