caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Benedikt Meurer <benedikt.meurer@googlemail.com>
Cc: caml-list@yquem.inria.fr
Subject: Native toplevel? (was: OCamlJit 2.0)
Date: Wed, 17 Nov 2010 09:44:04 +0100	[thread overview]
Message-ID: <4CE395D4.4000105@frisch.fr> (raw)
In-Reply-To: <D252EA22-12B7-4161-8F51-B09A505424D7@googlemail.com>

On 11/16/2010 03:52 PM, Benedikt Meurer wrote:
> OCamlJit 2.0 was specifically designed for desktop processors and is
> not really portable to anything else in its current shape, because
> the target audience are people using the interactive top-level and
> the byte-code interpreter for rapid prototyping/development

This looks like a very interesting project!

Does performance really matter that much for rapid 
prototyping/development?  I can imagine other uses of the toplevel where 
performance matters more, like theorem provers embedded in the OCaml 
toplevel.

Anyway, another option to get a more efficient interactive top-level is 
to turn to native code.

There is actually already a native top-level in the distribution, even 
though it is undocumented and unmaintained.  You can build it with the 
"make ocamlnat" target.  The implementation is based on the same 
approach as native dynlink.  The toplevel embeds the native compiler; 
for each phrase, the toplevel produces assembly code, calls the 
assembler and the linker to produce a dynamic/shared library, and then 
dynamically load and execute the resulting code.  This gives some 
latency, but it's not so bad in practice, and you get the full speed of 
native code.

A further step to improve this native toplevel is to avoid the call to 
the external assembler and linker.  To do that, one basically needs to 
replace the assembly code emitters (emit.mlp/emit_nt.mlp) with native 
code emitters and do the relocation/dynamic loading by hand, which is 
quite easy.

As it turns out, LexiFi uses on a daily basis such direct binary code 
emitters for x86/amd64 on Windows, and that would be easy to port to 
other x86/amd64 platforms.  The x86 version was developed internally, 
and the amd64 version was done by Fabrice Le Fessant.  There is also 
some code to wrap the binary code into COFF objects (and flexdll has a 
stand-alone mode to produce .cmxs files without an external linker), but 
that would be useless for a native toplevel. The goal was to have a 
compiler which can be more easily embedded in our applications and 
deployed to our customers, without depending on any external tool.


If you Benedikt, or someone else, is willing to work on a native 
top-level without the need to call an external assembler/linker, we are 
ready to extract the binary code emitters from our code base and share 
them with the community (with an open-source license to be determined). 
This requires some packaging work on our side, so we're going to do it 
only if there is interest in the project.


(Another nice side project, for having a good native toplevel, would be 
to extend ocamlopt with some control over the trade-off between speed of 
code generation, and the performance of the generated code. One way to 
do it is to force the interference graph to remain not too big, by 
spilling early, in order to avoid quadratic behavior in the register 
allocator.)


-- Alain



  parent reply	other threads:[~2010-11-17  8:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16 14:52 OCamlJit 2.0 Benedikt Meurer
2010-11-16 17:07 ` [Caml-list] " bluestorm
2010-11-16 17:32   ` Benedikt Meurer
2010-11-17  8:44 ` Alain Frisch [this message]
2010-11-17 10:46   ` Native toplevel? (was: OCamlJit 2.0) Satoshi Ogasawara
2010-11-17 11:38   ` Sylvain Le Gall
2010-11-17 22:57   ` [Caml-list] Native toplevel? Wojciech Daniel Meyer
2010-11-18 16:49   ` [Caml-list] Native toplevel? (was: OCamlJit 2.0) Ashish Agarwal
2010-11-19 18:09     ` David MENTRE
2010-11-19 18:24       ` Hezekiah M. Carty
2010-11-19 18:30         ` Ashish Agarwal
2010-11-19 18:42           ` Benedikt Meurer
2010-11-20 11:49     ` Jon Harrop
2010-11-18 18:19   ` Benedikt Meurer
     [not found]   ` <2025993285.616104.1290144569061.JavaMail.root@zmbs4.inria.fr>
2010-11-19 10:02     ` [Caml-list] Re: Native toplevel? Fabrice Le Fessant
2010-11-19 19:16       ` Benedikt Meurer
2010-11-19 18:43 ` [Caml-list] OCamlJit 2.0 Yoann Padioleau
2010-11-19 19:10   ` Benedikt Meurer
2010-11-20 15:59     ` Yoann Padioleau
2010-11-19 19:46   ` Dario Teixeira
2010-11-19 20:20     ` Yoann Padioleau
2010-11-20 15:19       ` [Was: OCamlJit 2.0] Vincent Balat
2010-11-20 15:42         ` [Caml-list] " Benedikt Meurer
2010-11-20 16:10           ` Yoann Padioleau
2010-11-20 16:25             ` Benedikt Meurer
2010-11-20 17:35               ` Yoann Padioleau
2010-11-20 17:08             ` Jon Harrop
2010-11-20 17:37               ` Yoann Padioleau
2010-11-20 17:48                 ` Sylvain Le Gall
2010-11-20 18:51                   ` [Caml-list] " Jon Harrop
2010-11-20 18:05                 ` [Caml-list] " Jon Harrop
2010-11-20 17:15             ` Gerd Stolpmann
2010-11-23  2:09             ` Elias Gabriel Amaral da Silva
2010-11-24  7:20     ` [Caml-list] OCamlJit 2.0 Alain Frisch
2010-11-24  7:59       ` Yoann Padioleau
2010-11-24  9:04       ` Compiling to Javascript Jerome Vouillon

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=4CE395D4.4000105@frisch.fr \
    --to=alain@frisch.fr \
    --cc=benedikt.meurer@googlemail.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).