Browse thread
[Caml-list] Great Programming Language Shootout Revived
[
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: | 2004-06-18 (17:07) |
From: | David Brown <caml-list@d...> |
Subject: | Re: [Caml-list] Great Programming Language Shootout Revived |
On Fri, Jun 18, 2004 at 10:38:45AM -0500, Brian Hurt wrote: > As a side note, there is a reason why C++ is slower than C, even if you're > compiling the exact same code. C++ functions need to be able to handle > exceptions and unroll the stack, even if the function itself doesn't throw > or catch exceptions. Even if unrolling the stack is a no-op, the function > generally needs to be able to both be handed off from another function's > stack unrolling, and hand off to another function's stack unrolling. That depends on how exceptions are implemented. There is a cost to exceptions that can be paid at different times: - At each exception catch (try). - At each exception occurrence (raise). - At every call. I've not actually seen the third case implemented. For some test cases, the actual function code generated by gcc and g++ are identical. g++ contains an extra descriptor to facilitate stack unwinding. It appears that g++ pays most of the exception cost on raise (which is probably best for C++ where exceptions are truly, exceptional). So, aside from cache differences due to the layout of the structures, the C-type code should execute at the same speed with C++ and C. Most gnat (Ada) targets also implement these "zero cost" exceptions, where the raise pays the cost, rather than catch. Dave ------------------- 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