Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] POSIX Threads: kill
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] register windows
> > 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