caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Török Edwin" <edwintorok@gmail.com>
To: bluestorm <bluestorm.dylc@gmail.com>
Cc: Benedikt Meurer <benedikt.meurer@googlemail.com>,
	caml-list@yquem.inria.fr
Subject: Re: [Caml-list] OCamlJIT2 vs. OCamlJIT
Date: Tue, 30 Nov 2010 19:26:00 +0200	[thread overview]
Message-ID: <20101130192600.35698cde@deb0> (raw)
In-Reply-To: <AANLkTi=Wu1SXVgQ+X0NECNx3oUsD=xEy-9Zq6T3ncJ+W@mail.gmail.com>

On Tue, 30 Nov 2010 18:01:28 +0100
bluestorm <bluestorm.dylc@gmail.com> wrote:

> On Tue, Nov 30, 2010 at 11:55 AM, Benedikt Meurer <
> benedikt.meurer@googlemail.com> wrote:
> >
> > LLVM backend for ocamlopt is a totally different story. You'd have
> > to start with the Ulambda or the Cmm intermediate representation,
> > while a JIT approach starts with the byte-code representation (not
> > necessarily, but that was the case for our approach).
> >
> > However, I'm not sure there would be any immediate benefit from
> > using LLVM as code generator backend for ocamlopt, since ocamlopt
> > already does a quite good (and fast) job.

I thought you already had some code to do that, but thrown it away
because the JIT was too slow. Was just trying to point out that such
code shouldn't be thrown away completely.
Did the LLVM code you had take OCaml bytecode or Ulambda/Cmm as
input?

> >  So besides probably
> > educational or research interests, what would be the practical
> > benefit of LLVM inside ocamlopt?
> >
> 
> There would be several advantages in switching to LLVM for code
> generation. The general idea is that if other people work on the
> low-level stuff, it is less work for the OCaml implementors.
> 
> - more portability : while I'm not sure LLVM is ported to more
> platforms than OCaml right now,

OCaml's tier 1 platforms are supported by LLVM. Ocaml's tier 2 support
has more architectures than LLVM though.

> the LLVM community will probably port
> its bytecode to numerous architectures in the future;

I've seen some microcontroller backends added lately, but I've also seen
unmaintained and broken backends removed (IA-64 for example).

> in contrast,
> maintining numerous backend in the OCaml compiler has a maintainance
> cost. In particular, cross-compilation would probably be easier.
> 
> - more optimizations : the LLVM guys try to develop a wide range of
> optimization passes between LLVM IR and native code, while ocamlopt is
> mostly a "non-optimising compiler". It's not clear however how much
> gain we could have, as OCaml has already optimized the most important
> parts, and a big part of the performance concerns are outside the
> LLVM area (data representation and GC). Still, the experience of
> GHC-LLVM has been quite positive, with noticeable improvements in
> some cases.
> 
> On the other hand, it may be non-trivial to adapt LLVM to cope with
> the OCaml runtime, the GC in particuliar, and that would probably
> involve upstream changes to LLVM.

There is some support for emitting (assembly, not JIT) code that works
with OCaml 3.10, it'd probably have to be adapted for 3.12:
http://llvm.org/svn/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
http://llvm.org/svn/llvm-project/llvm/trunk/lib/CodeGen/OcamlGC.cpp
http://llvm.org/releases/2.8/docs/GarbageCollection.html

> 
> LLVM is nice and trendy 

It'd be even nicer if it was written in OCaml, whenever I write C++
code lately it feels like I could've written the same with much less
code in OCaml.

If someone were to develop an LLVM backend for OCaml, I think it could
coexist with ocamlopt though, allowing the user to choose which backend
it wants to use.

> (though it's a shame the GNU guys, partly due
> to their own mistakes, are losing an important part of the FLOSS
> ecosystem to Apple...),

Well there could also be a GCC backend for OCaml, but I don't know how
one should get started writing one (or if it would be worth it).

Best regards,
--Edwin


  reply	other threads:[~2010-11-30 17:57 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30  8:36 Benedikt Meurer
2010-11-30 10:48 ` [Caml-list] " Török Edwin
2010-11-30 10:55   ` Benedikt Meurer
2010-11-30 17:01     ` bluestorm
2010-11-30 17:26       ` Török Edwin [this message]
2010-11-30 18:27         ` Basile Starynkevitch
2010-11-30 17:29       ` Benedikt Meurer
2010-11-30 17:32       ` Yoann Padioleau
2010-11-30 22:06         ` Jon Harrop
2010-11-30 22:48           ` Benedikt Meurer
2010-12-01 14:11             ` Jon Harrop
2010-12-01 15:00               ` Benedikt Meurer
2010-12-01 22:03                 ` Jon Harrop
2010-12-02  1:17                   ` Eray Ozkural
2010-12-03 10:03                   ` ocamlopt LLVM support (Was: [Caml-list] OCamlJIT2 vs. OCamlJIT) Benedikt Meurer
2010-12-03 13:34                     ` Till Varoquaux
2010-12-03 13:41                       ` Eray Ozkural
2010-12-03 14:06                         ` Török Edwin
2010-12-03 21:16                       ` Jon Harrop
2010-12-05 16:44                       ` Benedikt Meurer
2010-12-03 14:32                     ` Philippe Strauss
2010-12-03 21:22                       ` Jon Harrop
2010-12-03 21:45                         ` Philippe Strauss
2010-12-03 15:32                     ` Michael Ekstrand
2010-12-03 21:34                       ` Jon Harrop
2010-12-03 20:07                     ` Jon Harrop
2010-12-05 16:37                       ` Benedikt Meurer
2010-12-05 16:57                         ` Török Edwin
2010-12-05 20:54                           ` Benedikt Meurer
2010-12-05 20:12                         ` Jon Harrop
2010-12-05 21:21                           ` Benedikt Meurer
2010-12-05 21:44                             ` Benedikt Meurer
2010-12-06 22:38                             ` Jon Harrop
2010-12-05 22:41                           ` Erik de Castro Lopo
2010-12-05 22:34                         ` Erik de Castro Lopo
2010-12-06  8:27                           ` Benedikt Meurer
2010-12-06  9:28                             ` David Rajchenbach-Teller
2010-12-06 11:08                         ` Richard Jones
2010-12-06 20:18                           ` Jon Harrop
2010-12-01  0:16           ` [Caml-list] OCamlJIT2 vs. OCamlJIT Erik de Castro Lopo
2010-12-01  1:34             ` Yoann Padioleau
2010-12-01 12:58             ` Jon Harrop
2010-12-01 13:55               ` ivan chollet
2010-11-30 21:19       ` Jon Harrop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101130192600.35698cde@deb0 \
    --to=edwintorok@gmail.com \
    --cc=benedikt.meurer@googlemail.com \
    --cc=bluestorm.dylc@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).