From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA05387; Sat, 2 Feb 2002 18:59:21 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA05490 for ; Sat, 2 Feb 2002 18:59:20 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g12HxJ516495; Sat, 2 Feb 2002 18:59:19 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA04607; Sat, 2 Feb 2002 18:59:18 +0100 (MET) Date: Sat, 2 Feb 2002 18:59:18 +0100 From: Xavier Leroy To: David Monniaux Cc: Liste CAML Subject: Re: [Caml-list] optimizing functors Message-ID: <20020202185918.B3976@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from David.Monniaux@ens.fr on Thu, Jan 31, 2002 at 07:49:45AM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > OCaml does inlining of functions in the same module. Does it also do it > between different modules? Yes, but not across functor applications. More precisely, functions that are passed through a functor parameter cannot be inlined nor called with the optimized "direct" application scheme, they always go through the generic "indirect-through-closure" application scheme. > Would it optimize the following: > > module M= > struct > let f = function 0 -> true | _ -> false > end > > module N (D : sig val f: int->bool end) = > struct > let f = D.f > end > > module P=N(M) > > Does the compiler optimize the call to f in P, resolving it directly to > M.f, or does it do multiple indirections? It will do exactly one indirection: fetch a function closure from P.f (which happens to be the closure of M.f), and call it indirectly (and without inlining). - Xavier Leroy ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr