4 ms·
Zero cost refers to the cost when no exception is thrown, not the overhead of exceptions. It may be more expensive throwing an exception under "zero cost" excep
by pca006132 5y ago
Zero cost refers to the cost when no exception is thrown, not the overhead of exceptions. It may be more expensive throwing an exception under "zero cost" exception model, as throwing an exception may require parsing some data in the executable. (I'm not sure about the implementation, so this is just a may...)
- SideburnsOfDoom 5y ago> Zero cost refers to the cost when no exception is thrown, not the overhead of exceptions There are recent benchmarks where .NET "zero cost when an try-catch block is present and exception not thrown" turned out to be significantly slower then the alternative without such a block. It turns out that the try-catch block is a barrier across which some optimisations and re-organisations (e.g. method inlining) cannot happen, and that the compiler & JIT normally do a lot of these. So it might be "zero cost" but it might also prevent wins. Edit: see here https://blogs.msmvps.com/peterritchie/2007/06/22/performance-implications-of-try-catch-finally/ https://blogs.msmvps.com/peterritchie/2007/06/22/performance... https://stackoverflow.com/questions/1308432/do-try-catch-blocks-hurt-performance-when-exceptions-are-not-thrown https://stackoverflow.com/questions/1308432/do-try-catch-blo...
- masklinn 5y agoMakes sense. Basically it’s zero-cost for exceptions-unaware code. I don’t know if it’s been changed with more modern jits but used to be chrome was unable to jit functions with try statements (similar to functions using `arguments` or `with` I think).