Browse thread
[Caml-list] Does Caml have slow arithmetics ?
-
Diego Olivier Fernandez Pons
- Richard Jones
-
Basile Starynkevitch [local]
- Diego Olivier Fernandez Pons
-
Evgeny Chukreev
-
Xavier Leroy
- Evgeny Chukreev
-
skaller
- David Brown
- Alex Baretta
- Jon Harrop
-
Xavier Leroy
[
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: | Markus Mottl <markus@o...> |
| Subject: | Re: [Caml-list] Does Caml have slow arithmetics ? |
On Thu, 08 Jul 2004, Alex Baretta wrote: > Luc Maranget wrote: > >+ ocamlopt does it less often. Namely, calls in tail position > > become real tail calls when all their arguments are passed in registers. > > (This does not apply to self-tail calls which are always optimized) > > > What?! Is this true? This effectively means that I cannot count on > tail-call elimination in general? No, you can't. If you happen to use a register-starved architecture like IA-32 and call an OCaml-function with more than six parameters, then you are out of luck, because you'll have to throw things on the stack. AFAIK, the OCaml compiler generates closures on the heap to work around this, but only in cases where the recursion is obvious (self-tail calls). Hm, shouldn't be too difficult to extend this to mutual recursion? Or does OCaml already do this? I usually avoid recursive functions with more than six parameters for performance reasons. I wrap them in closures, which bind constant parameters, or, if there are too many volatile parameters, I modify the volatile parameters in references outside of the function. Another (less efficient) solution would be to use tuples to pass volatile parameters. The ultimate solution is, of course: buy a better architecture :-) Regards, Markus -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at ------------------- 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