From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 877CBBC69 for ; Thu, 16 Aug 2007 20:07:04 +0200 (CEST) Received: from pd4mo2so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7GI73dq030894 for ; Thu, 16 Aug 2007 20:07:04 +0200 Received: from pd2mr2so.prod.shaw.ca (pd2mr2so-qfe3.prod.shaw.ca [10.0.141.109]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JMV00KPEOXI8K20@l-daemon> for caml-list@inria.fr; Thu, 16 Aug 2007 12:05:42 -0600 (MDT) Received: from pn2ml9so.prod.shaw.ca ([10.0.121.7]) by pd2mr2so.prod.shaw.ca (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0JMV00CBAOXI6510@pd2mr2so.prod.shaw.ca> for caml-list@inria.fr; Thu, 16 Aug 2007 12:05:42 -0600 (MDT) Received: from glek.net ([24.108.194.183]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JMV005VGOXHHTE0@l-daemon> for caml-list@inria.fr; Thu, 16 Aug 2007 12:05:41 -0600 (MDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by glek.net (Postfix) with ESMTP id 7BE7C47DAC; Thu, 16 Aug 2007 11:04:08 -0700 (PDT) Date: Thu, 16 Aug 2007 11:05:28 -0700 From: Taras Glek Subject: Re: [Caml-list] JIT VM in OCaml: Impossible? In-reply-to: <1187285851.6017.17.camel@rosella.wigram> To: skaller Cc: Gordon Henriksen , Caml List Message-id: <46C491E8.9010007@shaw.ca> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <5C180944-2CD9-48FB-8802-8AF57972AD2C@gmail.com> <4DB2486A-4E68-4843-A02C-B058DB2CA28D@mac.com> <1187285851.6017.17.camel@rosella.wigram> User-Agent: Thunderbird 2.0.0.0 (X11/20070326) X-Miltered: at concorde with ID 46C49247.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 runtime:01 compiler:01 toolchain:01 compiler:01 10,:98 bloody:98 wrote:01 wrote:01 unix:01 compile:01 compiles:01 caml-list:01 data:02 skaller wrote: > On Thu, 2007-08-16 at 12:24 -0400, Gordon Henriksen wrote: > >> On 2007-08-16, at 10:10, Joel Reymont wrote: >> >> >>> Is it possible to write a JIT VM in OCaml? >>> >>> >>> It seems that this should not be possible as OCaml does not allow >>> for code generation at runtime. Am I mistaken? >>> >> Sure. You could write a compiler and assembler in ocaml. >> But you'd need to write glue code in C or assembly to >> convert the ocaml representation to machine data structures, >> > > Why? Ocaml is just as capable of generating binary data as C .. > if not more capable. You would need some glue to actually > *execute* this code, but that is also true in C. For Unix, > mmap() would probably be used. > > The question is: why would you do this? Why not just generate > C (or C++ as Felix does) and compile it to a shared library, > then link and execute it? > Because that would be bloody slow and depend on having a toolchain installed? For a JIT you want a fast compiler that only compiles as little as is needed. Taras