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
Re: Q: float arrays
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: rowan+@c...
Subject: Controlling inlining [was Re: Q: float arrays]

> I know that I'm asking too much, but wouldn't it be nice it the
> compiler did it for me?   In the example at hand,
>   let f2 = map (function (p,p') -> (p*.p'))
> the compiler could inline the multiplication automagically, iff it
> still had access to the definition of the map function.
> Here partial application really shines and it could shine even
> brighter if there was no speed penalty ...

Xavier replied:
> That's right, and I still plan to put some automatic inlining in
> Objective Caml at some point. However, known inlining strategies
> are very conservative and err on the safe side in order to avoid code
> size blowup. This means that if your "map" functional is sufficiently
> big, it will not be inlined, even though this could resut in important
> speedups.

This is part of the motivation for my recent work with Frank Pfenning
on "Staged Computation", which is related to partial evaluation and
run-time code generation.  The basic idea is to allow the programmer
to annotate their program to indicate which parts can be done "early",
which in this case means compile-time.  The result of the early stage
is a residual program which is executed at a later stage, in this case

Using annotations allows the programmer to identify situations where
"inlining" (or "specialization") would be beneficial, which is very
difficult for the compiler to determine.  A static type system
guarantees that the programmers annotations are consistent, and allows
propagation of this information across module boundaries.

There are two papers so far describing this work, though both are
rather abstract.  The first [1] describes a language which allows
specialization at run-time.  The second [2] describes a system with
distinct stages like "compile-time" and "run-time".


- Rowan

[1] Rowan Davies and Frank Pfenning.  A Modal Analysis of Staged
Computation, 23rd Annual ACM Symposium on Principles of Programming
Languages (POPL'96), St. Petersburg Beach, Florida, January 1996.  ACM

[2] Rowan Davies. A Temporal Logic Approach to Binding-Time Analysis,
In E. Clarke, editor, Proceedings of the Eleventh Annual Symposium on
Logic in Computer Science, New Brunswick, New Jersey, July 1996. IEEE
Computer Society Press.