Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Comparison of OCaml and MLton for numerics
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-01 (15:58)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] Comparison of OCaml and MLton for numerics
Alain Frisch wrote:

>Brian Hurt wrote:
>>where the function is only called from one place, or 3) where inlining
>>opened up signifigant other optimization opportunities.  The classic
>>example for Ocaml here is replacing a call to with an
>>integer compare.  Most of the rest of the time, inlining is either a
>>break even proposition, or often a loss.
>Another good situation is when inlining allows the compiler to turn a
>function call to an unknown location into a direct function call (or no
>function call at all). This happens as soon as you write " (fun
>x -> ...)". Inlining would avoid the allocation of the closure
>and a computed call (and then the local abstraction will also be inlined
>in the body of the inlined because it is used only once).
>Currently, OCaml never inlines recursive functions.

This qualifies as an optimization opportunity- turning a call to 
caml_apply into a direct function call is an optimization.  Which may 
open up other optimization possibilities.  But that was my point- if the 
only thing you're getting out of inlining a function is skipping a 
function call (to a known location), then inlining generally isn't worth 
it- it's only worth it if it opens up other possibilities.