English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
OCaml defunctorization and other optimizations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-05-20 (08:41)
From: Julien Signoles <julien.signoles@g...>
Subject: Re: [Caml-list] OCaml defunctorization and other optimizations

2010/5/19 Török Edwin <edwintorok@gmail.com>

> I was able to find the sources via the wayback machine.
> Unsurprisingly it doesn't build with OCaml 3.11.2 (it wants OCaml 3.06).
> Is there a more up to date variant of ocamldefun? Would it be possible
> to port it to 3.11.2?

As far as I know, there is no up to date variant of ocamldefun.
For porting to 3.11.2, you have at least to:
- update the caml AST
- migrate all the camlp4 stuff to new camlp4 or camlp5
- update the different analyses to take into account AST changes (in
particular the new caml constructs like recursive modules).

Besides ocamldefun could be hugely improved in order to generate more
efficient caml code. I know (I knew?) what to do for this purpose, but I
have no time from a while ago in order to implement myself a new version of
ocamldefun. I could provide some helps to someone motivated...

Is it possible to implement ocamldefun-like functionality via Camlp4's
> AST filters?

Defunctorisation is a fully syntactic task (that's not so true in presence
of recursive modules). But, among other thinks, defunctorisation requires to
perform the very same scope analysis than ocaml for binding each use of
variable to its declaration. I am not an expert of Camlp4 possibilities, but
defunctorisation requires to manipulate the full caml AST.

> Also is it possible to implement function specialization
> (monomorphization?) using an AST filter?
> The example from the OCaml tutorial is not optimized by
> http://www.ocaml-tutorial.org/performance_and_profiling.

I'm not an expert (again) but typing information should be required, isn't

> Or is it possible to get access to the OCaml compiler's IL
> representation and make optimizations on that?

At this day, there is no public interface to the internal modules of the
caml compiler. But, depending on the context (possible license issues), you
could embed some parts of the caml compiler in your tool.

Hope this helps,