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 E450FBBAF for ; Thu, 20 May 2010 13:15:52 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AogCAFe29EtIDtyfkGdsb2JhbACdeggVAQEBAQkJDAcRAx+IKqNzggGFHi6ITgEBAwWCaQiCHASDOw X-IronPort-AV: E=Sophos;i="4.53,271,1272837600"; d="scan'208";a="51524298" Received: from fg-out-1718.google.com ([72.14.220.159]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 May 2010 13:15:52 +0200 Received: by fg-out-1718.google.com with SMTP id e12so378007fga.3 for ; Thu, 20 May 2010 04:15:52 -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:cc:subject:references:in-reply-to :x-enigmail-version:openpgp:content-type:content-transfer-encoding; bh=b6mSuZv0LfHarcK6irnHhycknAk+0LDLJa920OcvCaQ=; b=P2G44BMNaEQYT3jVQfAMaLiPpTF8rSsfE2/6xg/ap36TnUJ158RLVgEjxpjV2yULEk WccG4fWrqkalNJYm+3TP2nj5NVKt9NG12oHCnr0W1bsvdkQ6mSoOiiF2NqwpNMSqxun8 K8oMgBeZlwINhcbqp5yE872RjJxieowk2HkbI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:openpgp:content-type :content-transfer-encoding; b=STQO7kzbAqQ4ciXNmDsqcXV93+g7XakocPeLOqvAQW4XLfBAGWQ1et860IR2qadUVc Kd7Ih4yi99vD6S7AJ8b7hyMS3Jl6OfLlSXlJvi3XEwvtkrSv11weWVugNeH/0wPgusU+ a3wkytnl6Ts80/aEeQD2MwT57JtdDQKtSoEtc= Received: by 10.102.17.22 with SMTP id 22mr66492muq.37.1274354151332; Thu, 20 May 2010 04:15:51 -0700 (PDT) Received: from debian ([79.114.106.90]) by mx.google.com with ESMTPS id j2sm38303690mue.53.2010.05.20.04.15.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 20 May 2010 04:15:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by debian (Postfix) with ESMTP id 850ED28816; Thu, 20 May 2010 14:15:48 +0300 (EEST) Message-ID: <4BF519E4.8040402@gmail.com> Date: Thu, 20 May 2010 14:15:48 +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: Julien Signoles Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml defunctorization and other optimizations References: <4BF3E071.9040901@gmail.com> In-Reply-To: X-Enigmail-Version: 1.0.1 OpenPGP: id=5379965D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; ocaml:01 signoles:01 ocaml:01 camlp:01 camlp:01 recursive:01 recursive:01 syntax:01 compiler:01 compiler:01 contrib:01 edwin:98 edwin:98 wrote:01 abstract:01 On 05/20/2010 11:41 AM, Julien Signoles wrote: > Hello, > > 2010/5/19 Török Edwin > > > 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 Thanks, this sounds good so far. >, but I > have no time from a while ago in order to implement myself a new version > of ocamldefun. Yes time is an issue for me too. > I could provide some helps to someone motivated... I think that'll have to be someone else than me, as I consider myself just a beginner in OCaml. However if you think that implementing AST transforms would be possible for a beginner (in OCaml, I do have experience with compilers), I'm willing to give it a try. > > 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. It looks like there is access to AST, I don't know if it is the full AST or just a simplified view: http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree http://brion.inria.fr/gallium/index.php/Camlp4MapGenerator > > > 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 it? Right, so I would need an AST that has all the infered type information. I don't know if Camlp4 can offer that. > > > 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. I think that if there is a defunctorizer written it should live in the OCaml distribution itself (maybe in contrib/). I certainly don't intend to write an external tool that uses OCaml internal modules. Best regards, --Edwin