* [Caml-list] GC assumptions ?
@ 2016-01-16 21:42 Nicolas Ojeda Bar
2016-01-17 11:01 ` Gerd Stolpmann
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Ojeda Bar @ 2016-01-16 21:42 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
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.
Any ideas?
Thanks!
Cheers,
Nicolas
[-- Attachment #2: Type: text/html, Size: 524 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] GC assumptions ?
2016-01-16 21:42 [Caml-list] GC assumptions ? Nicolas Ojeda Bar
@ 2016-01-17 11:01 ` Gerd Stolpmann
2016-01-18 18:58 ` Pierre Chambart
0 siblings, 1 reply; 3+ messages in thread
From: Gerd Stolpmann @ 2016-01-17 11:01 UTC (permalink / raw)
To: Nicolas Ojeda Bar; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]
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
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de
My OCaml site: http://www.camlcity.org
Contact details: http://www.camlcity.org/contact.html
Company homepage: http://www.gerd-stolpmann.de
------------------------------------------------------------
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] GC assumptions ?
2016-01-17 11:01 ` Gerd Stolpmann
@ 2016-01-18 18:58 ` Pierre Chambart
0 siblings, 0 replies; 3+ messages in thread
From: Pierre Chambart @ 2016-01-18 18:58 UTC (permalink / raw)
To: Gerd Stolpmann, Nicolas Ojeda Bar; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-18 18:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-16 21:42 [Caml-list] GC assumptions ? Nicolas Ojeda Bar
2016-01-17 11:01 ` Gerd Stolpmann
2016-01-18 18:58 ` Pierre Chambart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox