Can't catch exception in asmjit

197 Views Asked by At

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 ?

1

There are 1 best solutions below

0
Monkey Shen On

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.