[Mono-bugs] [Bug 62150][Wis] New - Idea for some exception handling speedups

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 30 Jul 2004 13:02:00 -0400 (EDT)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by lupus@ximian.com.


--- shadow/62150	2004-07-30 13:02:00.000000000 -0400
+++ shadow/62150.tmp.24313	2004-07-30 13:02:00.000000000 -0400
@@ -0,0 +1,42 @@
+Bug#: 62150
+Product: Mono: Runtime
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lupus@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Idea for some exception handling speedups
+I had a more elaborate proposal in the works for this issue which required
+some metadata changes and/or compiler help, but today I realized the JIT
+could handle the issue by itself.
+The main issue is that to implement many languages on the CLR (see python
+or perl) and multiprecision arithmetric, the overflow-checking opcodes are
+used, but exception object creation and handling may have a big cost.
+Most of these cases would use code like:
+try {
+ checked { x = y + z; }
+} catch (OverflowException) {
+  // fix up
+Now, in most cases like this, the jit does a check on a flag and jumps to
+the code that creates and throws the exception.
+In cases like this, the JIT could recognize that an overflow exception
+would be handled by the catch clause in the same method and that the catch
+clause code begins with a pop. This means the object doesn't need to be
+created, the exception handling code doesn't need to be involved and this
+pattern would be executed at very good speed.
+rethrow is a special case and if used the optimization can't be
+implemented. There may be other special cases that need to be considered
+(fault clauses, maybe?)
+This should be a simple optimization for a jit hacker that wants to start
+dipping his toes in the mono jit internals, too.