Re: The performance cost of using exceptions?

From: Xavier Leroy (xleroy@pauillac.inria.fr)
Date: Tue May 16 2000 - 11:55:06 MET DST

  • Next message: Frank Atanassow: "Re: The performance cost of using exceptions?"

    > Are programs written to make heavy use of exceptions going to be markedly
    > slower than programs written more traditionally with loops/ifs, etc?
    > (My uninformed mental picture of exception is that they would use
    > some type of underlying setjump/longjump overhead.)

    The OCaml compiler "knows" about exceptions, so it can implement them
    more efficiently than setjmp/longjmp. Namely, there is no need to
    save registers to install an exception handler and to restore them
    when raising an exception.

    As rought approximations, I would say that raising an exception costs
    no more than, say, two calls to unknown functions, and installing an
    exception handler costs no more than one such call.

    - Xavier Leroy



    This archive was generated by hypermail 2b29 : Tue May 16 2000 - 12:41:34 MET DST