[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques GARRIGUE <garrigue@m...> |
| Subject: | Re: [Caml-list] What is a match statement translated into? |
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