Re: inlining functions called through functor parameters?

From: Xavier Leroy (Xavier.Leroy@inria.fr)
Date: Thu Feb 03 2000 - 19:38:38 MET

  • Next message: skaller: "Re: finalisation"

    > While searching the Caml mailing list archive, I found
    > a message from Xavier Leroy, posted on Tue Jun 23 1998,
    > in which he describes the fact that:
    > "... it is true that functions taken from the
    > functor parameter are always called via their closures".
    > I was wondering if this is still true (since 1998 is a long
    > time ago, in internet time at least), and if there are any plans
    > to implement more inlining for such functions.

    Yes, this is still true. So far, the body of a functor is compiled
    only once (at the point where it's defined), and this precludes
    inlining of the functions contained in the functor parameter (consider
    two applications of the functor).

    > The reason I ask is because I'm writing a couple of modules where
    > lots of small funtions are called via a functor parameter, and
    > I'm wondering if it's worth the trouble to inline them "by hand".

    If the functor is applied only once, you could turn it into a
    structure that references directly its argument; this will enable
    automatic inlining. Otherwise, and assuming that's the performance
    bottleneck in your program, it could be worth the effort to inline
    manually some of the functions.

    All the best,

    - Xavier Leroy



    This archive was generated by hypermail 2b29 : Fri Feb 04 2000 - 08:51:15 MET