[Mono-devel-list] ilasm questions

Ben Maurer bmaurer at users.sourceforge.net
Thu Jan 15 21:30:21 EST 2004


Hello,

On Thu, 2004-01-15 at 16:52, Bart Van Rompaey wrote:
> 1) Mono doesn't make use of the short branch instructions (ex. bge.s). I
> presume using this could mean some runtime performance improvement?
No, we do not. It is very hard to emit these correctly with the
System.Reflection.Emit framework. There is 0 difference in runtime
performance, you just save 3 bytes, because you only use one byte for
the offset.

> 2) ms.net generates some weird code in case of branches. Let me give an
> example:
> 
> public static int fib (int n) {
> 	if (n < 2)
> 		return 1;
> 	return fib(n-2)+fib(n-1);
> }
> 
> The if structures translates to:
> 
> ms.net:
> 
> IL_0000:  ldarg.0
> IL_0001:  ldc.i4.2
> IL_0002:  bge.s IL_0008
> IL_0004:  ldc.i4.1
> IL_0005:  stloc.0
> IL_0006:  br.s IL_001c
> IL_0008:  ldarg.0
> ...
> IL_001c:  ldloc.0
> IL_001d:  ret
> 
> mono:
> IL_0000:  ldarg.0
> IL_0001:  ldc.i4.2
> IL_0002:  bge IL_0009
> IL_0007:  ldc.i4.1
> IL_0008:  ret
> IL_0009:  ldarg.0
> ... (rest of method)
> 
> Why would ms.net compile into that sequence of instructions? It has an
> extra store/load and and an extra branch instruction? Does anyone see
> some advantages of that?

MS.net does some really weird things if you do not pass /o+. However, I
would think a jit could optimize this sort of thing, so it is probably
not that important.




More information about the Mono-devel-list mailing list