caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: reig@dcs.gla.ac.uk
To: caml-list@inria.fr
Cc: Basile.Starynkevitch@cea.fr (STARYNKEVITCH Basile),
	nr@eecs.harvard.edu (Norman Ramsey),
	reig@dcs.gla.ac.uk (Fermin Reig)
Subject: Re: [Caml-list] Ocaml and C--
Date: Tue, 5 Jun 2001 11:44:27 +0100 (BST)	[thread overview]
Message-ID: <200106051044.LAA13141@crab.dcs.gla.ac.uk> (raw)
In-Reply-To: <200105291930.f4TJUiL05545@wally.eecs.harvard.edu> from "Norman Ramsey" at May 29, 2001 03:30:52 PM

Norman Ramsey wrote:
> 
>  > Supposing that QC-- will deliver it promises...
>  > will Ocaml switch to target C-- or will Ocaml continue to
>  > natively target the usual architectures (x86, Alpha, Sparc, ia64,
>  > x86-64...)?
> 
> It's way too early to ask anyone to make this decision, because C-- is
> a long way away from being good enough and reliable enough to support
> a production compiler.  Having said that, Fermin Reig has been doing
> some very interesting experiments with OCaml and C--, which I hope he
> will comment on here.

I have modified ocamlopt to emit C-- instead of Mach code (Mach is
ocamlopt's intermediate language of abstract machine
instructions). The C-- backend produces code that is slightly slower
than the native ocamlopt backend (alpha/linux). I have identified
several reasons for this slowdown:

1. Memory allocation.

ocamlopt combines several allocations in the same basic block into one
that requests a larger chunk of memory. This is done in the Mach
internal representation, so we lose this optimization in the C--
backend. OCaml programs contain many individual allocations and each
allocation translates into a conditional branch, which is not cheap in
modern RISC proessors.

2. Instruction scheduling

ocamlopt does better instruction scheduling inside basic blocks than
the C-- compiler.

3. Garbage collection

The C-- compiler reports GC roots to the garbage collector that may
not be live at the point of the collection (the collector is still
type-accurate, but not liveness-accurate). This prevents some garbage
from being reclaimed and can make each collection to take longer.

Other minor issues that may slowdown garbage collection (email me if
you want to know the details).

4. Exception handling

It's a little bit more costly via C--, but so little that it should go
unnoticed (though I haven't measured it).


Fermin

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-06-05 10:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-29 11:25 STARYNKEVITCH Basile
2001-05-29 19:30 ` Norman Ramsey
2001-06-05 10:44   ` reig [this message]
2001-06-05 11:46 ` Xavier Leroy
2001-05-30 16:33 Hao-yang Wang
2001-06-05 21:23 David Gurr

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=200106051044.LAA13141@crab.dcs.gla.ac.uk \
    --to=reig@dcs.gla.ac.uk \
    --cc=Basile.Starynkevitch@cea.fr \
    --cc=caml-list@inria.fr \
    --cc=nr@eecs.harvard.edu \
    /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).