From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA28890 for caml-redistribution; Wed, 3 Feb 1999 13:02:36 +0100 (MET) 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 OAA04529 for ; Mon, 1 Feb 1999 14:27:47 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id OAA07544; Mon, 1 Feb 1999 14:27:42 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA21476; Mon, 1 Feb 1999 14:27:42 +0100 (MET) Message-ID: <19990201142742.34877@pauillac.inria.fr> Date: Mon, 1 Feb 1999 14:27:42 +0100 From: Xavier Leroy To: John Prevost , caml-list@inria.fr Subject: Re: Optimization with -inline n References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: ; from John Prevost on Thu, Jan 28, 1999 at 04:58:42AM -0500 Sender: weis > In what circumstances will ocamlopt -inline n put a function in-line? > I was just trying it to see what effect it could have on my monadic > parsing libraries, but it didn't seem to have much effect, whereas my > inlining by hand did. I take this to mean that it does not, at least, > cross module boundaries. Inlining does cross module boundaries. However, it has the following limitations: - functions defined recursively are not inlined; - when inlining higher-order functions with known function arguments, those known function arguments are not themselves inlined. The latter limitation is unfortunate, as it means that only "first-order" code can really benefit from inlining, however it's not yet clear to me how to remove this limitation within the limits of the current implementation of inlining. > When should I expect to see ocamlopt inlining functions? For each function definition, ocamlopt estimates the size of the function body (in instructions -- this is a fairly approximative computation). If the size is less than the parameter to ocamlopt -inline , the function is marked inlinable. If you're curious to see what has been actually inlined, you can compile with ocamlopt -S and look at the generated assembly code, or (slightly more readable) compile with ocamlopt -dcmm; this causes the first intermediate code after inlining to be dumped on standard output. - Xavier Leroy