caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: John Carr <jfc@MIT.EDU>
Cc: OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] register windows
Date: Sat, 24 May 2003 11:56:31 +0200	[thread overview]
Message-ID: <20030524115631.C10663@pauillac.inria.fr> (raw)
In-Reply-To: <200305202126.RAA03623@no-knife.mit.edu>; from jfc@MIT.EDU on Tue, May 20, 2003 at 05:26:28PM -0400

> > A fixed-size register window is always going to save and restore too
> > many registers.
> 
> As long as you stay within the eight windows implemented in hardware
> saving the extra registers costs nothing -- a save instruction takes
> one cycle.

Well, you're thinking of the best case, and I'm thinking of the worst
case where the 8 hardware windows will overflow -- and in many
programs involving recursion, they do overflow very often.  In this case, the
whole contents of one or several windows are stored in memory (or
reloaded from memory), including those registers that are not used by
the program.  So, even if the corresponding OS traps have no overhead
(which is not true), the processor ends up doing more memory stores
and loads than strictly necessary.

> Register windows were invented when somebody observed that programs
> tended to stay within a small range of call depth.  That observation
> is about 25 years old.  Since then inlining has reduced call depth
> while the rise of giant libraries with layers and layers of wrapper
> functions has increased call depth.
> 
> The question is, are present-day ocaml programs typically the sort for
> which register windows are better?

My guess is "no".  Heavy use of recursion, as encouraged by Caml,
leads to call depths much larger than what the SPARC designers
observed on a few C programs 25 years ago.

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-05-24  9:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-16  8:24 [Caml-list] POSIX Threads: kill Christoph Bauer
2003-05-16  9:54 ` Xavier Leroy
2003-05-17 13:21   ` John Carr
2003-05-20 19:48     ` [Caml-list] register windows Xavier Leroy
2003-05-20 21:26       ` John Carr
2003-05-24  9:56         ` Xavier Leroy [this message]
2003-06-02 21:00     ` [Caml-list] POSIX Threads: kill John Max 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=20030524115631.C10663@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jfc@MIT.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).