Version française
Home     About     Download     Resources     Contact us    
Browse thread
OCaml and Boehm
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Goswin von Brederlow <goswin-v-b@w...>
Subject: Re: [Caml-list] OCaml and Boehm
Basile STARYNKEVITCH <basile@starynkevitch.net> writes:

> Lukasz Stafiniak wrote:
>> Hi,
>>
>> 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.) And if not, could it be patched to make it
>> Boehm-safe in this sense?
>>
>>
> Probably not. Because I am not sure of what you mean by Boehm-safe,
> since Boehm's GC is conservative and do not make much promises.

It makes the promise that a block that is pointed too is never freed.
(at least for some form of pointed too)

> And very probably, Ocaml runtime cannot realistically be make
> Boehm-safe or even Boehm compatible.

Correct me if I'm wrong but aren't pointers in ocaml always pointing
inside allocated memory instead of its begining? Each block has a
header and the ocaml value points to after the header. So every ocaml
value would be 4/8 bytes offset to the real address of a block.

Can Boehm cope with that at all?

> However, it could happen that you might run some Boehm GC code inside
> Ocaml if you are lucky. You should be sure that no pointer go from
> GC-Boehm zone into Ocaml zone.

And probably the other way around too given the above. But you need
bindings for any non ocaml code you call so you already have stub
functions between ocaml and boehm using code. Any values that pass
between the two you can register with each GC. But I fear Boehm has no
finalize_* equivalent which you would need to tell the ocaml GC a
value as been droped when the Boehm GC frees something.

So I would guess you can't pass ocaml pointers into Boehm GC at all
without manually handling the resource.

> But your question is really too vague. What is the Boehm-GC based code
> you want to run within an Ocaml application, and what is that
> application?
>
> Regards.

MfG
        Goswin