Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: David Monniaux <David.Monniaux@ens.fr>
Cc: Liste CAML <caml-list@inria.fr>
Subject: Re: [Caml-list] optimizing functors
Date: Sat, 2 Feb 2002 18:59:18 +0100	[thread overview]
Message-ID: <20020202185918.B3976@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.GSO.4.03.10201310738521.15113-100000@basilic.ens.fr>; from David.Monniaux@ens.fr on Thu, Jan 31, 2002 at 07:49:45AM +0100

> 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


  reply	other threads:[~2002-02-02 17:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-31  6:49 David Monniaux
2002-02-02 17:59 ` Xavier Leroy [this message]
2002-02-04 12:50   ` David Monniaux
2002-02-05  8:11     ` Francois Pottier
2002-02-04 14:12 Michael Hicks

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=20020202185918.B3976@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=David.Monniaux@ens.fr \
    --cc=caml-list@inria.fr \
    /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