caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques GARRIGUE <garrigue@math.nagoya-u.ac.jp>
To: joelr1@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] What is a match statement translated into?
Date: Sat, 18 Aug 2007 16:42:40 +0900 (JST)	[thread overview]
Message-ID: <20070818.164240.2004159589.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <1A6B8F53-FDA5-4F37-BA08-1FBD9CF09E7B@gmail.com>

From: Joel Reymont <joelr1@gmail.com>

> Is pattern-matching code in OCaml expanded into threaded code (pre- 
> computed branch table) or something analogous to the C switch  
> statement (lots of branching)?

I do not understand your description of C compilation: this certainly
depends a lot on the compiler and the optimization level.
OCaml does different things according to the data matched, using a
table when it is compact enough, or branches otherwise. So there is
no uniform answer, just that it is rather optimized.

> How do I find out?
> 
> I suspect this should be quite optimized but I haven't tried dumping  
> disassembling native-compiled OCaml yet and I wonder if there's a  
> simpler approach.

No need to disassemble: you can just dump the assembler with the -S
flag. And this is probably the most instructive approach, as the
compiler itself is quite involved.

Jacques Garrigue


  reply	other threads:[~2007-08-18  7:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-18  6:55 Joel Reymont
2007-08-18  7:42 ` Jacques GARRIGUE [this message]
2007-08-18 10:22 ` [Caml-list] " 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=20070818.164240.2004159589.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@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).