caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Joel Reymont <joelr1@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Instruction selection in the OCaml compiler: Modules or	classes?
Date: Thu, 22 Feb 2007 18:38:41 +0100	[thread overview]
Message-ID: <45DDD521.8080004@inria.fr> (raw)
In-Reply-To: <6CB0D237-F894-4AC3-BDBE-2BB484928D3C@gmail.com>

> I'm reading through the icfp99 slides on classes vs modules in OCaml.
> The part that I'm interested in starts on p27 where instruction
> selection in the OCaml compiler is discussed.
>
> I'm not well-versed in the OCaml compiler code yet so I thought I  would
> ask the list: does the compiler use a module or class solution?

It uses classes, inheritance and overriding (of generic code by
processor-dependent code) for a few passes: instruction selection,
reloading of spilled registers, and instruction scheduling.  The other
passes are either processor-independent or can be parameterized in a
simpler way (e.g. register allocation, which is parameterized by the
number of hardware registers in each register class).

> The slides seem to favor the class-based solution but then I hear  that
> classes in OCaml are slow and people like Markus Mottl just  plain
> despise them :-). What does everyone else opine?

Method dispatch is slightly slower than calls to unknown functions,
but the compiler passes that use objects are not speed-critical anyway
(most of the compilation time is spent elsewhere).

I don't despise objects and classes: it's just that the kind of code
that I usually write does not need them often.  But there are some
cases where they work better than other forms of parameterization
available in OCaml.  Ensuring that the native-code compiler is not
polluted all over the place by Intel x86-specific hacks is one of them.

- Xavier Leroy


  parent reply	other threads:[~2007-02-22 17:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22 14:38 Joel Reymont
2007-02-22 17:21 ` [Caml-list] " Tom
2007-02-22 17:38 ` Xavier Leroy [this message]
2007-02-22 19:55 ` Chris King
2007-02-22 19:59 ` Markus Mottl
2007-02-23 16:13 ` brogoff
2007-02-23 18:14   ` Tom
2007-02-23 19:28     ` [Caml-list] Instruction selection in the OCaml compiler: Modulesor classes? Andreas Rossberg
2007-02-24  2:51       ` skaller
2007-02-24 11:48         ` David Baelde
     [not found]           ` <4a708d20702240518l2c430b06r18fe64cabe5cbe9@mail.gmail.com>
2007-02-24 13:33             ` Lukasz Stafiniak
2007-02-24 14:58         ` [Caml-list] Instruction selection in the OCaml compiler:Modulesor classes? Andreas Rossberg
2007-02-24 17:39           ` skaller

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=45DDD521.8080004@inria.fr \
    --to=xavier.leroy@inria.fr \
    --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).