Hacker News new | ask | show | jobs
by thealfreds 3022 days ago
The try/catch wasn't always that case. I'm having trouble finding the blog from one of the v8 developers who went into details about it and other optimizations. It was on HN a while back.

Here is a perf test with various v8 versions (as you noted not only JIT but going going with the authors favorite).

https://github.com/davidmarkclements/v8-perf

2 comments

My recollection is that the nonperformance of try/catch is something specific to the v8 JIT. Historically, the zero-cost exception model of try/catch has you do absolutely nothing with the data until someone throws an exception, at which point you work out how to map the return address to the appropriate catch handler.
v8 used to not be able to optimize blocks containing try/catch, which is why if you needed it, you relegated it to a function containing just the try/catch block.

but since async/await relies on the use of try/catch, last november's (october?) v8 release can optimize try/catch.

plus, it was only ever a v8 issue, not an issue in javascriptcore nor tracemonkey.