From: Pierre Chambart <pierre.chambart@ocamlpro.com>
To: Gerd Stolpmann <info@gerd-stolpmann.de>,
Nicolas Ojeda Bar <n.oje.bar@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] GC assumptions ?
Date: Mon, 18 Jan 2016 19:58:42 +0100 [thread overview]
Message-ID: <569D35E2.9080103@ocamlpro.com> (raw)
In-Reply-To: <1453028479.32106.28.camel@e130.lan.sumadev.de>
On 17/01/2016 12:01, Gerd Stolpmann wrote:
> Am Samstag, den 16.01.2016, 22:42 +0100 schrieb Nicolas Ojeda Bar:
>> Hi list,
>>
>>
>> I am toying with the idea of using the OCaml runtime for a dynamically
>> typed language targeting Lambda. I was wondering what the OCaml
>> runtime (ie the GC) assumes about the language being compiled.
>>
>>
>> In particular I was wondering if it assumes that a value cannot go
>> from pointing to a block to being an int or vice-versa.
> This possibility exists in OCaml, e.g.
>
> type t = Block of bool | Int0
>
> Now, an assignment x := Block false; x := Int0 would do the change you
> are thinking about (argument-less variants are represented as ints).
>
> Gerd
>
Note that in that case, the value is built as an Const_pointer instead of
an integer. It announce to the compiler that this value could contain a
block later.
But the result of integer returning primitive is assumed to always be an
integer, in particular, it is not safe to do something like: (imagine the
corresponding lambda code).
let f x =
let r = ref (x + 1) in (* r is local mutable variable after simplify *)
r := Obj.magic (x,x);
call_a_function ();
!r
Since r is considered as containing an integer, it is not registered in
the frame descriptors as a potential GC root.
This is not the only place I think that assumes that, so you should
be quite carefull.
--
Pierre
prev parent reply other threads:[~2016-01-18 18:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-16 21:42 Nicolas Ojeda Bar
2016-01-17 11:01 ` Gerd Stolpmann
2016-01-18 18:58 ` Pierre Chambart [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=569D35E2.9080103@ocamlpro.com \
--to=pierre.chambart@ocamlpro.com \
--cc=caml-list@inria.fr \
--cc=info@gerd-stolpmann.de \
--cc=n.oje.bar@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox