r/transprogrammer • • Jul 20 '24

Implementing exceptions

Just wanna know if anyone knows a more time-efficient way of implementing exceptions in a language than this or sees any issues with this design :3

(I know this flow chart sucks, sry)

handlethrow would exist separately for each try-catch clause

(obv this will only work for x86 but smth similar should work for all major architectures)

15 Upvotes

25 comments sorted by

View all comments

Show parent comment

1

u/definitelynotagirl99 Jul 21 '24

good that you mention the icache, i actually didnt consider that one.
that said tho, seeing as jcc handlethrow is either 2 or 4 bytes depending on distance and that could be optimized to jcc epilogue for any block of code that has no handlers of its own so i wouldn't be too worried about increasing code size too much. further more, the systems you mentioned should run into an even bigger caching issue since those need to access various structures in memory that may or may not be cached. i'm just hoping to shave off overhead by not accessing any memory or other external resources. It's also worth mentioning that this is mainly designed to perform well in scenarios where there is a handler within only 1 or 2 frames.