From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 6DC8ABBAF for ; Wed, 19 May 2010 14:58:30 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AggEAHd980vRVaE0mGdsb2JhbACSBIwJCBUBAQEBAQgJDAcRIqxMggCFRy6ITgEBAwWFCwSDOw X-IronPort-AV: E=Sophos;i="4.53,263,1272837600"; d="scan'208";a="51453090" Received: from mail-fx0-f52.google.com ([209.85.161.52]) by mail2-smtp-roc.national.inria.fr with ESMTP; 19 May 2010 14:58:30 +0200 Received: by fxm11 with SMTP id 11so846361fxm.39 for ; Wed, 19 May 2010 05:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:openpgp :content-type:content-transfer-encoding; bh=DlTe5UjLYuKm7uWIdbEgsox6N/VMiaqpr9/7HPgsBic=; b=xcUEO3JnAz6X9YqCs3Wpn4f5HrSpdP0obT+rot6su1Qlk4h/0EWHh0QMo6ipgBjbGW jvf46Y0OZewgbC9mgjZEfMy9eelUF8ZHakZ7y22m4YEjeCI0pAjRAe6aJb9RERPJ1XyT uzXlZ+xr7XcBUrF6dvhHqCD1x0Wx6tmgxbTkM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=OpnfIH4N4RHvZKdevNjqWBIBbXss14avc9414YatqnJRQzKz76qzd0CPFzv7qCIAxH xELoQX0oe9sm5hL2b5Ad9JaGXJcAqLeiDAtnVtf4KYRg1OWZ6AJAGBm1fAH8oELc6Tnf 1HX6+JG9Tl0ujNLXOIqqRRmpc4R1EJZ6JVX1c= Received: by 10.223.17.197 with SMTP id t5mr4938149faa.84.1274273907747; Wed, 19 May 2010 05:58:27 -0700 (PDT) Received: from debian ([79.114.31.137]) by mx.google.com with ESMTPS id y12sm5338972faj.17.2010.05.19.05.58.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 May 2010 05:58:26 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by debian (Postfix) with ESMTP id A0A9DB3236 for ; Wed, 19 May 2010 15:58:25 +0300 (EEST) Message-ID: <4BF3E071.9040901@gmail.com> Date: Wed, 19 May 2010 15:58:25 +0300 From: =?ISO-8859-1?Q?T=F6r=F6k_Edwin?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: OCaml defunctorization and other optimizations X-Enigmail-Version: 1.0.1 OpenPGP: id=5379965D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 ocaml:01 functors:01 camlp:01 coq:01 ocaml's:01 'int':01 inlined:01 struct:01 mult:01 functor:01 struct:01 val:01 mult:01 edwin:98 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