caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Optimization with -inline n
@ 1999-01-28  9:58 John Prevost
  1999-02-01 13:27 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: John Prevost @ 1999-01-28  9:58 UTC (permalink / raw)
  To: caml-list

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.

When should I expect to see ocamlopt inlining functions?

jmp




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Optimization with -inline n
  1999-01-28  9:58 Optimization with -inline n John Prevost
@ 1999-02-01 13:27 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 1999-02-01 13:27 UTC (permalink / raw)
  To: John Prevost, caml-list

> 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-02-03 12:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-28  9:58 Optimization with -inline n John Prevost
1999-02-01 13:27 ` Xavier Leroy

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).