caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: John Prevost <prevost@maya.com>, caml-list@inria.fr
Subject: Re: Optimization with -inline n
Date: Mon, 1 Feb 1999 14:27:42 +0100	[thread overview]
Message-ID: <19990201142742.34877@pauillac.inria.fr> (raw)
In-Reply-To: <ya2aez367n1.fsf@zarya.maya.com>; from John Prevost on Thu, Jan 28, 1999 at 04:58:42AM -0500

> 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 <n> parameter to
ocamlopt -inline <n>, 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




      reply	other threads:[~1999-02-03 12:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-28  9:58 John Prevost
1999-02-01 13:27 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990201142742.34877@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=prevost@maya.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).