From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id DC3F57F8C9 for ; Mon, 18 Jan 2016 19:58:55 +0100 (CET) IronPort-PHdr: 9a23:9w5jiR1fd0Zj+tursmDT+DRfVm0co7zxezQtwd8ZsekXKPad9pjvdHbS+e9qxAeQG96LtbQV1aGP6vuocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC0YLmiavrosabSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/JHBIr3ZahwdqBfCCwjOmYzrJnqsxfEZQSC/HdZSXkRlgJNCg7Dqh33CNO5lCrxse50w2G9P8D6RPgeUC7qu6EtTx3lzi0OLRY29WjWjop7i6cN8zy7oBkq+4/ZepuYfNF+d6bXdMkGDT5ZX8tLTSEHCYO1aoEGFfYpOu1Rqo3lvVxIphy7U1r/TNjzwyNF0yellZYx1P4sRFnL Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=pierre.chambart@ocamlpro.com; spf=None smtp.mailfrom=pierre.chambart@ocamlpro.com; spf=Pass smtp.helo=postmaster@redisdead.crans.org Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pierre.chambart@ocamlpro.com) identity=pra; client-ip=138.231.136.39; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierre.chambart@ocamlpro.com"; x-sender="pierre.chambart@ocamlpro.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pierre.chambart@ocamlpro.com) identity=mailfrom; client-ip=138.231.136.39; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierre.chambart@ocamlpro.com"; x-sender="pierre.chambart@ocamlpro.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@redisdead.crans.org designates 138.231.136.39 as permitted sender) identity=helo; client-ip=138.231.136.39; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pierre.chambart@ocamlpro.com"; x-sender="postmaster@redisdead.crans.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BTAgCJNZ1WlyeI54pejU+1NoYPAoE3PBABAQEBAQEBARABAQEBAQgWB0+CLYIIAQEEeAEQCw4KCRYPCQMCAQIBRQYBDAgCiBcFvyMBAQEBAQUBAQEBAR6GVYR/hFWEaAEElxqXCYVXjl05glKBZYgtAQEB X-IPAS-Result: A0BTAgCJNZ1WlyeI54pejU+1NoYPAoE3PBABAQEBAQEBARABAQEBAQgWB0+CLYIIAQEEeAEQCw4KCRYPCQMCAQIBRQYBDAgCiBcFvyMBAQEBAQUBAQEBAR6GVYR/hFWEaAEElxqXCYVXjl05glKBZYgtAQEB X-IronPort-AV: E=Sophos;i="5.22,313,1449529200"; d="scan'208";a="160806910" Received: from redisdead.crans.org ([138.231.136.39]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-GCM-SHA384; 18 Jan 2016 19:58:44 +0100 Received: from [134.157.22.158] (unknown [134.157.22.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by redisdead.crans.org (Postfix) with ESMTPSA id 6FDED61C; Mon, 18 Jan 2016 19:58:44 +0100 (CET) To: Gerd Stolpmann , Nicolas Ojeda Bar References: <1453028479.32106.28.camel@e130.lan.sumadev.de> Cc: caml-list@inria.fr From: Pierre Chambart X-Enigmail-Draft-Status: N1110 Organization: OcamlPro Message-ID: <569D35E2.9080103@ocamlpro.com> Date: Mon, 18 Jan 2016 19:58:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 MIME-Version: 1.0 In-Reply-To: <1453028479.32106.28.camel@e130.lan.sumadev.de> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Validation-by: pierre.chambart@ocamlpro.com Subject: Re: [Caml-list] GC assumptions ? 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