Version française
Home     About     Download     Resources     Contact us    
Browse thread
JIT VM in OCaml: Impossible?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Taras Glek <taras.judge@s...>
Subject: Re: [Caml-list] JIT VM in OCaml: Impossible?
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