Permalink
Browse files

2009-01-21 Mark Probst <mark.probst@gmail.com>

	* method-to-ir.c: Only apply exception constructor optimization if
	the the method actually belongs to an exception class.  Fixes
	#467456.

2009-01-21  Mark Probst  <mark.probst@gmail.com>

	* bug-467456.cs: New test case.

	* Makefile.am: Test added.

svn path=/trunk/mono/; revision=124028
  • Loading branch information...
1 parent 10fa718 commit 47e99edeaf078c1a719ba483dcd367449a073d04 @schani schani committed Jan 21, 2009
Showing with 50 additions and 2 deletions.
  1. +6 −0 mono/mini/ChangeLog
  2. +13 −1 mono/mini/method-to-ir.c
  3. +6 −0 mono/tests/ChangeLog
  4. +2 −1 mono/tests/Makefile.am
  5. +23 −0 mono/tests/bug-467456.cs
View
@@ -1,3 +1,9 @@
+2009-01-21 Mark Probst <mark.probst@gmail.com>
+
+ * method-to-ir.c: Only apply exception constructor optimization if
+ the the method actually belongs to an exception class. Fixes
+ #467456.
+
2009-01-21 Zoltan Varga <vargaz@gmail.com>
* mini-trampolines.c (mono_delegate_trampoline): Put back the previous
View
@@ -5033,6 +5033,17 @@ emit_optimized_ldloca_ir (MonoCompile *cfg, unsigned char *ip, unsigned char *en
return NULL;
}
+static gboolean
+is_exception_class (MonoClass *class)
+{
+ while (class) {
+ if (class == mono_defaults.exception_class)
+ return TRUE;
+ class = class->parent;
+ }
+ return FALSE;
+}
+
/*
* mono_method_to_ir:
*
@@ -7189,7 +7200,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
* Generate smaller code for the common newobj <exception> instruction in
* argument checking code.
*/
- if (bblock->out_of_line && cmethod->klass->image == mono_defaults.corlib && n <= 2 &&
+ if (bblock->out_of_line && cmethod->klass->image == mono_defaults.corlib &&
+ is_exception_class (cmethod->klass) && n <= 2 &&
((n < 1) || (!fsig->params [0]->byref && fsig->params [0]->type == MONO_TYPE_STRING)) &&
((n < 2) || (!fsig->params [1]->byref && fsig->params [1]->type == MONO_TYPE_STRING))) {
MonoInst *iargs [3];
View
@@ -1,5 +1,11 @@
2009-01-21 Mark Probst <mark.probst@gmail.com>
+ * bug-467456.cs: New test case.
+
+ * Makefile.am: Test added.
+
+2009-01-21 Mark Probst <mark.probst@gmail.com>
+
* generic-unloading.2.cs, generic-unloading-sub.2.cs: Test case
for unloading images whose MonoGenericInst's are still in use.
View
@@ -338,7 +338,8 @@ BASE_TEST_CS_SRC= \
bug-462592.cs \
bug-459094.cs \
generic-unloading.2.cs \
- generic-unloading-sub.2.cs
+ generic-unloading-sub.2.cs \
+ bug-467456.cs
if AMD64
TEST_CS_SRC = $(BASE_TEST_CS_SRC) async-exc-compilation.cs
View
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+class Program
+{
+ static void Trigger () {
+ List<string> inners = new List<string> ();
+ inners.Add ("Failed to run update to completion");
+ throw new Exception ();
+ }
+
+ static int Main (string[] args)
+ {
+ try {
+ Trigger ();
+ } catch (TypeLoadException e) {
+ return 1;
+ } catch (Exception e) {
+ return 0;
+ }
+ return 1;
+ }
+}

0 comments on commit 47e99ed

Please sign in to comment.