English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
IBMs UVM? RE: JIT-compilation for OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-01-04 (21:18)
From: David Gurr <gurr@m...>
Subject: IBMs UVM? RE: JIT-compilation for OCaml?
OK, JVM is not an ideal target for compiling ML.  But what about
IBM's UVM.  Does anyone here know about IBM's VMs?  I have seen
hints that UVM started life as a VM for Smalltalk.  If so, it
is probabaly ML friendly.  Does anyone know more about this?

> It is well known (e.g. see the Kawa implementation of Scheme on the
> JVM) that the Java Virtual Machine is not well suited for functional
> programming: function closures and tail-recursion calls (which are
> actually jump with arguments) do not exist in the JVM, and emulating
> them (e.g. closures as instances of specially generated classes) is
> quite inefficient. The JVM is not as universal as Sun's marketing hype
> claim it is...
> On the contrary the Ocaml virtual machine was (of course) designed for
> functional programming, and efficiently implement tails calls and
> closure constructions.

There are a number of gotchas with compiling Ocaml to JVM but closures
are not really the problem.  Jumps do exist but they are only "within a
method"  Which means that you get lots of code duplication if you do a
naive compilation of a let rec.  But if you try the MLj (a SML to JVM
compiler written in SML) you will see that this really is not a
problem.  If I had to point to one single difference between the java
and ocaml runtimes that really simplifies compilation of Ocaml it would
be the universal data type (ie the union of 31 bit tagged ints and 32
bit pointers -- for 32 bit machines of course).  This makes it easy to
compile efficient polymorphic code.  With JVM you need to monomorphise
the code.  If you do so at compilation time you need the whole program
(al MLj and Milton) which works but ... .  But if the point of JVM is
to do JIT then it makes sense to do monomorphing at JIT time.  And
there are hooks to JVM so you can do this (and some people doing
generics for java have tried this).  My opinion after doing a fair bit
of this is that the Ocaml implementation is oh so much nicer to work
with so I've mostly lost interest in the subject.  A more promising
direction is to compile java to a 64bit ocaml runtime.  But I think
the Ocaml group does not like that idea.

- David Gurr

MLj : http://www.dcs.ed.ac.uk/home/mlj/