caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] optimizing functors
@ 2002-02-04 14:12 Michael Hicks
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Hicks @ 2002-02-04 14:12 UTC (permalink / raw)
  To: David Monniaux, Xavier Leroy; +Cc: Liste CAML

I believe that the MLton compiler, which is a whole-program compiler for SML, does this sort of optimization.  See http://www.sourcelight.com/MLton/.

Mike

> -----Original Message-----
> From: David Monniaux [mailto:David.Monniaux@ens.fr]
> Sent: Monday, February 04, 2002 7:50 AM
> To: Xavier Leroy
> Cc: Liste CAML
> Subject: Re: [Caml-list] optimizing functors
> 
> 
> On Sat, 2 Feb 2002, Xavier Leroy wrote:
> 
> > 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.
> 
> I realize that the current scheme of implementing modules as 
> records is
> (relatively) simple and allows easy separate compilation. However, it
> prevents optimizations, as you said.
> 
> In code containing many modules consisting of a few small 
> functions called
> by functions in functors, this lack of optimization may be costly.
> 
> I was thinking of implementing such functors similarly as C++ 
> templates
> (expanding the functor parameters). Has some work been done on this?
> 
>  
> David Monniaux            http://www.di.ens.fr/~monniaux
> Laboratoire d'informatique de l'École Normale Supérieure,
> Paris, France
> 
> 
> -------------------
> 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
-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Caml-list] optimizing functors
@ 2002-01-31  6:49 David Monniaux
  2002-02-02 17:59 ` Xavier Leroy
  0 siblings, 1 reply; 5+ messages in thread
From: David Monniaux @ 2002-01-31  6:49 UTC (permalink / raw)
  To: Liste CAML

We are currently writing code containing lots of stacked functors. Most of
the implemented functions are simple manipulations (two lines) that invoke
functions in the functor's argument module.

OCaml does inlining of functions in the same module. Does it also do it
between different modules? 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?


David Monniaux            http://www.di.ens.fr/~monniaux
Laboratoire d'informatique de l'École Normale Supérieure,
Paris, France

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


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

end of thread, other threads:[~2002-02-05  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-04 14:12 [Caml-list] optimizing functors Michael Hicks
  -- strict thread matches above, loose matches on Subject: below --
2002-01-31  6:49 David Monniaux
2002-02-02 17:59 ` Xavier Leroy
2002-02-04 12:50   ` David Monniaux
2002-02-05  8:11     ` Francois Pottier

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