caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Compiling to OCaml bytecode
@ 2005-09-09  5:22 Jon Harrop
  2005-09-09 15:01 ` [Caml-list] " Paul Snively
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Harrop @ 2005-09-09  5:22 UTC (permalink / raw)
  To: caml-list


I am interested in improving the performance of a simple term-level 
interpreter. As OCaml's bytecode is so fast, I'd like to replace the 
interpreter with a JIT compiler that compiles to OCaml bytecode and then uses 
OCaml's bytecode interpreter to execute the generated code efficiently and 
handle the results.

Does the OCaml distribution expose everything needed to do this? I assume the 
Dynlink module is where I should be looking. I've never used it before but it 
looks as though it only loads from file (the "loadfile" function), so I'd 
have to compile to a .cmo file and load that. What is the easiest way to 
recover the result? If the necessary functionality is not already exposed, 
could it and/or what are the odds that it will be added?

Also, is a bytecode-compiled JIT bytecode compiler likely to outperform a 
native-code-compiled term-level interpreter? I assume the JIT compiler would 
itself need to be compiled to bytecode in order to provide the bytecode 
interpreter for the generated code.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Compiling to OCaml bytecode
  2005-09-09  5:22 Compiling to OCaml bytecode Jon Harrop
@ 2005-09-09 15:01 ` Paul Snively
  2005-09-13  0:48   ` Jon Harrop
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Snively @ 2005-09-09 15:01 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jon!

First: I love the book. :-)

On Sep 8, 2005, at 10:22 PM, Jon Harrop wrote:

>
> I am interested in improving the performance of a simple term-level
> interpreter. As OCaml's bytecode is so fast, I'd like to replace the
> interpreter with a JIT compiler that compiles to OCaml bytecode and  
> then uses
> OCaml's bytecode interpreter to execute the generated code  
> efficiently and
> handle the results.
>
Sounds like <http://oops.tercom.ru/dml> to me, or maybe even <http:// 
www.metaocaml.org>.

> Does the OCaml distribution expose everything needed to do this?

No.

> I assume the
> Dynlink module is where I should be looking. I've never used it  
> before but it
> looks as though it only loads from file (the "loadfile" function),  
> so I'd
> have to compile to a .cmo file and load that. What is the easiest  
> way to
> recover the result? If the necessary functionality is not already  
> exposed,
> could it and/or what are the odds that it will be added?
>
I really do think either Dynamic Caml or MetaOCaml will be what you  
want.

> Also, is a bytecode-compiled JIT bytecode compiler likely to  
> outperform a
> native-code-compiled term-level interpreter? I assume the JIT  
> compiler would
> itself need to be compiled to bytecode in order to provide the  
> bytecode
> interpreter for the generated code.
>
"What happens when you try it?" ;-)

> -- 
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> Objective CAML for Scientists
> http://www.ffconsultancy.com/products/ocaml_for_scientists
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

Best regards,
Paul

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iEYEARECAAYFAkMho78ACgkQO3fYpochAqIdUACgxu7XGJfX8IkS32rSc1FlUPQQ
NacAn1D9+RGTJbfwxT/J2Fh8h51/YOw3
=3VZS
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Compiling to OCaml bytecode
  2005-09-09 15:01 ` [Caml-list] " Paul Snively
@ 2005-09-13  0:48   ` Jon Harrop
  2005-09-13  6:19     ` Mackenzie Straight
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Harrop @ 2005-09-13  0:48 UTC (permalink / raw)
  To: caml-list

On Friday 09 September 2005 16:01, Paul Snively wrote:
> Hi Jon!
>
> First: I love the book. :-)

Thank you! :-)

> Sounds like <http://oops.tercom.ru/dml> to me, or maybe even <http://
> www.metaocaml.org>.

I believe the former has been dead for some time. MetaOCaml is still alive and 
kicking though. I studied it in some detail but somehow managed to forget 
about it now...

> > Does the OCaml distribution expose everything needed to do this?
>
> No.

Damn.

A ".cmo" is just a marshalled data structure though, right? So could I spit 
those out and then dynlink them back in?

> I really do think either Dynamic Caml or MetaOCaml will be what you
> want.

I'll have a play with MetaOCaml.

> "What happens when you try it?" ;-)

I'll keep you posted. :-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Compiling to OCaml bytecode
  2005-09-13  0:48   ` Jon Harrop
@ 2005-09-13  6:19     ` Mackenzie Straight
  2005-09-13  6:54       ` Jon Harrop
  0 siblings, 1 reply; 6+ messages in thread
From: Mackenzie Straight @ 2005-09-13  6:19 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On 9/12/05, Jon Harrop <jon@ffconsultancy.com> wrote: 
> > > Does the OCaml distribution expose everything needed to do this?
> >
> > No.
> 
> Damn.
> 
> A ".cmo" is just a marshalled data structure though, right? So could I spit
> those out and then dynlink them back in?

You may want to take a look at the modules under bytecomp/ --
specifically: Instruct, Meta, Emitcode. But really, MetaOCaml can
probably do what you want (and now supports native code on x86)...

--eiz


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Compiling to OCaml bytecode
  2005-09-13  6:19     ` Mackenzie Straight
@ 2005-09-13  6:54       ` Jon Harrop
  2005-09-13  7:17         ` skaller
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Harrop @ 2005-09-13  6:54 UTC (permalink / raw)
  To: caml-list

On Tuesday 13 September 2005 07:19, Mackenzie Straight wrote:
> You may want to take a look at the modules under bytecomp/ --
> specifically: Instruct, Meta, Emitcode.

Will do, thanks.

> But really, MetaOCaml can 
> probably do what you want (and now supports native code on x86)...

Yes, I'm just playing with it now. Absolutely fantastic to get native code 
support! Alas, it has come just as we've moved to AMD64. Grrr. :-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Compiling to OCaml bytecode
  2005-09-13  6:54       ` Jon Harrop
@ 2005-09-13  7:17         ` skaller
  0 siblings, 0 replies; 6+ messages in thread
From: skaller @ 2005-09-13  7:17 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

On Tue, 2005-09-13 at 07:54 +0100, Jon Harrop wrote:

> Yes, I'm just playing with it now. Absolutely fantastic to get native code 
> support! Alas, it has come just as we've moved to AMD64. Grrr. :-)

Same problem with Neko, Demexp, MLton and a host of other
products. One good thing about Ocaml! It has been made
clear for some time AMD64 is a major target and i386 is
deprecated: Cathedral got amd64 bit running early, and 
with hardly any visible problems (I found just one small
bug). Congrats!

BTW: is dynamic loading support for native code any
easier for x64_64? It would be really nice to build
dynamically loadable native code function libraries
with ocaml, not just statically linked programs.

-- 
John Skaller <skaller at users dot sourceforge dot net>


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-09-13  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-09  5:22 Compiling to OCaml bytecode Jon Harrop
2005-09-09 15:01 ` [Caml-list] " Paul Snively
2005-09-13  0:48   ` Jon Harrop
2005-09-13  6:19     ` Mackenzie Straight
2005-09-13  6:54       ` Jon Harrop
2005-09-13  7:17         ` skaller

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).