From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 4DF9BBBC4 for ; Mon, 13 Apr 2009 19:37:04 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4CACYV40nUGyoElGdsb2JhbACWMwEBAQEJCwgJEQO2MYN8Bg X-IronPort-AV: E=Sophos;i="4.40,180,1238968800"; d="scan'208";a="26172139" Received: from smtp4-g21.free.fr ([212.27.42.4]) by mail3-smtp-sop.national.inria.fr with ESMTP; 13 Apr 2009 19:37:03 +0200 Received: from smtp4-g21.free.fr (localhost [127.0.0.1]) by smtp4-g21.free.fr (Postfix) with ESMTP id E5F404C8152; Mon, 13 Apr 2009 19:36:57 +0200 (CEST) Received: from [192.168.1.3] (che78-2-82-237-71-191.fbx.proxad.net [82.237.71.191]) by smtp4-g21.free.fr (Postfix) with ESMTP id 554FA4C8062; Mon, 13 Apr 2009 19:36:54 +0200 (CEST) Message-ID: <49E37835.5090306@inria.fr> Date: Mon, 13 Apr 2009 19:36:53 +0200 From: Xavier Leroy User-Agent: Thunderbird 2.0.0.4 (X11/20070620) MIME-Version: 1.0 To: Lukasz Stafiniak Cc: Caml Subject: Re: [Caml-list] OCaml and Boehm References: <4a708d20904101313s49ef3b75m45202b6bda800b77@mail.gmail.com> In-Reply-To: <4a708d20904101313s49ef3b75m45202b6bda800b77@mail.gmail.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 boehm:01 ocaml:01 runtime:01 boehm:01 traversing:01 ocaml's:01 ocaml's:01 malloc:01 pointers:01 pointers:01 word-aligned:01 basile:01 malloc:01 heap:01 > Is the OCaml runtime Boehm-safe? That is, can it be run with Boehm > turned on and traversing OCaml's heap? (So that the OCaml heap can > provide roots to Boehm.) I conjecture the answer is "yes", although it's hard to tell for sure without a precise specification of what is/is not OK with the Boehm-Demers-Weiser collector. >>From the standpoint of this collector, OCaml's heap is just a set of large-ish blocks allocated with malloc() (*) and containing a zillion pointers within those blocks. OCaml doesn't play any dirty tricks with pointers: no xoring of two pointers, no pointers represented as offsets from a base, no pointers one below or one above a malloc-ed block. Most pointers are word-aligned but we sometimes play tricks with the low 2 bits. Of course, almost all Caml pointers point inside those malloc-ed blocks, not to the beginning, but I'm confident that the B-D-W collector can handle this, otherwise it would fail on pretty much any existing C code. This said, I agree with Basile that what you're trying to achieve (coexistence between several GCs) is risky, and that a design based on message passing and separated memory spaces would be more robust, if feasible. - Xavier Leroy (*) In 3.10 and earlier releases, OCaml sometimes used mmap() instead of malloc() to obtain these blocks. Starting from 3.11, malloc() is the only interface OCaml uses to obtain memory from the OS.