Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Török_Edwin <edwintorok@g...>
Subject: OCaml defunctorization and other optimizations
Hi,

I've seen in several places recommendations to use 'ocamldefun' to speed
up OCaml programs that use functors heavily [*].

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?

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

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.

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

[*] For example when extracting ML programs from Coq using OCaml's
native 'int' type I get code like this (which is not inlined/optimized
at all by OCaml):
module Z_as_Int =
 struct
....
  let _2 = 2
  let mult = ( * )
...
end
module F =
 functor (I:Int) ->
 struct
  (** val mul2 : I.int -> I.int **)

  let mul2 n =
    I.mult I._2 n
 end
module F2 = F(Z_as_Int)

Best regards,
--Edwin