caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: Joel Reymont <joelr1@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] High-performance bytecode interpreter in OCaml
Date: Thu, 16 Aug 2007 04:58:49 +0100	[thread overview]
Message-ID: <200708160458.49873.jon@ffconsultancy.com> (raw)
In-Reply-To: <3C3EDB59-44C1-4C3A-AD96-C762B986F39C@gmail.com>

On Thursday 16 August 2007 00:26:49 Joel Reymont wrote:
> On Aug 15, 2007, at 4:18 PM, Jon Harrop wrote:
> >   let rec compile bytecode = match bytecode with
> >
> >     | 0x83::x::t ->
> >
> >         let x = String.lowercase (string_of_int x) in
> >         let t = compile t in
> >         (fun k -> print_string x; k t)
>
> I'm curious, would this be any faster than doing whatever the 0x83
> opcode requires and then just invoking (compile t)?
>
> Does it actually make sense to convert the whole bytecode file into a
> chain of closures and then execute it repeatedly? Would there be a
> huge gain compared to interpreting every time?
>
> I guess it would make sense if closures could be compiled into
> machine code "just in time" or if my VM was compiled using ocamlopt.
> I'm not sure, though, so I'm looking for input.

Yes, this is not compilation, it just hoists code from the inner loop (such as 
String.lowercase and string_of_int in that case) and replaces dynamic 
dispatch with static dispatch. The former is usually the more important of 
the two optimizations, particularly if you can hoist lookups and replace them 
with single indirections.

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


  reply	other threads:[~2007-08-16 12:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-15 11:49 Joel Reymont
2007-08-15 13:01 ` [Caml-list] " Jon Harrop
2007-08-15 13:20   ` Joel Reymont
2007-08-15 15:18     ` Jon Harrop
2007-08-15 23:26       ` Joel Reymont
2007-08-16  3:58         ` Jon Harrop [this message]
2007-08-15 23:31     ` Grant Olson
2007-08-16 15:55       ` Jon Harrop

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=200708160458.49873.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=joelr1@gmail.com \
    /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).