From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 5DE28BC57 for ; Wed, 31 Mar 2010 20:59:09 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgcFANo3s0vB/Bd4Y2dsb2JhbACbNQsXCAsHEQUfwUWFAAQ X-IronPort-AV: E=Sophos;i="4.51,342,1267398000"; d="scan'208";a="48146799" Received: from smtp-msa-out01.orange.fr ([193.252.23.120]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Mar 2010 20:59:09 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id B79EC1C00058; Wed, 31 Mar 2010 20:59:08 +0200 (CEST) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id A33001C0005E; Wed, 31 Mar 2010 20:59:08 +0200 (CEST) Received: from [192.168.1.53] (APuteaux-154-1-96-239.w83-204.abo.wanadoo.fr [83.204.231.239]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id 63B841C00058; Wed, 31 Mar 2010 20:59:08 +0200 (CEST) X-ME-UUID: 20100331185908408.63B841C00058@mwinf5a04.orange.fr X-ME-User-Auth: lexifi Message-ID: <4BB39B7C.6050402@frisch.fr> Date: Wed, 31 Mar 2010 20:59:08 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Dmitry Bely Cc: Caml List Subject: Re: [Caml-list] Optimizing Float Ref's References: <4A9F9015.2010408@inria.fr> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 ref's:01 ref's:01 unboxed:01 compiler:01 unboxed:01 val:01 ocaml:01 compiler:01 mutable:01 2009:98 wrote:01 wrote:01 dmitry:01 On 31/03/2010 19:21, Dmitry Bely wrote: > On Thu, Sep 3, 2009 at 1:44 PM, Xavier Leroy wrote: > (...) >>> But, I thought that float ref's were automatically unboxed by the compiler >>> when they didn't escape the local context. >> >> Yes, if all uses of the float ref are unboxed, which is the case in >> your code. > > let max_val (a:float array) = > let m = ref min_float in > for i = 0 to (Array.length a) - 1 do > if a.(i)> !m > then m := a.(i) > done; > !m > > !m is not unboxed (Ocaml 3.11). Should it? As far as I can tell, the boxing for the reference cell is removed by the compiler (that is, the reference is implemented as a mutable local variable), but not the boxing for the float contained in the reference. Since a is a float array, it is needed to box the float before putting it in the reference, hence the allocation. -- Alain