From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id IAA08886 for caml-redistribution; Wed, 6 Nov 1996 08:30:16 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id RAA06450 for ; Tue, 5 Nov 1996 17:58:29 +0100 Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id RAA09631 for ; Tue, 5 Nov 1996 17:58:28 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id RAA27070 for ; Tue, 5 Nov 1996 17:58:28 +0100 (MET) Received: from VIXEN.FOX.CS.CMU.EDU (VIXEN.FOX.CS.CMU.EDU [128.2.206.178]) by concorde.inria.fr (8.7.6/8.7.1) with SMTP id RAA09627 for ; Tue, 5 Nov 1996 17:58:22 +0100 (MET) Received: from VIXEN.FOX.CS.CMU.EDU by VIXEN.FOX.CS.CMU.EDU id aa03949; 5 Nov 96 11:57:15 EST From: rowan+@cs.cmu.edu To: Thorsten Ohl cc: caml-list@MARGAUX.inria.fr, Xavier Leroy Subject: Controlling inlining [was Re: Q: float arrays] In-reply-to: Your message of "Wed, 30 Oct 96 15:52:28 +0100." <9610301452.AA34276@crunch> Date: Tue, 05 Nov 96 11:56:54 EST Message-ID: <3945.847213014@VIXEN.FOX.CS.CMU.EDU> Sender: weis Thorsten: > 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 run-time. 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". Cheers - 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 press. http://www.cs.cmu.edu/~rowan/papers/mlboxpoplfinal.ps.gz [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. http://www.cs.cmu.edu/~rowan/papers/circle.ps.gz