[Mono-devel-list] mcs code generation

Andre 'Ilu' Seidelt mono-devel01 at foobarquarium.de
Sun Mar 28 08:57:29 EST 2004


Hi,

given the following simple pice of code:
using System;

public class exception {
  public static string catchSome() {
    try {
      return new Object().ToString();
    } catch(NullReferenceException e) {
      return "";
    } catch(Exception e) {
      return "";
    }
  }
}
I get the following IL-code:

[...]
        .method public static hidebysig class System.String catchSome() cil 
managed
        {
                // Start of method header: 20f4
                .maxstack  3
                .locals    init (class 
[mscorlib]System.NullReferenceException,
                            class [mscorlib]System.Exception,
                            class System.String)
        ?L2100:
                newobj     instance void [mscorlib]System.Object::.ctor()
                callvirt   instance class System.String 
[mscorlib]System.Object::ToString()
                stloc.2
                leave      ?L2137
                leave      ?L2137
        ?L2115:
                stloc.0
                ldstr      ""
                stloc.2
                leave      ?L2137
                leave      ?L2137
        ?L2126:
                stloc.1
                ldstr      ""
                stloc.2
                leave      ?L2137
                leave      ?L2137
        ?L2137:
                ldloc.2
                ret
                .try ?L2100 to ?L2115 catch 
[mscorlib]System.NullReferenceException handler ?L2115 to ?L2126
                .try ?L2100 to ?L2115 catch [mscorlib]System.Exception 
handler ?L2126 to ?L2137
        }
[...]

why does mcs generate the leave twice for each block?
pnet-cscc and ms-csc doesn't, they even generate a leave.s instead of leave..

regards
	Ilu




More information about the Mono-devel-list mailing list