I'm using asmjit and I came across a problem. When c++ exception being throwed by a function called in generated jit code (x64), it can not be catched even if I do try-catch outside the jit function call, why's that and how can I catch the exception ?
Asked
Active
Viewed 184 times
0
-
Please show us a [mcve]. – Algirdas Preidžius Nov 02 '16 at 13:48
-
I would suggest changing the question to a more generic question, something like "How to handle exceptions in JIT generated code", as it's not strictly related to asmjit - I mean the op is asking for a solution related to asmjit, but the question could be answered in a more generic way first, and then shown how it could be done with asmjit as well. – Petr Nov 28 '16 at 12:00
1 Answers
0
The answer of asmjit's author Petr Kobalíček via Email, very helpful:
it highly depends on OS you are targeting. AsmJit doesn't provide any helpers for exception handling, so you need to handle exceptions yourself.
If you are on Windows you can check out: https://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
Also, checking other JIT engines like V8 can help you understand how JITted code usually handles exceptions. On Windows you can install an exception handler for the whole virtual address space JIT code uses, this way you don't have to embed unwind data for each function.

Monkey Shen
- 199
- 1
- 6