<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I have some data points on this. </div><div><br></div><div>- The style of exception handling employed by VMKit has in the past been used as an optimization. For example, OpenVM switched to this after using C++ exceptions for along time because it was a net performance win. This is because Java-like languages tend to do more exception throwing than the C++ runtime is tuned for and the cost of unwinding in C++ is too great: so paying one branch after every call ends up being cheaper, for many benchmarks, than using C++ exceptions because all benchmarks have some throwing (usually at least internally in the standard library). Such high exception volume may be a Javaism. </div><div><br></div><div>- WebKit uses LLVM and does exceptions. The implementation is incomplete (I.e. We won't use the LLVM JIT for some exception code paths) but the basic idea is there: 1) throwing an exception through a function that doesn't catch just means you need to just use unwind meta-data. That's easy with compact_unwind. 2) catching can be done by using either deoptimization (deoptimize the entire catching function) or by ensuring that state live in a catch is spilled. It's best to do both: use deoptimization if profiling tells you that the catch doesn't execute and switch to spilling if it does. The benefit is that the deopt approach is very fast if zero throwing happens and the spilling approach will let you implement very efficient unwinding for when it happens with high volume. </div><div><br></div><div>I'm not sure this can completely answer your question. Exception implementation is a tricky subject with many strategies and it's an area where you could easily come up with fresh ideas. :-) <br><br>-Filip</div><div><br>On May 1, 2014, at 2:09 PM, Kevin Modzelewski <<a href="mailto:kmod@dropbox.com">kmod@dropbox.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Hi all, I'm working on implementing exceptions in Pyston, and I was hoping to get some guidance from the list. I think I've learned enough about C++-style DWARF exceptions to convince myself I have a workable approach, but then I found this VMKit paper (2010) which says<div>
<br><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The exception manager: To manage exceptions, J3 reserves a<br>
word for the pending exception in the local storage of each thread.<br>After each method invocation, the word is tested. If an exception<br>has been raised and the function is able to trap the exception, a<br>branch to the exception handler is executed. Otherwise, the function<br>
returns to the caller. This implementation is not optimal because it<br>requires a test and branch after each method invocation. A more<br>efficient implementation would use exception tables. However, at<br>time of writing the paper, the exception tables generated by LLVM<br>
rely on the GCC runtime library [19] which is not optimized for<br>dynamically generated tables, at least on Linux.</blockquote></div><div><br></div><div>So now I'm reexamining whether C++-style exceptions are a good choice for Python, which I would guess throws more exceptions than Java.</div>
</div><div><br></div><div style="">Does anyone have advice on the subject? I'm wary of the costs of having to branch after every function call, but maybe that ends up not being too much of a performance drain if the CPU can predict them correctly? But then again, it looks like VMKit has moved to a setjmp-longjmp approach, which makes me think that there must have been some overhead that they wanted to avoid.</div>
<div style=""><br></div><div style="">I'm also curious about why libgcc is slow on dynamically generated tables, and if that's still true with MCJIT (I assume the VMKit change was made while on the old JIT).</div><div style="">
<br></div><div style="">thanks,</div><div style="">kmod</div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>LLVM Developers mailing list</span><br><span><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a></span><br><span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></span><br></div></blockquote></body></html>