From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA01125; Fri, 18 Jun 2004 19:07:19 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA01116 for ; Fri, 18 Jun 2004 19:07:18 +0200 (MET DST) Received: from mail.davidb.org (adsl-64-172-240-129.dsl.sndg02.pacbell.net [64.172.240.129]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i5IH7GSH031943 for ; Fri, 18 Jun 2004 19:07:17 +0200 Received: from davidb by mail.davidb.org with local (Exim 3.36 #1 (Debian)) id 1BbMpa-0001VB-00; Fri, 18 Jun 2004 10:07:10 -0700 Date: Fri, 18 Jun 2004 10:07:10 -0700 From: David Brown To: Brian Hurt Cc: Ville-Pertti Keinonen , Ocaml Mailing List Subject: Re: [Caml-list] Great Programming Language Shootout Revived Message-ID: <20040618170710.GA5672@davidb.org> References: <06D9583C-C0FD-11D8-8AC7-000393863F70@exomi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Miltered: at concorde with ID 40D32145.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 caml-list:01 shootout:01 2004:99 slower:01 unroll:01 unrolling:01 unrolling:01 implemented:01 implemented:01 gcc:01 descriptor:01 gnat:01 exception:02 exception:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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