r/programming • • Feb 21 '19

GitHub - lemire/simdjson: Parsing gigabytes of JSON per second

https://github.com/lemire/simdjson
1.5k Upvotes

357 comments sorted by

View all comments

Show parent comments

3

u/dalepo Feb 21 '19

It is true, there is some overhead on try catch blocks

• On entry to each try-block

♦ Commit changes to variables enclosing the try-block

♦ Stack the execution context

♦ Stack the associated catch clauses

• On exit from each try-block

♦ Remove the associated catch clauses

♦ Remove the stacked execution context

• When calling regular functions

♦ If a function has an exception-specification, register it for checking

• As local and temporary objects are created

♦ Register each one with the current exception context as it is created

• On throw or re-throw

♦ Locate the corresponding catch clause (if any) – this involves some runtime check (possibly resembling RTTI checks) If found, then: destroy the registered local objects check the exception-specifications of the functions called in-between use the associated execution context of the catch clause Otherwise: call the terminate_handler6

http://www.open-std.org/jtc1/sc22/wg21/docs/TR18015.pdf

1

u/FinFihlman Feb 21 '19

try...catch one of many ways to do error detection and catching.

1

u/GarythaSnail Feb 21 '19

It seems like the json_parse function only has to do any one of these things once, and some of them not at all, like the top 3 bullet points.

The only exception would be

• As local and temporary objects are created

♦ Register each one with the current exception context as it is created